summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
diff options
context:
space:
mode:
authorGraham Madarasz <graham@lindenlab.com>2013-06-09 20:55:02 -0700
committerGraham Madarasz <graham@lindenlab.com>2013-06-09 20:55:02 -0700
commit33a2608da5a85b01acbfcced10128a2c42760928 (patch)
tree5df902a8125c730f4f970eefb1ceedc7a7c5f853 /indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
parent75c4b50f88ead9f9a40e4154a9cf75621b6a1002 (diff)
NORSPEC-246 fix issues with normal encoding on precision-deprived hardware and remove haxors
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl')
-rwxr-xr-xindra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl16
1 files changed, 6 insertions, 10 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index adfe012e4d..879953b476 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -68,20 +68,16 @@ uniform mat4 inv_proj;
#ifdef SINGLE_FP_ONLY
vec2 encode_normal(vec3 n)
{
- float f = sqrt(2 * n.z + 2);
- return (n.xy / vec2(f)) + vec2(0.5f);
+ vec2 sn;
+ sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,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);
+ 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)