MAINT-8988
Make rebuilding sky tex not look up invariant values by converting from LLSD 15 times per pixel. Set range on density multiplier to be non-zero to clamp light attenuation to sane values. Fix UI for density multiplier to include 4 decimal places and not show 0.0003 as 0.00meow-7.2.2
parent
d20c4c17af
commit
1f69a685eb
|
|
@ -155,7 +155,7 @@ LLSettingsSky::validation_list_t legacyHazeValidationList()
|
|||
legacyHazeValidation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_HAZE_HORIZON, false, LLSD::TypeReal,
|
||||
boost::bind(&LLSettingsBase::Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f)))));
|
||||
legacyHazeValidation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_DENSITY_MULTIPLIER, false, LLSD::TypeReal,
|
||||
boost::bind(&LLSettingsBase::Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(0.0009f)))));
|
||||
boost::bind(&LLSettingsBase::Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0001f)(0.9f)))));
|
||||
legacyHazeValidation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_DISTANCE_MULTIPLIER, false, LLSD::TypeReal,
|
||||
boost::bind(&LLSettingsBase::Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(100.0f)))));
|
||||
}
|
||||
|
|
@ -923,11 +923,12 @@ F32 LLSettingsSky::getHazeHorizon() const
|
|||
|
||||
F32 LLSettingsSky::getDensityMultiplier() const
|
||||
{
|
||||
F32 density_multiplier = 0.0001f;
|
||||
if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_DENSITY_MULTIPLIER))
|
||||
{
|
||||
return mSettings[SETTING_LEGACY_HAZE][SETTING_DENSITY_MULTIPLIER].asReal();
|
||||
density_multiplier = mSettings[SETTING_LEGACY_HAZE][SETTING_DENSITY_MULTIPLIER].asReal();
|
||||
}
|
||||
return 0.0001f;
|
||||
return density_multiplier;
|
||||
}
|
||||
|
||||
F32 LLSettingsSky::getDistanceMultiplier() const
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ void LLAtmospherics::init()
|
|||
mInitialized = true;
|
||||
}
|
||||
|
||||
LLColor4 LLAtmospherics::calcSkyColorInDir(const LLVector3 &dir, bool isShiny)
|
||||
LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVector3 &dir, bool isShiny)
|
||||
{
|
||||
F32 saturation = 0.3f;
|
||||
if (dir.mV[VZ] < -0.02f)
|
||||
|
|
@ -241,7 +241,6 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(const LLVector3 &dir, bool isShiny)
|
|||
// undo OGL_TO_CFR_ROTATION and negate vertical direction.
|
||||
LLVector3 Pn = LLVector3(-dir[1] , -dir[2], -dir[0]);
|
||||
|
||||
AtmosphericsVars vars;
|
||||
calcSkyColorWLVert(Pn, vars);
|
||||
|
||||
LLColor3 sky_color = calcSkyColorWLFrag(Pn, vars);
|
||||
|
|
@ -258,16 +257,15 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(const LLVector3 &dir, bool isShiny)
|
|||
void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars)
|
||||
{
|
||||
// LEGACY_ATMOSPHERICS
|
||||
LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
|
||||
//LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
|
||||
|
||||
LLColor3 blue_density = psky->getBlueDensity();
|
||||
LLColor3 blue_horizon = psky->getBlueHorizon();
|
||||
F32 haze_density = psky->getHazeDensity();
|
||||
F32 haze_horizon = psky->getHazeHorizon();
|
||||
F32 density_multiplier = psky->getDensityMultiplier();
|
||||
|
||||
F32 max_y = psky->getMaxY();
|
||||
LLVector3 sun_norm = LLVector3(LLEnvironment::instance().getClampedSunNorm());
|
||||
LLColor3 blue_density = vars.blue_density;
|
||||
LLColor3 blue_horizon = vars.blue_horizon;
|
||||
F32 haze_horizon = vars.haze_horizon;
|
||||
F32 haze_density = vars.haze_density;
|
||||
F32 density_multiplier = vars.density_multiplier;
|
||||
F32 max_y = vars.max_y;
|
||||
LLVector4 sun_norm = vars.sun_norm;
|
||||
|
||||
// project the direction ray onto the sky dome.
|
||||
F32 phi = acos(Pn[1]);
|
||||
|
|
@ -277,7 +275,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars)
|
|||
sinA = 0.01f;
|
||||
}
|
||||
|
||||
F32 Plen = psky->getDomeRadius() * sin(F_PI + phi + asin(psky->getDomeOffset() * sinA)) / sinA;
|
||||
F32 Plen = vars.dome_radius * sin(F_PI + phi + asin(vars.dome_offset * sinA)) / sinA;
|
||||
|
||||
Pn *= Plen;
|
||||
|
||||
|
|
@ -298,19 +296,19 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars)
|
|||
Pn /= Plen;
|
||||
|
||||
// Initialize temp variables
|
||||
LLColor3 sunlight = psky->getSunlightColor();
|
||||
LLColor3 ambient = psky->getAmbientColor();
|
||||
LLColor3 sunlight = vars.sunlight;
|
||||
LLColor3 ambient = vars.ambient;
|
||||
|
||||
LLColor3 glow = psky->getGlow();
|
||||
F32 cloud_shadow = psky->getCloudShadow();
|
||||
LLColor3 glow = vars.glow;
|
||||
F32 cloud_shadow = vars.cloud_shadow;
|
||||
|
||||
// Sunlight attenuation effect (hue and brightness) due to atmosphere
|
||||
// this is used later for sunlight modulation at various altitudes
|
||||
LLColor3 light_atten = psky->getLightAttenuation(psky->getMaxY());
|
||||
LLColor3 light_atten = vars.light_atten;
|
||||
|
||||
// Calculate relative weights
|
||||
LLColor3 temp2(0.f, 0.f, 0.f);
|
||||
LLColor3 temp1 = psky->getLightTransmittance();
|
||||
LLColor3 temp1 = vars.light_transmittance;
|
||||
|
||||
LLColor3 blue_weight = componentDiv(blue_density, temp1);
|
||||
LLColor3 haze_weight = componentDiv(smear(haze_density), temp1);
|
||||
|
|
@ -329,7 +327,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars)
|
|||
|
||||
|
||||
// Compute haze glow
|
||||
temp2.mV[0] = Pn * sun_norm;
|
||||
temp2.mV[0] = Pn * LLVector3(sun_norm);
|
||||
|
||||
temp2.mV[0] = 1.f - temp2.mV[0];
|
||||
// temp2.x is 0 at the sun and increases away from sun
|
||||
|
|
@ -359,7 +357,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars)
|
|||
// Final atmosphere additive
|
||||
componentMultBy(vars.hazeColor, LLColor3::white - temp1);
|
||||
|
||||
sunlight = psky->getSunlightColor();
|
||||
sunlight = vars.sunlight;
|
||||
temp2.mV[1] = llmax(0.f, sun_norm[1] * 2.f);
|
||||
temp2.mV[1] = 1.f / temp2.mV[1];
|
||||
componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1]));
|
||||
|
|
@ -493,9 +491,30 @@ void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in)
|
|||
tosun_45.normalize();
|
||||
|
||||
// Sky colors, just slightly above the horizon in the direction of the sun, perpendicular to the sun, and at a 45 degree angle to the sun.
|
||||
res_color[0] = calcSkyColorInDir(tosun);
|
||||
res_color[1] = calcSkyColorInDir(perp_tosun);
|
||||
res_color[2] = calcSkyColorInDir(tosun_45);
|
||||
AtmosphericsVars vars;
|
||||
|
||||
LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
|
||||
|
||||
// invariants across whole sky tex process...
|
||||
vars.blue_density = psky->getBlueDensity();
|
||||
vars.blue_horizon = psky->getBlueHorizon();
|
||||
vars.haze_density = psky->getHazeDensity();
|
||||
vars.haze_horizon = psky->getHazeHorizon();
|
||||
vars.density_multiplier = psky->getDensityMultiplier();
|
||||
vars.max_y = psky->getMaxY();
|
||||
vars.sun_norm = LLEnvironment::instance().getClampedSunNorm();
|
||||
vars.sunlight = psky->getSunlightColor();
|
||||
vars.ambient = psky->getAmbientColor();
|
||||
vars.glow = psky->getGlow();
|
||||
vars.cloud_shadow = psky->getCloudShadow();
|
||||
vars.dome_radius = psky->getDomeRadius();
|
||||
vars.dome_offset = psky->getDomeOffset();
|
||||
vars.light_atten = psky->getLightAttenuation(vars.max_y);
|
||||
vars.light_transmittance = psky->getLightTransmittance();
|
||||
|
||||
res_color[0] = calcSkyColorInDir(vars, tosun);
|
||||
res_color[1] = calcSkyColorInDir(vars, perp_tosun);
|
||||
res_color[2] = calcSkyColorInDir(vars, tosun_45);
|
||||
|
||||
sky_fog_color = color_norm(res_color[0] + res_color[1] + res_color[2]);
|
||||
|
||||
|
|
|
|||
|
|
@ -187,6 +187,21 @@ public:
|
|||
, cloudColorSun(0,0,0)
|
||||
, cloudColorAmbient(0,0,0)
|
||||
, cloudDensity(0.0f)
|
||||
, blue_density()
|
||||
, blue_horizon()
|
||||
, haze_density(0.0f)
|
||||
, haze_horizon(0.0f)
|
||||
, density_multiplier(0.0f)
|
||||
, max_y(0.0f)
|
||||
, sun_norm(0.0f, 1.0f, 0.0f, 1.0f)
|
||||
, sunlight()
|
||||
, ambient()
|
||||
, glow()
|
||||
, cloud_shadow(1.0f)
|
||||
, dome_radius(1.0f)
|
||||
, dome_offset(1.0f)
|
||||
, light_atten()
|
||||
, light_transmittance()
|
||||
{
|
||||
horizontalProjection[0] = LLVector2(0,0);
|
||||
horizontalProjection[1] = LLVector2(0,0);
|
||||
|
|
@ -198,6 +213,21 @@ public:
|
|||
LLColor3 cloudColorAmbient;
|
||||
F32 cloudDensity;
|
||||
LLVector2 horizontalProjection[2];
|
||||
LLColor3 blue_density;
|
||||
LLColor3 blue_horizon;
|
||||
F32 haze_density;
|
||||
F32 haze_horizon;
|
||||
F32 density_multiplier;
|
||||
F32 max_y;
|
||||
LLVector4 sun_norm;
|
||||
LLColor3 sunlight;
|
||||
LLColor3 ambient;
|
||||
LLColor3 glow;
|
||||
F32 cloud_shadow;
|
||||
F32 dome_radius;
|
||||
F32 dome_offset;
|
||||
LLColor3 light_atten;
|
||||
LLColor3 light_transmittance;
|
||||
};
|
||||
|
||||
class LLAtmospherics
|
||||
|
|
@ -222,7 +252,7 @@ public:
|
|||
void setCloudDensity(F32 cloud_density) { mCloudDensity = cloud_density; }
|
||||
void setWind ( const LLVector3& wind ) { mWind = wind.length(); }
|
||||
|
||||
LLColor4 calcSkyColorInDir(const LLVector3& dir, bool isShiny = false);
|
||||
LLColor4 calcSkyColorInDir(AtmosphericsVars& vars, const LLVector3& dir, bool isShiny = false);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
|||
|
|
@ -420,13 +420,34 @@ void LLVOSky::init()
|
|||
|
||||
updateDirections();
|
||||
|
||||
AtmosphericsVars vars;
|
||||
|
||||
LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
|
||||
|
||||
// invariants across whole sky tex process...
|
||||
vars.blue_density = psky->getBlueDensity();
|
||||
vars.blue_horizon = psky->getBlueHorizon();
|
||||
vars.haze_density = psky->getHazeDensity();
|
||||
vars.haze_horizon = psky->getHazeHorizon();
|
||||
vars.density_multiplier = psky->getDensityMultiplier();
|
||||
vars.max_y = psky->getMaxY();
|
||||
vars.sun_norm = LLEnvironment::instance().getClampedSunNorm();
|
||||
vars.sunlight = psky->getSunlightColor();
|
||||
vars.ambient = psky->getAmbientColor();
|
||||
vars.glow = psky->getGlow();
|
||||
vars.cloud_shadow = psky->getCloudShadow();
|
||||
vars.dome_radius = psky->getDomeRadius();
|
||||
vars.dome_offset = psky->getDomeOffset();
|
||||
vars.light_atten = psky->getLightAttenuation(vars.max_y);
|
||||
vars.light_transmittance = psky->getLightTransmittance();
|
||||
|
||||
// Initialize the cached normalized direction vectors
|
||||
for (S32 side = 0; side < 6; ++side)
|
||||
{
|
||||
for (S32 tile = 0; tile < NUM_TILES; ++tile)
|
||||
{
|
||||
initSkyTextureDirs(side, tile);
|
||||
createSkyTexture(side, tile);
|
||||
createSkyTexture(vars, side, tile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -551,7 +572,7 @@ void LLVOSky::initSkyTextureDirs(const S32 side, const S32 tile)
|
|||
}
|
||||
}
|
||||
|
||||
void LLVOSky::createSkyTexture(const S32 side, const S32 tile)
|
||||
void LLVOSky::createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 tile)
|
||||
{
|
||||
S32 tile_x = tile % NUM_TILES_X;
|
||||
S32 tile_y = tile / NUM_TILES_X;
|
||||
|
|
@ -564,8 +585,8 @@ void LLVOSky::createSkyTexture(const S32 side, const S32 tile)
|
|||
{
|
||||
for (x = tile_x_pos; x < (tile_x_pos + sTileResX); ++x)
|
||||
{
|
||||
mSkyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(mSkyTex[side].getDir(x, y)), x, y);
|
||||
mShinyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(mSkyTex[side].getDir(x, y), true), x, y);
|
||||
mSkyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(vars, mSkyTex[side].getDir(x, y)), x, y);
|
||||
mShinyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(vars, mSkyTex[side].getDir(x, y), true), x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -664,11 +685,32 @@ bool LLVOSky::updateSky()
|
|||
{
|
||||
updateFog(LLViewerCamera::getInstance()->getFar());
|
||||
|
||||
AtmosphericsVars vars;
|
||||
|
||||
LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
|
||||
|
||||
// invariants across whole sky tex process...
|
||||
vars.blue_density = psky->getBlueDensity();
|
||||
vars.blue_horizon = psky->getBlueHorizon();
|
||||
vars.haze_density = psky->getHazeDensity();
|
||||
vars.haze_horizon = psky->getHazeHorizon();
|
||||
vars.density_multiplier = psky->getDensityMultiplier();
|
||||
vars.max_y = psky->getMaxY();
|
||||
vars.sun_norm = LLEnvironment::instance().getClampedSunNorm();
|
||||
vars.sunlight = psky->getSunlightColor();
|
||||
vars.ambient = psky->getAmbientColor();
|
||||
vars.glow = psky->getGlow();
|
||||
vars.cloud_shadow = psky->getCloudShadow();
|
||||
vars.dome_radius = psky->getDomeRadius();
|
||||
vars.dome_offset = psky->getDomeOffset();
|
||||
vars.light_atten = psky->getLightAttenuation(vars.max_y);
|
||||
vars.light_transmittance = psky->getLightTransmittance();
|
||||
|
||||
for (int side = 0; side < 6; side++)
|
||||
{
|
||||
for (int tile = 0; tile < NUM_TILES; tile++)
|
||||
{
|
||||
createSkyTexture(side, tile);
|
||||
createSkyTexture(vars, side, tile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ protected:
|
|||
void updateDirections(void);
|
||||
|
||||
void initSkyTextureDirs(const S32 side, const S32 tile);
|
||||
void createSkyTexture(const S32 side, const S32 tile);
|
||||
void createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 tile);
|
||||
|
||||
LLPointer<LLViewerFetchedTexture> mSunTexturep[2];
|
||||
LLPointer<LLViewerFetchedTexture> mMoonTexturep[2];
|
||||
|
|
|
|||
|
|
@ -187,14 +187,14 @@
|
|||
Density Multiplier:
|
||||
</text>
|
||||
<slider
|
||||
decimal_digits="2"
|
||||
decimal_digits="4"
|
||||
follows="left|top"
|
||||
height="16"
|
||||
increment="0.01"
|
||||
increment="0.0001"
|
||||
initial_value="0"
|
||||
layout="topleft"
|
||||
left_delta="5"
|
||||
min_val="0"
|
||||
min_val="0.0001"
|
||||
max_val="0.9"
|
||||
name="density_multip"
|
||||
top_delta="20"
|
||||
|
|
@ -250,4 +250,4 @@
|
|||
</layout_stack>
|
||||
</layout_panel>
|
||||
</layout_stack>
|
||||
</panel>
|
||||
</panel>
|
||||
|
|
|
|||
Loading…
Reference in New Issue