diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl | 24 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl | 123 |
2 files changed, 110 insertions, 37 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl index 15e02c9551..d5b4e278bc 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl @@ -53,8 +53,11 @@ VARYING vec3 vary_position; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; #ifdef HAS_NORMAL_MAP - VARYING vec3 vary_normal; - VARYING vec2 vary_texcoord1; +VARYING vec3 vary_normal; +VARYING vec3 vary_mat0; +VARYING vec3 vary_mat1; +VARYING vec3 vary_mat2; +VARYING vec2 vary_texcoord1; #endif #ifdef HAS_SPECULAR_MAP @@ -77,24 +80,31 @@ void main() #ifdef HAS_NORMAL_MAP vec4 norm = texture2D(bumpMap, vary_texcoord1.xy); - vec3 tnorm = norm.xyz * 2 - 1; + norm.xyz = norm.xyz * 2 - 1; + + vec3 tnorm = vec3(dot(norm.xyz,vary_mat0), + dot(norm.xyz,vary_mat1), + dot(norm.xyz,vary_mat2)); #else vec4 norm = vec4(0,0,0,1.0); // vec3 tnorm = vary_normal; vec3 tnorm = vec3(0,0,1); #endif + tnorm = normalize(tnorm.xyz); + + norm.xyz = normalize(tnorm.xyz); // RGB = Occlusion, Roughness, Metal // default values // occlusion ? // roughness 1.0 // metal 1.0 #ifdef HAS_SPECULAR_MAP - vec3 spec = texture2D(specularMap, vary_texcoord0.xy).rgb; // TODO: FIXME: vary_texcoord2 + vec3 spec = texture2D(specularMap, vary_texcoord2.xy).rgb; #else - vec3 spec = vec3(0,1,1); + vec3 spec = vec3(1,1,1); #endif - norm.xyz = normalize(tnorm.xyz); + #if DEBUG_BASIC col.rgb = vec3( 1, 0, 1 ); @@ -111,6 +121,6 @@ void main() frag_data[0] = vec4(col, 0.0); frag_data[1] = vec4(spec.rgb, vertex_color.a); // Occlusion, Roughness, Metal - frag_data[2] = vec4(encode_normal(norm.xyz), vertex_color.a, GBUFFER_FLAG_HAS_PBR); // + frag_data[2] = vec4(encode_normal(tnorm), vertex_color.a, GBUFFER_FLAG_HAS_PBR); // frag_data[3] = vec4(emissive,0); // Emissive } diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl index 58048687a5..a2606ed771 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl @@ -23,59 +23,122 @@ * $/LicenseInfo$ */ -uniform mat3 normal_matrix; -uniform mat4 texture_matrix0; +#define DIFFUSE_ALPHA_MODE_IGNORE 0 +#define DIFFUSE_ALPHA_MODE_BLEND 1 +#define DIFFUSE_ALPHA_MODE_MASK 2 +#define DIFFUSE_ALPHA_MODE_EMISSIVE 3 + +#ifdef HAS_SKIN uniform mat4 modelview_matrix; +uniform mat4 projection_matrix; +mat4 getObjectSkinnedTransform(); +#else +uniform mat3 normal_matrix; uniform mat4 modelview_projection_matrix; +#endif + +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) + +#if !defined(HAS_SKIN) +uniform mat4 modelview_matrix; +#endif + +VARYING vec3 vary_position; + +#endif + +uniform mat4 texture_matrix0; ATTRIBUTE vec3 position; ATTRIBUTE vec4 diffuse_color; ATTRIBUTE vec3 normal; ATTRIBUTE vec2 texcoord0; + #ifdef HAS_NORMAL_MAP - ATTRIBUTE vec4 tangent; - ATTRIBUTE vec2 texcoord1; - VARYING vec3 vary_mat0; - VARYING vec3 vary_mat1; - VARYING vec3 vary_mat2; -#endif +ATTRIBUTE vec4 tangent; +ATTRIBUTE vec2 texcoord1; -#if HAS_SPECULAR_MAP - ATTRIBUTE vec2 texcoord2; -#endif +VARYING vec3 vary_mat0; +VARYING vec3 vary_mat1; +VARYING vec3 vary_mat2; -VARYING vec3 vary_position; +VARYING vec2 vary_texcoord1; +#else VARYING vec3 vary_normal; +#endif + +#ifdef HAS_SPECULAR_MAP +ATTRIBUTE vec2 texcoord2; +VARYING vec2 vary_texcoord2; +#endif + VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; -VARYING vec2 vary_texcoord1; // normal map -VARYING vec2 vary_texcoord2; // specular map - -void passTextureIndex(); void main() { - //transform vertex - gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); - vary_position = (modelview_matrix * vec4(position.xyz,1.0)).xyz; - vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; +#ifdef HAS_SKIN + mat4 mat = getObjectSkinnedTransform(); + + mat = modelview_matrix * mat; - passTextureIndex(); - vary_normal = normalize(normal_matrix * normal); + vec3 pos = (mat*vec4(position.xyz,1.0)).xyz; + +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) + vary_position = pos; +#endif + gl_Position = projection_matrix*vec4(pos,1.0); + +#else + //transform vertex + gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + +#endif + + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; + #ifdef HAS_NORMAL_MAP - //vary_texcoord1 = (texture_matrix0 * vec4(texcoord1,0,1)).xy; - vary_texcoord1 = texcoord1; -// vary_mat0 = vec3(t.x, b.x, n.x); -// vary_mat1 = vec3(t.y, b.y, n.y); -// vary_mat2 = vec3(t.z, b.z, n.z); + vary_texcoord1 = (texture_matrix0 * vec4(texcoord1,0,1)).xy; #endif #ifdef HAS_SPECULAR_MAP - //vary_texcoord2 = (texture_matrix0 * vec4(texcoord2,0,1)).xy; - vary_texcoord2 = texcoord2; + vary_texcoord2 = (texture_matrix0 * vec4(texcoord2,0,1)).xy; #endif - vertex_color = diffuse_color; +#ifdef HAS_SKIN + vec3 n = normalize((mat*vec4(normal.xyz+position.xyz,1.0)).xyz-pos.xyz); +#ifdef HAS_NORMAL_MAP + vec3 t = normalize((mat*vec4(tangent.xyz+position.xyz,1.0)).xyz-pos.xyz); + vec3 b = cross(n, t)*tangent.w; + + vary_mat0 = vec3(t.x, b.x, n.x); + vary_mat1 = vec3(t.y, b.y, n.y); + vary_mat2 = vec3(t.z, b.z, n.z); +#else //HAS_NORMAL_MAP +vary_normal = n; +#endif //HAS_NORMAL_MAP +#else //HAS_SKIN + vec3 n = normalize(normal_matrix * normal); +#ifdef HAS_NORMAL_MAP + vec3 t = normalize(normal_matrix * tangent.xyz); + vec3 b = cross(n,t)*tangent.w; + //vec3 t = cross(b,n) * binormal.w; + + vary_mat0 = vec3(t.x, b.x, n.x); + vary_mat1 = vec3(t.y, b.y, n.y); + vary_mat2 = vec3(t.z, b.z, n.z); +#else //HAS_NORMAL_MAP + vary_normal = n; +#endif //HAS_NORMAL_MAP +#endif //HAS_SKIN + + vertex_color = diffuse_color; + +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) +#if !defined(HAS_SKIN) + vary_position = (modelview_matrix*vec4(position.xyz, 1.0)).xyz; +#endif +#endif } |