diff options
author | RunitaiLinden <davep@lindenlab.com> | 2023-04-04 12:29:12 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-04 10:29:12 -0700 |
commit | 698966f8e7ddcc0b123a83d7c4e381778f8cd8ab (patch) | |
tree | 38132d861fbd835d36963e6a4c71048ac957d163 /indra | |
parent | 7be7c66b0e43baef64871dac278eac5726e28d25 (diff) |
SL-19538 Remove hacky ambiance scale and take the mittens off probe a… (#151)
* SL-19538 Remove hacky ambiance scale and take the mittens off probe ambiance values. Fix for sky brightening being done in sRGB space.
Diffstat (limited to 'indra')
21 files changed, 26 insertions, 93 deletions
diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 8b470d235c..5dfce4ae16 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -83,7 +83,7 @@ const F32 LIGHT_MAX_CUTOFF = 180.f; // reflection probes const F32 REFLECTION_PROBE_MIN_AMBIANCE = 0.f; -const F32 REFLECTION_PROBE_MAX_AMBIANCE = 1.f; +const F32 REFLECTION_PROBE_MAX_AMBIANCE = 100.f; const F32 REFLECTION_PROBE_DEFAULT_AMBIANCE = 0.f; const F32 REFLECTION_PROBE_MIN_CLIP_DISTANCE = 0.f; const F32 REFLECTION_PROBE_MAX_CLIP_DISTANCE = 1024.f; diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 016cbe6e75..e1679c7f52 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -276,7 +276,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } - if (features->hasAtmospherics || features->isDeferred) + if (features->hasAtmospherics || features->isDeferred || features->hasTransport) { if (!shader->attachFragmentObject("windlight/atmosphericsFuncs.glsl")) { return FALSE; diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 5ffd610fba..4490e3eec2 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10347,17 +10347,6 @@ <key>Value</key> <integer>128</integer> </map> - <key>RenderReflectionProbeAmbianceScale</key> - <map> - <key>Comment</key> - <string>Scaler to apply to reflection probes to over-brighten sky contributions to indirect light</string> - <key>Persist</key> - <integer>1</integer> - <key>Type</key> - <string>F32</string> - <key>Value</key> - <real>8</real> - </map> <key>RenderTonemapper</key> <map> <key>Comment</key> diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 3a15fd1111..03df9fd4a1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -44,7 +44,6 @@ vec4 applyWaterFogView(vec3 pos, vec4 color); vec3 srgb_to_linear(vec3 cs); vec3 linear_to_srgb(vec3 cl); vec3 fullbrightAtmosTransport(vec3 light); -vec3 fullbrightScaleSoftClip(vec3 light); #ifdef HAS_ALPHA_MASK uniform float minimum_alpha; @@ -88,8 +87,9 @@ void main() #endif #ifndef IS_HUD - color.rgb = fullbrightAtmosTransport(color.rgb); color.rgb = srgb_to_linear(color.rgb); + color.rgb = fullbrightAtmosTransport(color.rgb); + #endif frag_color.rgb = color.rgb; diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl index 0090155e5c..62d134188c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl @@ -91,7 +91,7 @@ void main() vary_LightNormPosDot = rel_pos_lightnorm_dot; // Initialize temp variables - vec3 sunlight = (sun_up_factor == 1) ? sunlight_color*2.0 : moonlight_color; + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index e7322c14fb..70be9a9029 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -276,9 +276,7 @@ void main() color.rgb *= diffuse_linear.rgb; - color.rgb = linear_to_srgb(color.rgb); color.rgb = atmosFragLightingLinear(color.rgb, additive, atten); - color.rgb = srgb_to_linear(color.rgb); vec4 light = vec4(0,0,0,0); diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl index fb76db99a0..b76443f0f0 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl @@ -83,7 +83,6 @@ vec3 linear_to_srgb(vec3 c); void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); vec3 atmosFragLightingLinear(vec3 color, vec3 additive, vec3 atten); -vec3 scaleSoftClipFragLinear(vec3 color); void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float nh, out float nl, out float nv, out float vh, out float lightDist); float calcLegacyDistanceAttenuation(float distance, float falloff); @@ -236,11 +235,8 @@ void main() color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten, spec); glare += max(max(spec.r, spec.g), spec.b); - color.rgb = linear_to_srgb(color.rgb); color.rgb = atmosFragLightingLinear(color.rgb, additive, atten); - color.rgb = scaleSoftClipFragLinear(color.rgb); - color.rgb = srgb_to_linear(color.rgb); - + vec3 light = vec3(0); // Punctual lights diff --git a/indra/newview/app_settings/shaders/class2/interface/irradianceGenF.glsl b/indra/newview/app_settings/shaders/class2/interface/irradianceGenF.glsl index baf68e11f4..d21af946e0 100644 --- a/indra/newview/app_settings/shaders/class2/interface/irradianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class2/interface/irradianceGenF.glsl @@ -32,7 +32,6 @@ uniform samplerCubeArray reflectionProbes; uniform int sourceIdx; uniform float max_probe_lod; -uniform float ambiance_scale; in vec3 vary_dir; @@ -200,8 +199,6 @@ vec4 filterColor(vec3 N) color /= float(u_sampleCount); - color.rgb *= ambiance_scale; - return color; } diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl index 1d02498209..22e93496d2 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl @@ -30,10 +30,14 @@ vec3 scaleSoftClipFrag(vec3 light); vec3 srgb_to_linear(vec3 col); vec3 linear_to_srgb(vec3 col); +uniform int sun_up_factor; + vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten) { light *= atten.r; - light += additive * 2.0; + additive = srgb_to_linear(additive*2.0); + additive *= sun_up_factor + 1.0; + light += additive; return light; } diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl index c2527db218..12a99edc34 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl @@ -63,9 +63,7 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou vec3 rel_pos_norm = normalize(rel_pos); float rel_pos_len = length(rel_pos); - float scale = sun_up_factor + 1; vec3 sunlight = (sun_up_factor == 1) ? sunlight_color: moonlight_color; - sunlight *= scale; // sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes @@ -143,7 +141,7 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou // fudge sunlit and amblit to get consistent lighting compared to legacy // midday before PBR was a thing - sunlit = sunlight.rgb / scale; + sunlit = sunlight.rgb; amblit = tmpAmbient.rgb * 0.25; additive *= vec3(1.0 - combined_haze); diff --git a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl index 6aa719d200..8221ba9516 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl @@ -30,14 +30,13 @@ vec3 getAdditiveColor(); vec3 getAtmosAttenuation(); -vec3 srgb_to_linear(vec3 col); -vec3 linear_to_srgb(vec3 col); +vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); + +// the below implementations are deprecated but remain here as adapters for shaders that haven't been refactored yet vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten) { - light *= atten.r; - light += additive * 2.0; - return light; + return atmosFragLighting(light, additive, atten); } vec3 atmosTransport(vec3 light) @@ -45,30 +44,17 @@ vec3 atmosTransport(vec3 light) return atmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation()); } -vec3 fullbrightAtmosTransportFragLinear(vec3 light, vec3 additive, vec3 atten) -{ - // same as non-linear version, probably fine - //float brightness = dot(light.rgb * 0.5, vec3(0.3333)) + 0.1; - //return mix(atmosTransportFrag(light.rgb, additive, atten), light.rgb + additive, brightness * brightness); - return atmosTransportFrag(light, additive, atten); -} - vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) { - //float brightness = dot(light.rgb * 0.5, vec3(0.3333)) + 0.1; - //return mix(atmosTransportFrag(light.rgb, additive, atten), light.rgb + additive, brightness * brightness); return atmosTransportFrag(light, additive, atten); } vec3 fullbrightAtmosTransport(vec3 light) { - //return fullbrightAtmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation()); return atmosTransport(light); } vec3 fullbrightShinyAtmosTransport(vec3 light) { - //float brightness = dot(light.rgb, vec3(0.33333)); - //return mix(atmosTransport(light.rgb), (light.rgb + getAdditiveColor().rgb) * (2.0 - brightness), brightness * brightness); return atmosTransport(light); } diff --git a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl index b90de7609b..f6bed16c84 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl @@ -43,9 +43,7 @@ VARYING vec3 vary_position; uniform samplerCube environmentMap; -vec3 fullbrightShinyAtmosTransport(vec3 light); vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten); -vec3 fullbrightScaleSoftClip(vec3 light); void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao); @@ -88,9 +86,8 @@ void main() sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, vec2(0), pos.xyz, norm.xyz, spec.a, env_intensity); applyLegacyEnv(color.rgb, legacyenv, spec, pos, norm, env_intensity); - color.rgb = fullbrightAtmosTransportFrag(color.rgb, additive, atten); - color.rgb = fullbrightScaleSoftClip(color.rgb); color.rgb = srgb_to_linear(color.rgb); + color.rgb = fullbrightAtmosTransportFrag(color.rgb, additive, atten); #endif color.a = 1.0; diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index 6e41df34a4..02ab4494f6 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -44,7 +44,6 @@ vec4 applyWaterFogView(vec3 pos, vec4 color); vec3 atmosFragLightingLinear(vec3 l, vec3 additive, vec3 atten); vec3 scaleSoftClipFragLinear(vec3 l); void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); -vec3 fullbrightAtmosTransportFragLinear(vec3 light, vec3 additive, vec3 atten); vec3 srgb_to_linear(vec3 cs); vec3 linear_to_srgb(vec3 cs); @@ -386,10 +385,7 @@ void main() glare += cur_glare; } - color.rgb = linear_to_srgb(color.rgb); color.rgb = atmosFragLightingLinear(color.rgb, additive, atten); - color.rgb = scaleSoftClipFragLinear(color.rgb); - color.rgb = srgb_to_linear(color.rgb); vec3 npos = normalize(-pos.xyz); vec3 light = vec3(0, 0, 0); diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 0e3ebd1534..7953360054 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -71,7 +71,6 @@ vec4 getPositionWithDepth(vec2 pos_screen, float depth); void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); vec3 atmosFragLightingLinear(vec3 l, vec3 additive, vec3 atten); vec3 scaleSoftClipFragLinear(vec3 l); -vec3 fullbrightAtmosTransportFragLinear(vec3 light, vec3 additive, vec3 atten); // reflection probe interface void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, @@ -212,6 +211,7 @@ void main() { //should only be true of WL sky, just port over base color value color = srgb_to_linear(texture2D(emissiveRect, tc).rgb); + color *= sun_up_factor + 1.0; } else { @@ -262,9 +262,7 @@ void main() if (do_atmospherics) { - color = linear_to_srgb(color); color = atmosFragLightingLinear(color, additive, atten); - color = srgb_to_linear(color); } } diff --git a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl index 9da86759c9..ec0439fa97 100644 --- a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl @@ -282,11 +282,7 @@ void main() color = mix(color, fb.rgb, f); - color.rgb = linear_to_srgb(color.rgb); color = atmosFragLightingLinear(color, additive, atten); - color = scaleSoftClipFragLinear(color); - color.rgb = srgb_to_linear(color.rgb); - float spec = min(max(max(punctual.r, punctual.g), punctual.b), 0.05); diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 09ac7e57a4..bccd76415f 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -651,10 +651,6 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face) S32 channel = gIrradianceGenProgram.enableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP_ARRAY); mTexture->bind(channel); - static LLCachedControl<F32> ambiance_scale(gSavedSettings, "RenderReflectionProbeAmbianceScale", 8.f); - static LLStaticHashedString ambiance_scale_str("ambiance_scale"); - - gIrradianceGenProgram.uniform1f(ambiance_scale_str, ambiance_scale); gIrradianceGenProgram.uniform1i(sSourceIdx, sourceIdx); gIrradianceGenProgram.uniform1f(LLShaderMgr::REFLECTION_PROBE_MAX_LOD, mMaxProbeLOD); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index b50cb49b7e..8b402e210d 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1920,7 +1920,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredFullbrightProgram.mFeatures.calculatesAtmospherics = true; gDeferredFullbrightProgram.mFeatures.hasGamma = true; gDeferredFullbrightProgram.mFeatures.hasTransport = true; - gDeferredFullbrightProgram.mFeatures.hasSrgb = true; + gDeferredFullbrightProgram.mFeatures.hasSrgb = true; gDeferredFullbrightProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; gDeferredFullbrightProgram.mShaderFiles.clear(); gDeferredFullbrightProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER)); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index dfe365b737..11deff5bff 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -5637,15 +5637,6 @@ void LLPipeline::setupHWLights() // Ambient LLColor4 ambient = psky->getTotalAmbient(); - static LLCachedControl<F32> ambiance_scale(gSavedSettings, "RenderReflectionProbeAmbianceScale", 8.f); - - F32 light_scale = 1.f; - - if (gCubeSnapshot && !mReflectionMapManager.isRadiancePass()) - { //darken local lights based on brightening of sky lighting - light_scale = 1.f / ambiance_scale; - } - gGL.setAmbientLightColor(ambient); bool sun_up = environment.getIsSunUp(); @@ -5739,7 +5730,7 @@ void LLPipeline::setupHWLights() } //send linear light color to shader - LLColor4 light_color = light->getLightLinearColor()*light_scale; + LLColor4 light_color = light->getLightLinearColor(); light_color.mV[3] = 0.0f; F32 fade = iter->fade; @@ -7885,15 +7876,6 @@ void LLPipeline::renderDeferredLighting() llassert(!sRenderingHUDs); - static LLCachedControl<F32> ambiance_scale(gSavedSettings, "RenderReflectionProbeAmbianceScale", 8.f); - - F32 light_scale = 1.f; - - if (gCubeSnapshot && !mReflectionMapManager.isRadiancePass()) - { //darken local lights based on brightening of sky lighting - light_scale = 1.f / ambiance_scale; - } - LLRenderTarget *screen_target = &mRT->screen; LLRenderTarget* deferred_light_target = &mRT->deferredLight; @@ -8129,7 +8111,7 @@ void LLPipeline::renderDeferredLighting() F32 s = volume->getLightRadius() * 1.5f; // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor()*light_scale; + LLColor3 col = volume->getLightLinearColor(); if (col.magVecSquared() < 0.001f) { @@ -8223,7 +8205,7 @@ void LLPipeline::renderDeferredLighting() setupSpotLight(gDeferredSpotLightProgram, drawablep); // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor() * light_scale; + LLColor3 col = volume->getLightLinearColor(); gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); @@ -8298,7 +8280,7 @@ void LLPipeline::renderDeferredLighting() setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor() * light_scale; + LLColor3 col = volume->getLightLinearColor(); gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, light_size_final); diff --git a/indra/newview/skins/default/xui/en/floater_adjust_environment.xml b/indra/newview/skins/default/xui/en/floater_adjust_environment.xml index 39fe573c98..f6bfb3574d 100644 --- a/indra/newview/skins/default/xui/en/floater_adjust_environment.xml +++ b/indra/newview/skins/default/xui/en/floater_adjust_environment.xml @@ -266,7 +266,7 @@ layout="topleft" left_delta="5" min_val="0" - max_val="1" + max_val="10" name="probe_ambiance" top_pad="5" width="185" diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml index 1faf9c3152..5e999ed245 100644 --- a/indra/newview/skins/default/xui/en/floater_tools.xml +++ b/indra/newview/skins/default/xui/en/floater_tools.xml @@ -2574,7 +2574,7 @@ even though the user gets a free copy. label="Ambiance" label_width="55" left="10" - max_val="1" + max_val="100" min_val="0" mouse_opaque="true" name="Probe Ambiance" diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml index 094be36b01..a80b1a9166 100644 --- a/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml @@ -333,7 +333,7 @@ layout="topleft" left_delta="5" min_val="0" - max_val="1" + max_val="10" name="probe_ambiance" top_delta="20" width="219" |