summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class2/deferred
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2023-02-07 18:25:22 -0600
committerDave Parks <davep@lindenlab.com>2023-02-07 18:25:22 -0600
commita2647e953aeee26ef99e62e0146adcd37c8afca1 (patch)
treeafb8c28e3ca63eb0f3c5773e3230aa24fe9ff77d /indra/newview/app_settings/shaders/class2/deferred
parentbe9e4f186db1b3612a26e27a0294114ca66c539c (diff)
SL-18229 Fix for PBR materials on HUDs misbehaving. Incidental decruft.
Diffstat (limited to 'indra/newview/app_settings/shaders/class2/deferred')
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl58
1 files changed, 58 insertions, 0 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
index 35e22ef3a2..35ccc65a8e 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
@@ -25,6 +25,8 @@
/*[EXTRA_CODE_HERE]*/
+#ifndef IS_HUD
+
uniform sampler2D diffuseMap; //always in sRGB space
uniform sampler2D bumpMap;
uniform sampler2D emissiveMap;
@@ -249,3 +251,59 @@ void main()
a += f;
frag_color = vec4(color.rgb,a);
}
+
+#else
+
+uniform sampler2D diffuseMap; //always in sRGB space
+uniform sampler2D emissiveMap;
+
+uniform vec3 emissiveColor;
+
+out vec4 frag_color;
+
+in vec3 vary_position;
+
+in vec2 basecolor_texcoord;
+in vec2 emissive_texcoord;
+
+in vec4 vertex_color;
+
+#ifdef HAS_ALPHA_MASK
+uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff()
+#endif
+
+vec3 srgb_to_linear(vec3 c);
+vec3 linear_to_srgb(vec3 c);
+
+
+void main()
+{
+ vec3 color = vec3(0,0,0);
+
+ vec3 pos = vary_position;
+
+ vec4 basecolor = texture(diffuseMap, basecolor_texcoord.xy).rgba;
+ basecolor.rgb = srgb_to_linear(basecolor.rgb);
+#ifdef HAS_ALPHA_MASK
+ if (basecolor.a < minimum_alpha)
+ {
+ discard;
+ }
+#endif
+
+ color = vertex_color.rgb * basecolor.rgb;
+
+ // emissiveColor is the emissive color factor from GLTF and is already in linear space
+ vec3 colorEmissive = emissiveColor;
+ // emissiveMap here is a vanilla RGB texture encoded as sRGB, manually convert to linear
+ colorEmissive *= srgb_to_linear(texture2D(emissiveMap, emissive_texcoord.xy).rgb);
+
+
+ float a = basecolor.a*vertex_color.a;
+ a = 1.0;
+ color += colorEmissive;
+ color = linear_to_srgb(color);
+ frag_color = vec4(color.rgb,a);
+}
+
+#endif