summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1
diff options
context:
space:
mode:
authorGraham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com>2018-03-12 17:52:04 +0100
committerGraham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com>2018-03-12 17:52:04 +0100
commit98b2fed85fd459012ed2b859ea40a3f56d27c0e8 (patch)
tree74c478cf0c9526d382cbaae00c0bc6f13d5968b1 /indra/newview/app_settings/shaders/class1
parentcf460b13bee894684d0ca1bcb5bbc9eb38df719c (diff)
De-duplicate shader code for encoding and decoding normals to/from gbuffer format.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl19
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl17
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialF.glsl18
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl17
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl12
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl11
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl12
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl12
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl11
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/treeF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/waterF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/decodeNormF.glsl (renamed from indra/newview/app_settings/shaders/class1/environment/decodeNorm.glsl)0
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/encodeNormF.glsl (renamed from indra/newview/app_settings/shaders/class1/environment/encodeNorm.glsl)0
22 files changed, 22 insertions, 175 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 090aa3d27f..47dadb4ced 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -104,23 +104,8 @@ vec4 applyWaterFogView(vec3 pos, vec4 color);
vec3 srgb_to_linear(vec3 cs);
vec3 linear_to_srgb(vec3 cl);
-
-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;
-}
+vec3 encode_normal (vec2 enc);
+vec3 decode_normal (vec2 enc);
vec3 calcDirectionalLight(vec3 n, vec3 l)
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
index 86625a25ae..60d83cc623 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
@@ -38,11 +38,7 @@ uniform float minimum_alpha;
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;
-}
+vec2 encode_normal(vec3 n);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
index cbd8d2ebfc..b56abb66d1 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
@@ -61,22 +61,7 @@ vec4 getPosition(vec2 pos_screen)
return pos;
}
-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;
-}
+vec3 decode_normal (vec2 enc);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
index 0e95c267bc..b5677a07ee 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
@@ -42,11 +42,7 @@ VARYING vec3 vary_mat2;
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;
-}
+vec2 encode_normal(vec3 n);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
index e4fff3e21a..b328ee9483 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
@@ -39,11 +39,7 @@ 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;
-}
+vec2 encode_normal(vec3 n);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
index f3a0fba7cd..fc5c86b4d6 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
@@ -38,11 +38,7 @@ uniform float minimum_alpha;
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;
-}
+vec2 encode_normal(vec3 n);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
index e16ae4844d..1bb8eb8bd0 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
@@ -38,11 +38,7 @@ 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;
-}
+vec2 encode_normal(vec3 n);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
index d8b980c402..8319e61242 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
@@ -37,11 +37,7 @@ 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;
-}
+vec2 encode_normal(vec3 n);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
index 04ec35b308..828c325c9d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
@@ -35,12 +35,7 @@ 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;
-}
-
+vec2 encode_normal(vec3 n);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index e1b582c08c..d14805eccf 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -441,22 +441,8 @@ 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;
-}
-
-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;
-}
+vec2 encode_normal(vec3 n);
+vec3 decode_normal (vec2 enc);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index 9974f8f31b..d1ac19270d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -57,22 +57,7 @@ uniform float far_z;
uniform mat4 inv_proj;
-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;
-}
+vec3 decode_normal (vec2 enc);
vec4 getPosition(vec2 pos_screen)
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
index eeb2fe39cc..1d75322b4c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -72,17 +72,7 @@ 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;
-}
-
+vec3 decode_normal (vec2 enc);
vec3 srgb_to_linear(vec3 cs);
vec3 linear_to_srgb(vec3 cl);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
index 4f02365f45..13b803e03e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
@@ -56,16 +56,7 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
uniform vec4 viewport;
-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;
-}
+vec3 decode_normal (vec2 enc);
vec4 getPosition(vec2 pos_screen)
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 0703f75d60..5983d74cbc 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -87,17 +87,7 @@ vec4 applyWaterFogView(vec3 pos, vec4 color);
vec3 srgb_to_linear(vec3 cs);
vec3 linear_to_srgb(vec3 cl);
-
-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;
-}
+vec3 decode_normal (vec2 enc);
vec4 getPosition_d(vec2 pos_screen, float depth)
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index 88e79a8c46..2b6428963d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -70,17 +70,7 @@ 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;
-}
-
+vec3 decode_normal (vec2 enc);
vec3 srgb_to_linear(vec3 cs);
vec3 linear_to_srgb(vec3 cl);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
index 3a31173fab..403df87853 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
@@ -51,16 +51,7 @@ 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;
-}
+vec3 decode_normal (vec2 enc);
vec4 getPosition(vec2 pos_screen)
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
index 597fef486e..0cd90b0d97 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
@@ -41,11 +41,7 @@ VARYING vec3 vary_normal;
VARYING vec4 vary_texcoord0;
VARYING vec4 vary_texcoord1;
-vec2 encode_normal(vec3 n)
-{
- float f = sqrt(8 * n.z + 8);
- return n.xy / f + 0.5;
-}
+vec2 encode_normal(vec3 n);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
index 3cd791920d..89e354558a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
@@ -39,11 +39,7 @@ VARYING vec2 vary_texcoord0;
uniform float minimum_alpha;
-vec2 encode_normal(vec3 n)
-{
- float f = sqrt(8 * n.z + 8);
- return n.xy / f + 0.5;
-}
+vec2 encode_normal(vec3 n);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl
index 5e676b23f0..3a8565ee38 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl
@@ -61,11 +61,7 @@ VARYING vec4 view;
vec3 srgb_to_linear(vec3 cs);
vec3 linear_to_srgb(vec3 cl);
-vec2 encode_normal(vec3 n)
-{
- float f = sqrt(8 * n.z + 8);
- return n.xy / f + 0.5;
-}
+vec2 encode_normal(vec3 n);
vec4 applyWaterFog(vec4 color, vec3 viewVec)
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index 99c84c67e9..b321eb508b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -70,12 +70,7 @@ VARYING vec4 view;
VARYING vec4 vary_position;
vec3 srgb_to_linear(vec3 cs);
-
-vec2 encode_normal(vec3 n)
-{
- float f = sqrt(8 * n.z + 8);
- return n.xy / f + 0.5;
-}
+vec2 encode_normal(vec3 n);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class1/environment/decodeNorm.glsl b/indra/newview/app_settings/shaders/class1/environment/decodeNormF.glsl
index 0abb1e43db..0abb1e43db 100644
--- a/indra/newview/app_settings/shaders/class1/environment/decodeNorm.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/decodeNormF.glsl
diff --git a/indra/newview/app_settings/shaders/class1/environment/encodeNorm.glsl b/indra/newview/app_settings/shaders/class1/environment/encodeNormF.glsl
index ee21715c1d..ee21715c1d 100644
--- a/indra/newview/app_settings/shaders/class1/environment/encodeNorm.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/encodeNormF.glsl