diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl')
-rwxr-xr-x | indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl index 1470239a71..7fcbb1aa85 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl @@ -49,16 +49,42 @@ VARYING vec2 vary_fragcoord; uniform mat4 inv_proj; uniform vec2 screen_res; -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; -} +#ifdef SINGLE_FP_ONLY
+vec2 encode_normal(vec3 n)
+{
+ float f = sqrt(2 * n.z + 2);
+ return (n.xy / vec2(f)) + vec2(0.5f);
+}
+
+vec3 decode_normal (vec2 enc)
+{
+ vec2 fenc = enc - 0.5f;
+ float f = dot(fenc,fenc);
+ f = clamp(f,0.0f,1.0f);
+ float g = sqrt(1-f);
+ vec3 n;
+ n.xy = fenc*g;
+ n.z = 1.0f - (f * 0.5f);
+ return normalize(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 vec4 getPosition(vec2 pos_screen) { |