summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl')
-rwxr-xr-x[-rw-r--r--]indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl8
1 files changed, 7 insertions, 1 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
index c1fa9e4aac..7930b5d18b 100644..100755
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
@@ -37,6 +37,12 @@ VARYING vec3 vary_normal;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
+vec2 encode_normal(vec3 n)
+{
+ float f = sqrt(8 * n.z + 8);
+ return n.xy / f + 0.5;
+}
+
void main()
{
vec4 col = texture2D(diffuseMap, vary_texcoord0.xy) * vertex_color;
@@ -49,6 +55,6 @@ void main()
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0); // spec
vec3 nvn = normalize(vary_normal);
- frag_data[2] = vec4(nvn.xyz * 0.5 + 0.5, 0.0);
+ frag_data[2] = vec4(encode_normal(nvn.xyz), 0.0, 0.0);
}