diff options
author | Tofu Linden <tofu.linden@lindenlab.com> | 2010-03-07 11:34:31 +0000 |
---|---|---|
committer | Tofu Linden <tofu.linden@lindenlab.com> | 2010-03-07 11:34:31 +0000 |
commit | 550922aa84634594c277bd51d2839256f5963ac7 (patch) | |
tree | 6ed0726391a9b5684f135eceae1ee21c9ac8294e | |
parent | 23f03d9f6cc64d960d8eb05c8fb2cb10f6a4ec6b (diff) |
Add a touch of fakey ripple to shadows on the surface of water, as if the water has depth. Using 4th component of the normal map to encode a position displacement (along the normal) in the class2 shadow lookup.
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/waterF.glsl | 4 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index 55c893d73b..ceb7e0fb56 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -133,9 +133,9 @@ void main() //wavef.z *= 0.1f; //wavef = normalize(wavef); - wavef = (norm_mat*vec4(wavef, 1.0)).xyz; + vec3 screenspacewavef = (norm_mat*vec4(wavef, 1.0)).xyz; gl_FragData[0] = vec4(color.rgb, 0.5); // diffuse gl_FragData[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec - gl_FragData[2] = vec4(wavef*0.5+0.5, 0.0); // normal + gl_FragData[2] = vec4(screenspacewavef*0.5+0.5, screenspacewavef.z*0.5); // normal, displace } diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl index 74a948f584..50502dbdad 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl @@ -159,7 +159,9 @@ void main() vec4 pos = getPosition(pos_screen); - vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0; + vec4 nmap4 = texture2DRect(normalMap, pos_screen); + float displace = nmap4.w; + vec3 norm = nmap4.xyz*2.0-1.0; /*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL { @@ -168,9 +170,9 @@ void main() }*/ float shadow = 1.0; - float dp_directional_light = max(0.0, dot(norm, vary_light.xyz)); + float dp_directional_light = max(0.0, dot(norm, vary_light.xyz)); - vec4 spos = vec4(pos.xyz + vary_light.xyz * (1.0-dp_directional_light)*shadow_offset, 1.0); + vec4 spos = vec4(pos.xyz + displace*norm + vary_light.xyz * (1.0-dp_directional_light)*shadow_offset, 1.0); if (spos.z > -shadow_clip.w) { |