summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/environment/decodeNormF.glsl
diff options
context:
space:
mode:
authorGraham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com>2018-03-12 17:52:04 +0100
committerGraham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com>2018-03-12 17:52:04 +0100
commit98b2fed85fd459012ed2b859ea40a3f56d27c0e8 (patch)
tree74c478cf0c9526d382cbaae00c0bc6f13d5968b1 /indra/newview/app_settings/shaders/class1/environment/decodeNormF.glsl
parentcf460b13bee894684d0ca1bcb5bbc9eb38df719c (diff)
De-duplicate shader code for encoding and decoding normals to/from gbuffer format.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/environment/decodeNormF.glsl')
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/decodeNormF.glsl11
1 files changed, 11 insertions, 0 deletions
diff --git a/indra/newview/app_settings/shaders/class1/environment/decodeNormF.glsl b/indra/newview/app_settings/shaders/class1/environment/decodeNormF.glsl
new file mode 100644
index 0000000000..0abb1e43db
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/environment/decodeNormF.glsl
@@ -0,0 +1,11 @@
+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;
+}
+