diff options
author | Geenz <geenz@geenzo.com> | 2013-04-15 19:40:12 -0400 |
---|---|---|
committer | Geenz <geenz@geenzo.com> | 2013-04-15 19:40:12 -0400 |
commit | c72c3691ecf83875d4ee3e0784b3e76cb4b4633a (patch) | |
tree | 7959f729f94b8fcd85bb3b32a7b5bb271c746b47 /indra/newview/app_settings/shaders/class1 | |
parent | 39544a3b06e3221602444eb81c7df8c1030c6bb5 (diff) | |
parent | fafa21315f043ab51e3373e825c85646685778a6 (diff) |
Merged Graham's stuff amongst others.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1')
3 files changed, 52 insertions, 22 deletions
diff --git a/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl b/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl index 43ed41a205..ff30560adc 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl @@ -26,22 +26,28 @@ ATTRIBUTE vec4 weight4; -uniform mat4 matrixPalette[32]; +uniform mat4 matrixPalette[64]; mat4 getObjectSkinnedTransform() { - int i; - vec4 w = fract(weight4); - vec4 index = floor(weight4); - - float scale = 1.0/(w.x+w.y+w.z+w.w); - w *= scale; + float w0 = fract(weight4.x); + float w1 = fract(weight4.y); + float w2 = fract(weight4.z); + float w3 = fract(weight4.w); + + int i0 = int(floor(weight4.x)); + int i1 = int(floor(weight4.y)); + int i2 = int(floor(weight4.z)); + int i3 = int(floor(weight4.w)); + + //float scale = 1.0/(w.x+w.y+w.z+w.w); + //w *= scale; - mat4 mat = matrixPalette[int(index.x)]*w.x; - mat += matrixPalette[int(index.y)]*w.y; - mat += matrixPalette[int(index.z)]*w.z; - mat += matrixPalette[int(index.w)]*w.w; + mat4 mat = matrixPalette[i0]*w0; + mat += matrixPalette[i1]*w1; + mat += matrixPalette[i2]*w2; + mat += matrixPalette[i3]*w3; return mat; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index eb0c546af7..00717cd6a9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -81,12 +81,10 @@ uniform vec4 specular_color; uniform float shadow_offset; -vec2 calcDirectionalLight(vec3 n, vec3 l) +vec3 calcDirectionalLight(vec3 n, vec3 l) { - vec3 refl = normalize(reflect(vary_position.xyz, n.xyz)); float a = pow(max(dot(n,l),0.0), 0.7); - refl.x = pow(pow(max(dot(refl, l), 0.0), specular_color.w * 128), 0.6); - return vec2(a, refl.x); + return vec3(a,a,a); } float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) @@ -144,8 +142,9 @@ void main() dot(normal.xyz, vary_rotation[1]), dot(normal.xyz, vary_rotation[2])); - vec2 slight = calcDirectionalLight(normal, light_position[0].xyz); - vec3 dlight = slight.x * vary_directional.rgb * vary_pointlight_col; + vec3 l = light_position[0].xyz; + vec3 dlight = calcDirectionalLight(normal, l); + dlight = dlight * vary_directional.rgb * vary_pointlight_col; vec4 col = vec4(vary_ambient + dlight, vertex_color_alpha); vec4 color = diff * col; @@ -155,13 +154,24 @@ void main() color.rgb = scaleSoftClip(color.rgb); vec3 light_col = vec3(0,0,0); +#ifdef MAC_GEFORCE_HACK + #define LIGHT_LOOP(i) \ + light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + + LIGHT_LOOP(1) + LIGHT_LOOP(2) + LIGHT_LOOP(3) + LIGHT_LOOP(4) + LIGHT_LOOP(5) + LIGHT_LOOP(6) + LIGHT_LOOP(7) +#else for (int i = 2; i < 8; i++) { light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); } +#endif - vec3 n = normalize(reflect(vary_position.xyz, normal.xyz)); - n = vec3(dot(n, light_position[0].xyz)); color.rgb += diff.rgb * vary_pointlight_col * light_col; frag_color = color; diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl index 10e9670894..e872dadcc1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl @@ -114,7 +114,10 @@ void main() vec4 diff= texture2D(diffuseMap,vary_texcoord0.xy); - vec3 dlight = calcDirectionalLight(vary_norm, light_position[0].xyz) * vary_directional.rgb * vary_pointlight_col; + vec3 n = vary_norm; + vec3 l = light_position[0].xyz; + vec3 dlight = calcDirectionalLight(n, l); + dlight = dlight * vary_directional.rgb * vary_pointlight_col; vec4 col = vec4(vary_ambient + dlight, vertex_color.a); vec4 color = diff * col; @@ -123,12 +126,23 @@ void main() color.rgb = scaleSoftClip(color.rgb); vec3 light_col = vec3(0,0,0); - +#if MAC_GEFORCE_HACK + #define LIGHT_LOOP(i) \ + light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + + LIGHT_LOOP(1) + LIGHT_LOOP(2) + LIGHT_LOOP(3) + LIGHT_LOOP(4) + LIGHT_LOOP(5) + LIGHT_LOOP(6) + LIGHT_LOOP(7) +#else for (int i = 2; i < 8; i++) { light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); } - +#endif color.rgb += diff.rgb * vary_pointlight_col * light_col; frag_color = color; |