Skip to content

Commit c02bade

Browse files
authored
#3170 Fix for tonemapping not working with PBR skies.
1 parent 5ac2adf commit c02bade

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

indra/llinventory/llsettingssky.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,7 @@ void LLSettingsSky::loadValuesFromLLSD()
11801180
mHDRMax = 2.0f;
11811181
mHDRMin = 0.5f;
11821182
mHDROffset = 1.0f;
1183+
mTonemapMix = 1.0f;
11831184

11841185
mSunTextureId = settings[SETTING_SUN_TEXTUREID].asUUID();
11851186
mMoonTextureId = settings[SETTING_MOON_TEXTUREID].asUUID();
@@ -2055,6 +2056,22 @@ F32 LLSettingsSky::getHDROffset() const
20552056
return mHDROffset;
20562057
}
20572058

2059+
F32 LLSettingsSky::getTonemapMix() const
2060+
{
2061+
if (mCanAutoAdjust)
2062+
return 0.0f;
2063+
2064+
return mTonemapMix;
2065+
}
2066+
2067+
void LLSettingsSky::setTonemapMix(F32 mix)
2068+
{
2069+
if (mCanAutoAdjust)
2070+
return;
2071+
2072+
mTonemapMix = mix;
2073+
}
2074+
20582075
void LLSettingsSky::setGamma(F32 val)
20592076
{
20602077
mGamma = val;

indra/llinventory/llsettingssky.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ class LLSettingsSky: public LLSettingsBase
212212
F32 getHDRMin() const;
213213
F32 getHDRMax() const;
214214
F32 getHDROffset() const;
215+
F32 getTonemapMix() const;
216+
void setTonemapMix(F32 mix);
215217

216218
void setGamma(F32 val);
217219

@@ -384,6 +386,7 @@ class LLSettingsSky: public LLSettingsBase
384386
F32 mCloudVariance;
385387
F32 mCloudShadow;
386388
F32 mCloudScale;
389+
F32 mTonemapMix;
387390
F32 mHDROffset;
388391
F32 mHDRMax;
389392
F32 mHDRMin;

indra/newview/llsettingsvo.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,10 +804,16 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force)
804804
static LLCachedControl<F32> sunlight_scale(gSavedSettings, "RenderSkySunlightScale", 1.5f);
805805
static LLCachedControl<F32> sunlight_hdr_scale(gSavedSettings, "RenderHDRSkySunlightScale", 1.5f);
806806
static LLCachedControl<F32> ambient_scale(gSavedSettings, "RenderSkyAmbientScale", 1.5f);
807+
static LLCachedControl<F32> tonemap_mix_setting(gSavedSettings, "RenderTonemapMix", 1.f);
807808

808809
// sky is a "classic" sky following pre SL 7.0 shading
809810
bool classic_mode = psky->canAutoAdjust();
810811

812+
if (!classic_mode)
813+
{
814+
psky->setTonemapMix(tonemap_mix_setting);
815+
}
816+
811817
shader->uniform1f(LLShaderMgr::SKY_SUNLIGHT_SCALE, hdr ? sunlight_hdr_scale : sunlight_scale);
812818
shader->uniform1f(LLShaderMgr::SKY_AMBIENT_SCALE, ambient_scale);
813819
shader->uniform1i(LLShaderMgr::CLASSIC_MODE, classic_mode);

indra/newview/pipeline.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7150,17 +7150,7 @@ void LLPipeline::tonemap(LLRenderTarget* src, LLRenderTarget* dst)
71507150

71517151
static LLCachedControl<U32> tonemap_type_setting(gSavedSettings, "RenderTonemapType", 0U);
71527152
shader.uniform1i(tonemap_type, tonemap_type_setting);
7153-
7154-
static LLCachedControl<F32> tonemap_mix_setting(gSavedSettings, "RenderTonemapMix", 1.f);
7155-
if (psky->canAutoAdjust())
7156-
{
7157-
// Legacy skies
7158-
shader.uniform1f(tonemap_mix, 0.f);
7159-
}
7160-
else
7161-
{
7162-
shader.uniform1f(tonemap_mix, tonemap_mix_setting());
7163-
}
7153+
shader.uniform1f(tonemap_mix, psky->getTonemapMix());
71647154

71657155
mScreenTriangleVB->setBuffer();
71667156
mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);

0 commit comments

Comments
 (0)