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, 16 insertions, 0 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl b/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl
index d493976eba..9060d358cf 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl
@@ -43,3 +43,19 @@ void mirrorClip(vec3 pos)
}
}
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag)
+{
+ float f = sqrt(8 * n.z + 8);
+ return vec4(n.xy / f + 0.5, env, gbuffer_flag);
+}
+
+vec4 decodeNormal(vec4 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;
+}