summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class1')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/globalF.glsl12
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/treeF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl4
15 files changed, 47 insertions, 15 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
index b904df3a1b..32b768cc63 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
@@ -36,6 +36,7 @@ in vec2 vary_texcoord0;
in vec3 vary_position;
void mirrorClip(vec3 pos);
+vec4 encodeNormal(vec3 norm, float gbuffer_flag);
void main()
{
@@ -51,7 +52,7 @@ 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, GBUFFER_FLAG_HAS_ATMOS);
+ frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
frag_data[3] = vec4(0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
index 2cc3085cd0..79c1b392e9 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
@@ -40,6 +40,8 @@ in vec2 vary_texcoord0;
in vec3 vary_position;
void mirrorClip(vec3 pos);
+vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+
void main()
{
mirrorClip(vary_position);
@@ -62,6 +64,6 @@ void main()
frag_data[1] = vertex_color.aaaa; // spec
//frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
vec3 nvn = normalize(tnorm);
- frag_data[2] = vec4(nvn, GBUFFER_FLAG_HAS_ATMOS);
+ frag_data[2] = encodeNormal(nvn, GBUFFER_FLAG_HAS_ATMOS);
frag_data[3] = vec4(vertex_color.a, 0, 0, 0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
index 8588a93648..0e8d8d010b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
@@ -75,6 +75,9 @@ const float ONE_OVER_PI = 0.3183098861;
vec3 srgb_to_linear(vec3 cs);
vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten);
+vec4 decodeNormal(vec4 norm);
+
+
float calcLegacyDistanceAttenuation(float distance, float falloff)
{
float dist_atten = 1.0 - clamp((distance + falloff)/(1.0 + falloff), 0.0, 1.0);
@@ -145,8 +148,7 @@ vec2 getScreenCoordinate(vec2 screenpos)
vec4 getNorm(vec2 screenpos)
{
- vec4 norm = texture(normalMap, screenpos.xy);
- norm.xyz = normalize(norm.xyz);
+ vec4 norm = decodeNormal(texture(normalMap, screenpos.xy));
return norm;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
index 1751e17814..fadf06d592 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
@@ -39,6 +39,8 @@ in vec2 vary_texcoord0;
void mirrorClip(vec3 pos);
+vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+
void main()
{
mirrorClip(vary_position);
@@ -53,7 +55,7 @@ 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, GBUFFER_FLAG_HAS_ATMOS);
+ frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
frag_data[3] = vec4(0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
index f5b517a8ea..10d06da416 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
@@ -36,6 +36,7 @@ in vec4 vertex_color;
in vec2 vary_texcoord0;
void mirrorClip(vec3 pos);
+vec4 encodeNormal(vec3 norm, float gbuffer_flag);
void main()
{
@@ -51,6 +52,6 @@ void main()
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0);
vec3 nvn = normalize(vary_normal);
- frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
+ frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
frag_data[3] = vec4(0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
index 89ea0c1710..f7c8fc9596 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
@@ -33,6 +33,7 @@ uniform sampler2D diffuseMap;
in vec3 vary_normal;
in vec2 vary_texcoord0;
+vec4 encodeNormal(vec3 norm, float gbuffer_flag);
void main()
{
@@ -46,7 +47,7 @@ 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, GBUFFER_FLAG_HAS_ATMOS);
+ frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
frag_data[3] = vec4(0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
index 7f056a51e8..d83f5a3145 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
@@ -35,6 +35,7 @@ in vec2 vary_texcoord0;
in vec3 vary_position;
void mirrorClip(vec3 pos);
+vec4 encodeNormal(vec3 norm, float gbuffer_flag);
void main()
{
@@ -42,9 +43,8 @@ void main()
vec3 col = vertex_color.rgb * texture(diffuseMap, vary_texcoord0.xy).rgb;
frag_data[0] = vec4(col, 0.0);
frag_data[1] = vertex_color.aaaa; // spec
- //frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
vec3 nvn = normalize(vary_normal);
- frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
+ frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
frag_data[3] = vec4(vertex_color.a, 0, 0, 0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
index 5c73878ba9..6d8943e7ae 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
@@ -33,6 +33,8 @@ in vec2 vary_texcoord0;
in vec3 vary_position;
void mirrorClip(vec3 pos);
+vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+
vec3 linear_to_srgb(vec3 c);
void main()
@@ -46,6 +48,6 @@ void main()
frag_data[0] = vec4(col, 0.0);
frag_data[1] = vec4(spec, vertex_color.a); // spec
vec3 nvn = normalize(vary_normal);
- frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
+ frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
frag_data[3] = vec4(vertex_color.a, 0, 0, 0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl b/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl
index d493976eba..16120508d5 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl
@@ -43,3 +43,15 @@ void mirrorClip(vec3 pos)
}
}
+vec4 encodeNormal(vec3 norm, float gbuffer_flag)
+{
+ return vec4(norm * 0.5 + 0.5, gbuffer_flag);
+}
+
+vec4 decodeNormal(vec4 norm)
+{
+ norm.xyz = norm.xyz * 2.0 - 1.0;
+ return norm;
+}
+
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
index 99cb23839a..a6bca68cb0 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
@@ -38,6 +38,8 @@ in vec2 vary_texcoord0;
vec3 linear_to_srgb(vec3 c);
+vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+
void main()
{
vec4 col = texture(diffuseMap, vary_texcoord0.xy);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl
index b521081af9..c0d4c387af 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl
@@ -61,6 +61,7 @@ uniform vec4 clipPlane;
uniform float clipSign;
void mirrorClip(vec3 pos);
+vec4 encodeNormal(vec3 norm, float gbuffer_flag);
uniform mat3 normal_matrix;
@@ -113,7 +114,7 @@ void main()
// See: C++: addDeferredAttachments(), GLSL: softenLightF
frag_data[0] = max(vec4(col, 0.0), vec4(0)); // Diffuse
frag_data[1] = max(vec4(spec.rgb,0.0), vec4(0)); // PBR linear packed Occlusion, Roughness, Metal.
- frag_data[2] = vec4(tnorm, GBUFFER_FLAG_HAS_PBR); // normal, environment intensity, flags
+ frag_data[2] = encodeNormal(tnorm, GBUFFER_FLAG_HAS_PBR); // normal, environment intensity, flags
frag_data[3] = max(vec4(emissive,0), vec4(0)); // PBR sRGB Emissive
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl
index 410c447c64..b434479511 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl
@@ -162,6 +162,7 @@ in vec4[2] vary_coords;
#endif
void mirrorClip(vec3 position);
+vec4 encodeNormal(vec3 norm, float gbuffer_flag);
float terrain_mix(TerrainMix tm, vec4 tms4);
@@ -429,7 +430,7 @@ void main()
#endif
frag_data[0] = max(vec4(pbr_mix.col.xyz, 0.0), vec4(0)); // Diffuse
frag_data[1] = max(vec4(mix_orm.rgb, base_color_factor_alpha), vec4(0)); // PBR linear packed Occlusion, Roughness, Metal.
- frag_data[2] = vec4(tnorm, GBUFFER_FLAG_HAS_PBR); // normal, flags
+ frag_data[2] = encodeNormal(tnorm, GBUFFER_FLAG_HAS_PBR); // normal, flags
frag_data[3] = max(vec4(mix_emissive,0), vec4(0)); // PBR sRGB Emissive
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
index 1fd31e0546..5ff84b5937 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
@@ -39,6 +39,7 @@ in vec4 vary_texcoord0;
in vec4 vary_texcoord1;
void mirrorClip(vec3 position);
+vec4 encodeNormal(vec3 norm, float gbuffer_flag);
void main()
{
@@ -60,7 +61,7 @@ void main()
frag_data[0] = max(outColor, vec4(0));
frag_data[1] = vec4(0.0,0.0,0.0,-1.0);
vec3 nvn = normalize(vary_normal);
- frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
+ frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
frag_data[3] = vec4(0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
index 05922ecb1a..0894eff660 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
@@ -37,6 +37,8 @@ in vec3 vary_position;
uniform float minimum_alpha;
void mirrorClip(vec3 pos);
+vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+
void main()
{
mirrorClip(vary_position);
@@ -49,6 +51,6 @@ void main()
frag_data[0] = vec4(vertex_color.rgb*col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0);
vec3 nvn = normalize(vary_normal);
- frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
+ frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
frag_data[3] = vec4(0);
}
diff --git a/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl b/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl
index ac4ff50552..1d8a92bac7 100644
--- a/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl
+++ b/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl
@@ -64,6 +64,8 @@ in vec2 base_color_uv;
in vec2 emissive_uv;
void mirrorClip(vec3 pos);
+vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+
vec3 linear_to_srgb(vec3 c);
vec3 srgb_to_linear(vec3 c);
// ==================================
@@ -241,7 +243,7 @@ void main()
#else
frag_data[0] = max(vec4(basecolor.rgb, 0.0), vec4(0));
frag_data[1] = max(vec4(orm.rgb,0.0), vec4(0));
- frag_data[2] = vec4(norm, GBUFFER_FLAG_HAS_PBR);
+ frag_data[2] = encodeNormal(norm, GBUFFER_FLAG_HAS_PBR);
frag_data[3] = max(vec4(emissive,0), vec4(0));
#endif
#endif