diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl')
-rwxr-xr-x | indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl index bfd9b9b3eb..bcccbf77d2 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl @@ -34,6 +34,12 @@ uniform sampler2D diffuseMap; VARYING vec3 vary_normal; 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 diff = texture2D(diffuseMap, vary_texcoord0.xy); @@ -46,6 +52,6 @@ void main() frag_data[0] = vec4(diff.rgb, 0.0); frag_data[1] = vec4(0,0,0,0); 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); } |