summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl')
-rwxr-xr-xindra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl37
1 files changed, 36 insertions, 1 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
index f400eb7a5b..eebeb91bf8 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
@@ -64,11 +64,46 @@ vec4 getPosition(vec2 pos_screen)
return pos;
}
+#ifdef SINGLE_FP_ONLY
+vec2 encode_normal(vec3 n)
+{
+ vec2 sn;
+ sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f);
+ return sn;
+}
+
+vec3 decode_normal (vec2 enc)
+{
+ vec3 n;
+ n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f);
+ n.z = sqrt(1.0f - dot(n.xy,n.xy));
+ return n;
+}
+#else
+vec2 encode_normal(vec3 n)
+{
+ float f = sqrt(8 * n.z + 8);
+ return n.xy / f + 0.5;
+}
+
+vec3 decode_normal (vec2 enc)
+{
+ vec2 fenc = enc*4-2;
+ float f = dot(fenc,fenc);
+ float g = sqrt(1-f/4);
+ vec3 n;
+ n.xy = fenc*g;
+ n.z = 1-f/2;
+ return n;
+}
+#endif
+
void main()
{
vec2 tc = vary_fragcoord.xy;
vec3 norm = texture2DRect(normalMap, tc).xyz;
- norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
+ norm = decode_normal(norm.xy); // unpack norm
+
vec3 pos = getPosition(tc).xyz;
vec4 ccol = texture2DRect(lightMap, tc).rgba;