summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
diff options
context:
space:
mode:
authorJonathan "Geenz" Goodman <geenz@lindenlab.com>2024-11-25 20:56:03 -0500
committerGitHub <noreply@github.com>2024-11-25 20:56:03 -0500
commitd65fb7cec8ce36ce7f6ff082f8d04bdd8bc0208c (patch)
tree0005e8ec095fb31dcd4f8b079af585e3333c365f /indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
parent7ef6e8fce763eb529ed160ea4ff11e6125e32ed5 (diff)
Drop emissive on old Intel GPUs (#3110)
* #3103 Add the ability to disable the emissive buffer for older GPUs with low memory bandwidth. * #3135 Add a "vintage" mode for slower GPUs * #2719 Fix for skies being overbrightened * #2632 Do not apply tonemapping on legacy skies
Diffstat (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl')
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl81
1 files changed, 46 insertions, 35 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index a9b299cfd7..52799dbba1 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -23,16 +23,12 @@
* $/LicenseInfo$
*/
+/*[EXTRA_CODE_HERE]*/
+
#define FLT_MAX 3.402823466e+38
out vec4 frag_color;
-vec4 decodeNormal(vec4 norm);
-
-uniform sampler2D diffuseRect;
-uniform sampler2D specularRect;
-uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
-
const float M_PI = 3.14159265;
#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO)
@@ -56,6 +52,8 @@ uniform mat3 ssao_effect_mat;
uniform vec3 sun_dir;
uniform vec3 moon_dir;
uniform int sun_up_factor;
+uniform int classic_mode;
+
in vec2 vary_fragcoord;
uniform mat4 inv_proj;
@@ -105,13 +103,7 @@ vec3 pbrBaseLight(vec3 diffuseColor,
vec3 additive,
vec3 atten);
-vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
- float perceptualRoughness,
- float metallic,
- vec3 n, // normal
- vec3 v, // surface point to camera
- vec3 l); //surface point to light
-
+GBufferInfo getGBuffer(vec2 screenpos);
void adjustIrradiance(inout vec3 irradiance, float ambocc)
{
@@ -128,13 +120,15 @@ void main()
vec2 tc = vary_fragcoord.xy;
float depth = getDepth(tc.xy);
vec4 pos = getPositionWithDepth(tc, depth);
- vec4 norm = getNorm(tc);
- vec3 colorEmissive = texture(emissiveRect, tc).rgb;
- float envIntensity = colorEmissive.r;
+
+ GBufferInfo gb = getGBuffer(tc);
+
+ vec3 colorEmissive = gb.emissive.rgb;
+ float envIntensity = gb.envIntensity;
vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
- vec4 baseColor = texture(diffuseRect, tc);
- vec4 spec = texture(specularRect, tc); // NOTE: PBR linear Emissive
+ vec4 baseColor = gb.albedo;
+ vec4 spec = gb.specular; // NOTE: PBR linear Emissive
#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO)
vec2 scol_ambocc = texture(lightMap, vary_fragcoord.xy).rg;
@@ -159,26 +153,26 @@ void main()
vec3 additive;
vec3 atten;
- calcAtmosphericVarsLinear(pos.xyz, norm.xyz, light_dir, sunlit, amblit, additive, atten);
+ calcAtmosphericVarsLinear(pos.xyz, gb.normal, light_dir, sunlit, amblit, additive, atten);
- vec3 sunlit_linear = srgb_to_linear(sunlit);
+ vec3 sunlit_linear = sunlit;
vec3 amblit_linear = amblit;
- vec3 irradiance = vec3(0);
vec3 radiance = vec3(0);
- if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
+ if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_HAS_PBR))
{
vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
float ao = orm.r;
+ vec3 irradiance = amblit_linear;
// PBR IBL
float gloss = 1.0 - perceptualRoughness;
- sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, norm.xyz, gloss, false, amblit_linear);
+ sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, gb.normal, gloss, false, amblit_linear);
adjustIrradiance(irradiance, ambocc);
@@ -187,17 +181,21 @@ void main()
calcDiffuseSpecular(baseColor.rgb, metallic, diffuseColor, specularColor);
vec3 v = -normalize(pos.xyz);
- color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten);
+ color = pbrBaseLight(diffuseColor, specularColor, metallic, v, gb.normal, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten);
}
- else if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_HDRI))
+ else if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_HAS_HDRI))
{
// actual HDRI sky, just copy color value
color = colorEmissive.rgb;
}
- else if (GET_GBUFFER_FLAG(GBUFFER_FLAG_SKIP_ATMOS))
+ else if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_SKIP_ATMOS))
{
//should only be true of WL sky, port over base color value and scale for fake HDR
+#if defined(HAS_EMISSIVE)
color = colorEmissive.rgb;
+#else
+ color = baseColor.rgb;
+#endif
color = srgb_to_linear(color);
color *= sky_hdr_scale;
}
@@ -208,31 +206,43 @@ void main()
spec.rgb = srgb_to_linear(spec.rgb);
- float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0);
+ float da = clamp(dot(gb.normal, light_dir.xyz), 0.0, 1.0);
- vec3 irradiance = vec3(0);
+ vec3 irradiance = amblit;
vec3 glossenv = vec3(0);
vec3 legacyenv = vec3(0);
- sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, norm.xyz, spec.a, envIntensity, false, amblit_linear);
+ sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, gb.normal, spec.a, envIntensity, false, amblit_linear);
adjustIrradiance(irradiance, ambocc);
// apply lambertian IBL only (see pbrIbl)
color.rgb = irradiance;
- vec3 sun_contrib = min(da, scol) * sunlit_linear;
- color.rgb += sun_contrib;
+ if (classic_mode > 0)
+ {
+ da = pow(da,1.2);
+ vec3 sun_contrib = vec3(min(da, scol));
+
+ color.rgb = srgb_to_linear(color.rgb * 0.9 + linear_to_srgb(sun_contrib) * sunlit_linear * 0.7);
+ sunlit_linear = srgb_to_linear(sunlit_linear);
+ }
+ else
+ {
+ vec3 sun_contrib = min(da, scol) * sunlit_linear;
+ color.rgb += sun_contrib;
+ }
+
color.rgb *= baseColor.rgb;
- vec3 refnormpersp = reflect(pos.xyz, norm.xyz);
+ vec3 refnormpersp = reflect(pos.xyz, gb.normal);
if (spec.a > 0.0)
{
vec3 lv = light_dir.xyz;
vec3 h, l, v = -normalize(pos.xyz);
float nh, nl, nv, vh, lightDist;
- vec3 n = norm.xyz;
+ vec3 n = gb.normal;
calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist);
if (nl > 0.0 && nh > 0.0)
@@ -249,7 +259,7 @@ void main()
}
// add radiance map
- applyGlossEnv(color, glossenv, spec, pos.xyz, norm.xyz);
+ applyGlossEnv(color, glossenv, spec, pos.xyz, gb.normal);
}
@@ -257,10 +267,11 @@ void main()
if (envIntensity > 0.0)
{ // add environment map
- applyLegacyEnv(color, legacyenv, spec, pos.xyz, norm.xyz, envIntensity);
+ applyLegacyEnv(color, legacyenv, spec, pos.xyz, gb.normal, envIntensity);
}
}
+ //color.r = classic_mode > 0 ? 1.0 : 0.0;
frag_color.rgb = max(color.rgb, vec3(0)); //output linear since local lights will be added to this shader's results
frag_color.a = 0.0;
}