diff options
author | Dave Parks <davep@lindenlab.com> | 2013-03-29 20:12:27 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2013-03-29 20:12:27 -0500 |
commit | 14f02e48b877569539c96ef5f261ac8b3943579f (patch) | |
tree | 382802d341977dc87f452804ba53062dc4f76c01 /indra/newview/app_settings/shaders/class1/deferred/materialV.glsl | |
parent | fc4869fb7871632b95dd293157b9965fb2edcb73 (diff) |
NORSPEC-66 Hook up material parameters to rigged attachments.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/materialV.glsl')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/materialV.glsl | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl index 744f79c0c9..6475d8d003 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl @@ -23,15 +23,24 @@ * $/LicenseInfo$ */ +#if HAS_SKIN +uniform mat4 modelview_matrix; +uniform mat4 projection_matrix; +mat4 getObjectSkinnedTransform(); +#else uniform mat3 normal_matrix; -uniform mat4 texture_matrix0; uniform mat4 modelview_projection_matrix; +#endif + +uniform mat4 texture_matrix0; + ATTRIBUTE vec3 position; ATTRIBUTE vec4 diffuse_color; ATTRIBUTE vec3 normal; ATTRIBUTE vec2 texcoord0; + #if HAS_NORMAL_MAP ATTRIBUTE vec3 binormal; ATTRIBUTE vec2 texcoord1; @@ -55,8 +64,21 @@ VARYING vec2 vary_texcoord0; void main() { +#if HAS_SKIN + mat4 mat = getObjectSkinnedTransform(); + + mat = modelview_matrix * mat; + + vec3 pos = (mat*vec4(position.xyz,1.0)).xyz; + + 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; #if HAS_NORMAL_MAP @@ -67,6 +89,19 @@ void main() vary_texcoord2 = (texture_matrix0 * vec4(texcoord2,0,1)).xy; #endif +#if HAS_SKIN + vec3 n = normalize((mat*vec4(normal.xyz+position.xyz,1.0)).xyz-pos.xyz); +#if HAS_NORMAL_MAP + vec3 b = normalize((mat*vec4(binormal.xyz+position.xyz,1.0)).xyz-pos.xyz); + vec3 t = cross(b, n); + + 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); #if HAS_NORMAL_MAP vec3 b = normalize(normal_matrix * binormal); @@ -75,9 +110,10 @@ void main() 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 +#else //HAS_NORMAL_MAP vary_normal = n; -#endif +#endif //HAS_NORMAL_MAP +#endif //HAS_SKIN vertex_color = diffuse_color; } |