summaryrefslogtreecommitdiff
path: root/indra/newview/llvosky.cpp
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2019-07-10 13:02:09 -0700
committerGraham Linden <graham@lindenlab.com>2019-07-10 13:02:09 -0700
commitd23bf2c16e2d36b18c920bbd42f49c47f3c58bd9 (patch)
treee76eb0412e6ba8480a5497cb9ea56191865cc7f4 /indra/newview/llvosky.cpp
parent5e84b7af3513851e52606a9c4610041ad1aec177 (diff)
SL-11541 WIP
Make LLSettingsSky::gammaCorrect work like the soft scale clip and gamma correct from release. Add transmittance effects to the low-end sky tex gen.
Diffstat (limited to 'indra/newview/llvosky.cpp')
-rw-r--r--indra/newview/llvosky.cpp110
1 files changed, 19 insertions, 91 deletions
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index 745278bf0c..3afc57d9ba 100644
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -207,16 +207,7 @@ void LLSkyTex::create(const F32 brightness)
void LLSkyTex::createGLImage(S32 which)
{
-#if USE_SRGB_DECODE
- if (LLPipeline::RenderDeferred)
- {
- mTexture[which]->setExplicitFormat(GL_SRGB8_ALPHA8, GL_RGBA);
- }
- else
-#endif
- {
- mTexture[which]->setExplicitFormat(GL_RGBA8, GL_RGBA);
- }
+ mTexture[which]->setExplicitFormat(GL_SRGB8_ALPHA8, GL_RGBA);
mTexture[which]->createGLTexture(0, mImageRaw[which], 0, TRUE, LLGLTexture::LOCAL);
mTexture[which]->setAddressMode(LLTexUnit::TAM_CLAMP);
}
@@ -478,7 +469,7 @@ void LLVOSky::init()
m_atmosphericsVars.haze_horizon = psky->getHazeHorizon();
m_atmosphericsVars.density_multiplier = psky->getDensityMultiplier();
m_atmosphericsVars.max_y = psky->getMaxY();
- m_atmosphericsVars.sun_norm = LLEnvironment::instance().getClampedSunNorm();
+ m_atmosphericsVars.sun_norm = LLEnvironment::instance().getClampedLightNorm();
m_atmosphericsVars.sunlight = psky->getSunlightColor();
m_atmosphericsVars.ambient = psky->getAmbientColor();
m_atmosphericsVars.glow = psky->getGlow();
@@ -486,7 +477,8 @@ void LLVOSky::init()
m_atmosphericsVars.dome_radius = psky->getDomeRadius();
m_atmosphericsVars.dome_offset = psky->getDomeOffset();
m_atmosphericsVars.light_atten = psky->getLightAttenuation(m_atmosphericsVars.max_y);
- m_atmosphericsVars.light_transmittance = psky->getLightTransmittance();
+ m_atmosphericsVars.light_transmittance = psky->getLightTransmittance(m_atmosphericsVars.max_y);
+ m_atmosphericsVars.total_density = psky->getTotalDensity();
m_atmosphericsVars.gamma = psky->getGamma();
// Initialize the cached normalized direction vectors
@@ -496,7 +488,7 @@ void LLVOSky::init()
{
initSkyTextureDirs(side, tile);
createSkyTexture(m_atmosphericsVars, side, tile, mSkyTex);
- createSkyTexture(m_atmosphericsVars, side, tile, mShinyTex);
+ createSkyTexture(m_atmosphericsVars, side, tile, mShinyTex, true);
}
}
@@ -527,8 +519,9 @@ void LLVOSky::calc()
m_atmosphericsVars.haze_density = psky->getHazeDensity();
m_atmosphericsVars.haze_horizon = psky->getHazeHorizon();
m_atmosphericsVars.density_multiplier = psky->getDensityMultiplier();
+ m_atmosphericsVars.distance_multiplier = psky->getDistanceMultiplier();
m_atmosphericsVars.max_y = psky->getMaxY();
- m_atmosphericsVars.sun_norm = LLEnvironment::instance().getClampedSunNorm();
+ m_atmosphericsVars.sun_norm = LLEnvironment::instance().getClampedLightNorm();
m_atmosphericsVars.sunlight = psky->getSunlightColor();
m_atmosphericsVars.ambient = psky->getAmbientColor();
m_atmosphericsVars.glow = psky->getGlow();
@@ -536,72 +529,10 @@ void LLVOSky::calc()
m_atmosphericsVars.dome_radius = psky->getDomeRadius();
m_atmosphericsVars.dome_offset = psky->getDomeOffset();
m_atmosphericsVars.light_atten = psky->getLightAttenuation(m_atmosphericsVars.max_y);
- m_atmosphericsVars.light_transmittance = psky->getLightTransmittance();
+ m_atmosphericsVars.light_transmittance = psky->getLightTransmittance(m_atmosphericsVars.max_y);
m_atmosphericsVars.gamma = psky->getGamma();
- LLColor3 vary_HazeColor;
- LLColor3 vary_SunlightColor;
- LLColor3 vary_AmbientColor;
- {
- // Initialize temp variables
- LLColor3 sunlight = m_atmosphericsVars.sunlight;
-
- // Sunlight attenuation effect (hue and brightness) due to atmosphere
- // this is used later for sunlight modulation at various altitudes
- LLColor3 light_atten =
- (m_atmosphericsVars.blue_density * 1.0 + smear(m_atmosphericsVars.haze_density * 0.25f)) * (m_atmosphericsVars.density_multiplier * m_atmosphericsVars.max_y);
-
- // Calculate relative weights
- LLColor3 temp2(0.f, 0.f, 0.f);
- LLColor3 temp1 = m_atmosphericsVars.blue_density + smear(m_atmosphericsVars.haze_density);
- LLColor3 blue_weight = componentDiv(m_atmosphericsVars.blue_density, temp1);
- LLColor3 haze_weight = componentDiv(smear(m_atmosphericsVars.haze_density), temp1);
-
- // Compute sunlight from P & lightnorm (for long rays like sky)
- /// USE only lightnorm.
- // temp2[1] = llmax(0.f, llmax(0.f, Pn[1]) * 1.0f + lightnorm[1] );
- F32 lighty = getSun().getDirection().mV[2];
- temp2.mV[1] = llmax(0.f, lighty);
- if(temp2.mV[1] > 0.f)
- {
- temp2.mV[1] = 1.f / temp2.mV[1];
- }
- componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1]));
-
- // Distance
- temp2.mV[2] = m_atmosphericsVars.density_multiplier;
-
- // Transparency (-> temp1)
- temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]);
-
- // vary_AtmosAttenuation = temp1;
-
- //increase ambient when there are more clouds
- LLColor3 tmpAmbient = m_atmosphericsVars.ambient + (smear(1.f) - m_atmosphericsVars.ambient) * m_atmosphericsVars.cloud_shadow * 0.5f;
-
- //haze color
- vary_HazeColor =
- (m_atmosphericsVars.blue_horizon * blue_weight * (sunlight * (1.f - m_atmosphericsVars.cloud_shadow) + tmpAmbient)
- + componentMult(m_atmosphericsVars.haze_horizon * haze_weight, sunlight * (1.f - m_atmosphericsVars.cloud_shadow) * temp2.mV[0] + tmpAmbient)
- );
-
- //brightness of surface both sunlight and ambient
- vary_SunlightColor = componentMult(sunlight, temp1) * 1.f;
- vary_SunlightColor.clamp();
- vary_SunlightColor = smear(1.0f) - vary_SunlightColor;
- vary_SunlightColor = componentPow(vary_SunlightColor, m_atmosphericsVars.gamma);
- vary_SunlightColor = smear(1.0f) - vary_SunlightColor;
- vary_AmbientColor = componentMult(tmpAmbient, temp1) * 0.5;
- vary_AmbientColor.clamp();
- vary_AmbientColor = smear(1.0f) - vary_AmbientColor;
- vary_AmbientColor = componentPow(vary_AmbientColor, m_atmosphericsVars.gamma);
- vary_AmbientColor = smear(1.0f) - vary_AmbientColor;
-
- componentMultBy(vary_HazeColor, LLColor3(1.f, 1.f, 1.f) - temp1);
-
- }
-
- mSun.setColor(vary_SunlightColor);
+ mSun.setColor(psky->getSunDiffuse());
mMoon.setColor(LLColor3(1.0f, 1.0f, 1.0f));
mSun.renewDirection();
@@ -617,17 +548,17 @@ void LLVOSky::initCubeMap()
{
images.push_back(mShinyTex[side].getImageRaw());
}
- if (mCubeMap)
+
+ if (!mCubeMap && gSavedSettings.getBOOL("RenderWater") && gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps)
+ {
+ mCubeMap = new LLCubeMap(true);
+ }
+
+ if (mCubeMap)
{
mCubeMap->init(images);
}
- else if (gSavedSettings.getBOOL("RenderWater") && gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps)
- {
- bool wantsRGB = LLPipeline::RenderDeferred;
- mCubeMap = new LLCubeMap(wantsRGB);
- mCubeMap->init(images);
- }
gGL.getTexUnit(0)->disable();
}
@@ -709,7 +640,7 @@ void LLVOSky::initSkyTextureDirs(const S32 side, const S32 tile)
}
}
-void LLVOSky::createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 tile, LLSkyTex* tex)
+void LLVOSky::createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 tile, LLSkyTex* tex, bool is_shiny)
{
S32 tile_x = tile % NUM_TILES_X;
S32 tile_y = tile / NUM_TILES_X;
@@ -722,7 +653,7 @@ void LLVOSky::createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32
{
for (x = tile_x_pos; x < (tile_x_pos + sTileResX); ++x)
{
- tex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(vars, tex[side].getDir(x, y), true), x, y);
+ tex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(vars, tex[side].getDir(x, y), is_shiny), x, y);
}
}
}
@@ -740,9 +671,6 @@ void LLVOSky::updateDirections(void)
mSun.setRotation(psky->getSunRotation());
mMoon.setRotation(psky->getMoonRotation());
- mSun.setColor(psky->getSunlightColor());
- mMoon.setColor(psky->getMoonDiffuse());
-
mSun.renewDirection();
mSun.renewColor();
mMoon.renewDirection();
@@ -834,7 +762,7 @@ bool LLVOSky::updateSky()
{
for (int tile = 0; tile < NUM_TILES; tile++)
{
- createSkyTexture(m_atmosphericsVars, side, tile, mShinyTex);
+ createSkyTexture(m_atmosphericsVars, side, tile, mShinyTex, true);
}
}