diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class1')
6 files changed, 26 insertions, 87 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index c8eaba6418..f9ebf33b4a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -382,8 +382,7 @@ vec3 pbrIbl(vec3 diffuseColor, vec3 irradiance, // irradiance map sample float ao, // ambient occlusion factor float nv, // normal dot view vector - float perceptualRough, - out vec3 specContrib) + float perceptualRough) { // retrieve a scale and bias to F0. See [1], Figure 3 vec2 brdf = BRDF(clamp(nv, 0, 1), 1.0-perceptualRough); @@ -393,23 +392,9 @@ vec3 pbrIbl(vec3 diffuseColor, vec3 diffuse = diffuseLight * diffuseColor; vec3 specular = specularLight * (specularColor * brdf.x + brdf.y); - specContrib = specular * ao; - return (diffuse + specular) * ao; } -vec3 pbrIbl(vec3 diffuseColor, - vec3 specularColor, - vec3 radiance, // radiance map sample - vec3 irradiance, // irradiance map sample - float ao, // ambient occlusion factor - float nv, // normal dot view vector - float perceptualRough) -{ - vec3 specContrib; - return pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, nv, perceptualRough, specContrib); -} - // Encapsulate the various inputs used by the various functions in the shading equation // We store values in this struct to simplify the integration of alternative implementations @@ -475,8 +460,7 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, float metallic, vec3 n, // normal vec3 v, // surface point to camera - vec3 l, //surface point to light - out vec3 specContrib) //specular contribution (exposed to alpha shaders to calculate "glare") + vec3 l) //surface point to light { // make sure specular highlights from punctual lights don't fall off of polished surfaces perceptualRoughness = max(perceptualRoughness, 8.0/255.0); @@ -524,28 +508,13 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, // Calculation of analytical lighting contribution vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs); - specContrib = F * G * D / (4.0 * NdotL * NdotV); + vec3 specContrib = F * G * D / (4.0 * NdotL * NdotV); // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law) vec3 color = NdotL * (diffuseContrib + specContrib); - specContrib *= NdotL; - specContrib = max(specContrib, vec3(0)); - return clamp(color, vec3(0), vec3(10)); } -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 -{ - vec3 specContrib; - - return pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n, v, l, specContrib); -} - void calcDiffuseSpecular(vec3 baseColor, float metallic, inout vec3 diffuseColor, inout vec3 specularColor) { vec3 f0 = vec3(0.04); @@ -554,30 +523,21 @@ void calcDiffuseSpecular(vec3 baseColor, float metallic, inout vec3 diffuseColor specularColor = mix(f0, baseColor, metallic); } -vec3 pbrBaseLight(vec3 diffuseColor, vec3 specularColor, float metallic, vec3 v, vec3 norm, float perceptualRoughness, vec3 light_dir, vec3 sunlit, float scol, vec3 radiance, vec3 irradiance, vec3 colorEmissive, float ao, vec3 additive, vec3 atten, out vec3 specContrib) +vec3 pbrBaseLight(vec3 diffuseColor, vec3 specularColor, float metallic, vec3 v, vec3 norm, float perceptualRoughness, vec3 light_dir, vec3 sunlit, float scol, vec3 radiance, vec3 irradiance, vec3 colorEmissive, float ao, vec3 additive, vec3 atten) { vec3 color = vec3(0); float NdotV = clamp(abs(dot(norm, v)), 0.001, 1.0); - vec3 ibl_spec; - color += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness, ibl_spec); + color += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness); - color += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm, v, normalize(light_dir), specContrib) * sunlit * 3.0 * scol; //magic number to balance with legacy materials - specContrib *= sunlit * 2.75 * scol; - specContrib += ibl_spec; + color += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm, v, normalize(light_dir)) * sunlit * 3.0 * scol; //magic number to balance with legacy materials color += colorEmissive; return color; } -vec3 pbrBaseLight(vec3 diffuseColor, vec3 specularColor, float metallic, vec3 v, vec3 norm, float perceptualRoughness, vec3 light_dir, vec3 sunlit, float scol, vec3 radiance, vec3 irradiance, vec3 colorEmissive, float ao, vec3 additive, vec3 atten) -{ - vec3 specContrib; - return pbrBaseLight(diffuseColor, specularColor, metallic, v, norm, perceptualRoughness, light_dir, sunlit, scol, radiance, irradiance, colorEmissive, ao, additive, atten, specContrib); -} - uniform vec4 waterPlane; uniform float waterSign; diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index b752307d13..5d58cc91cd 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -40,8 +40,6 @@ vec4 applyWaterFogView(vec3 pos, vec4 color); #endif vec3 srgb_to_linear(vec3 cs); -vec3 legacy_adjust_fullbright(vec3 c); -vec3 legacy_adjust(vec3 c); vec3 linear_to_srgb(vec3 cl); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); @@ -98,9 +96,7 @@ void main() #endif #ifndef IS_HUD - color.rgb = legacy_adjust(color.rgb); color.rgb = srgb_to_linear(color.rgb); - color.rgb = legacy_adjust_fullbright(color.rgb); color.rgb = atmosFragLighting(color.rgb, additive, atten); #endif diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 53e4f02314..64e6bc9da2 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -105,7 +105,8 @@ vec3 toneMap(vec3 color) color *= exposure * exp_scale; - color = toneMapACES_Hill(color); + // mix ACES and Linear here as a compromise to avoid over-darkening legacy content + color = mix(toneMapACES_Hill(color), color, 0.333); #endif return color; diff --git a/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl b/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl index 7a5e14566b..b5437d43d2 100644 --- a/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl +++ b/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl @@ -28,6 +28,10 @@ out vec4 frag_color; uniform sampler2D diffuseMap; +#if HAS_NOISE +uniform sampler2D glowNoiseMap; +uniform vec2 screen_res; +#endif uniform float minLuminance; uniform float maxExtractAlpha; uniform vec3 lumWeights; @@ -44,7 +48,16 @@ void main() float lum = smoothstep(minLuminance, minLuminance+1.0, dot(col.rgb, lumWeights ) ); float warmth = smoothstep(minLuminance, minLuminance+1.0, max(col.r * warmthWeights.r, max(col.g * warmthWeights.g, col.b * warmthWeights.b)) ); - frag_color.rgb = col.rgb; +#if HAS_NOISE + float TRUE_NOISE_RES = 128; // See mTrueNoiseMap + // *NOTE: Usually this is vary_fragcoord not vary_texcoord0, but glow extraction is in screen space + vec3 glow_noise = texture(glowNoiseMap, vary_texcoord0.xy * (screen_res / TRUE_NOISE_RES)).xyz; + // Dithering. Reduces banding effects in the reduced precision glow buffer. + float NOISE_DEPTH = 64.0; + col.rgb += glow_noise / NOISE_DEPTH; + col.rgb = max(col.rgb, vec3(0)); +#endif + frag_color.rgb = col.rgb; frag_color.a = max(col.a, mix(lum, warmth, warmthAmount) * maxExtractAlpha); } diff --git a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl index 31b02377da..e3fd10447e 100644 --- a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl @@ -113,31 +113,3 @@ vec3 inv_toneMapACES_Hill(vec3 color) return color; } -// adjust legacy colors to back out tonemapping and exposure -// NOTE: obsolete now that setting probe ambiance to zero removes tonemapping and exposure, but keeping for a minute -// while that change goes through testing - davep 6/1/2023 -#define LEGACY_ADJUST 0 - -vec3 legacy_adjust(vec3 c) -{ -#if LEGACY_ADJUST - vec3 desat = rgb2hsv(c.rgb); - desat.g *= 1.0-(1.0-desat.b)*0.5; - desat.b += (1.0-desat.b)*0.1f; - desat.rgb = hsv2rgb(desat); - return desat; -#else - return c; -#endif -} - -vec3 legacy_adjust_fullbright(vec3 c) -{ -#if LEGACY_ADJUST - float exp_scale = clamp(texture(exposureMap, vec2(0.5, 0.5)).r, 0.01, 10.0); - return c / exp_scale * 1.34; //magic 1.34 arrived at by binary search for a value that reproduces midpoint grey consistenty -#else - return c; -#endif -} - diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl index 437fa0a6d5..a1da4b1f9a 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl @@ -39,12 +39,12 @@ uniform float max_y; uniform vec3 glow; uniform float scene_light_strength; uniform float sun_moon_glow_factor; -uniform float sky_hdr_scale; +uniform float sky_sunlight_scale; +uniform float sky_ambient_scale; float getAmbientClamp() { return 1.0f; } vec3 srgb_to_linear(vec3 col); -vec3 legacy_adjust(vec3 col); // return colors in sRGB space void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, @@ -148,12 +148,9 @@ void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, ou // multiply to get similar colors as when the "scaleSoftClip" implementation was doubling color values // (allows for mixing of light sources other than sunlight e.g. reflection probes) - sunlit *= 1.5; - amblit *= 0.5; + sunlit *= sky_sunlight_scale; + amblit *= sky_ambient_scale; - // override amblit with ambient_color if sky probe ambiance is not zero - amblit = mix(amblit, ambient_color, clamp(sky_hdr_scale-1.0, 0.0, 1.0)); - amblit = srgb_to_linear(amblit); amblit *= ambientLighting(norm, light_dir); } |