summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/globalF.glsl')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/globalF.glsl16
1 files changed, 10 insertions, 6 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl b/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl
index 2aac333543..2ed4ba3163 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl
@@ -43,15 +43,19 @@ void mirrorClip(vec3 pos)
}
}
-vec4 encodeNormal(vec3 norm, float gbuffer_flag)
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag)
{
- return vec4(norm * 0.5 + 0.5, gbuffer_flag);
+ float f = sqrt(8 * n.z + 8);
+ return vec4(n.xy / f + 0.5, env, gbuffer_flag);
}
vec4 decodeNormal(vec4 norm)
{
- norm.xyz = norm.xyz * 2.0 - 1.0;
- return norm;
+ vec2 fenc = norm.xy*4-2;
+ float f = dot(fenc,fenc);
+ float g = sqrt(1-f/4);
+ vec4 n;
+ n.xy = fenc*g;
+ n.z = 1-f/2;
+ return n;
}
-
-