summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class2
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class2')
-rwxr-xr-xindra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl46
-rwxr-xr-xindra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl46
-rwxr-xr-xindra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl46
-rwxr-xr-xindra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl46
-rwxr-xr-xindra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl46
5 files changed, 180 insertions, 50 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index a6b0f7e7c1..f7023be150 100755
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -68,16 +68,42 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
-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 correctWithGamma(vec4 col)
{
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 31b2a32f7f..6e35641277 100755
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -78,16 +78,42 @@ vec3 vary_AtmosAttenuation;
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_d(vec2 pos_screen, float depth)
{
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index 91ff1f1e76..0436c80710 100755
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -68,16 +68,42 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
-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 correctWithGamma(vec4 col)
{
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index fa2f415e15..640701572d 100755
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -65,16 +65,42 @@ uniform float shadow_offset;
uniform float spot_shadow_bias;
uniform float spot_shadow_offset;
-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)
{
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
index 847fea6c08..6db26cec4c 100755
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
@@ -66,16 +66,42 @@ uniform float shadow_offset;
uniform float spot_shadow_bias;
uniform float spot_shadow_offset;
-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)
{