Prepare for validation and storage of legacy haze settings (still pass-through for now).
Isolate more use of legacy haze params behind wrapper funcs.master
parent
087e210825
commit
89d71617f0
|
|
@ -108,9 +108,36 @@ const std::string LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR("exp_s
|
|||
const std::string LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM("linear_term");
|
||||
const std::string LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM("constant_term");
|
||||
|
||||
const std::string LLSettingsSky::SETTING_LEGACY_HAZE("legacy_haze");
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
LLSettingsSky::validation_list_t legacyHazeValidationList()
|
||||
{
|
||||
static LLSettingsBase::validation_list_t legacyHazeValidation;
|
||||
if (legacyHazeValidation.empty())
|
||||
{
|
||||
legacyHazeValidation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_BLUE_DENSITY, true, LLSD::TypeArray,
|
||||
boost::bind(&LLSettingsBase::Validator::verifyVectorMinMax, _1,
|
||||
LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")),
|
||||
LLSD(LLSDArray(2.0f)(2.0f)(2.0f)("*")))));
|
||||
legacyHazeValidation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_BLUE_HORIZON, true, LLSD::TypeArray,
|
||||
boost::bind(&LLSettingsBase::Validator::verifyVectorMinMax, _1,
|
||||
LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")),
|
||||
LLSD(LLSDArray(2.0f)(2.0f)(2.0f)("*")))));
|
||||
legacyHazeValidation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_HAZE_DENSITY, true, LLSD::TypeReal,
|
||||
boost::bind(&LLSettingsBase::Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(4.0f)))));
|
||||
legacyHazeValidation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_HAZE_HORIZON, true, LLSD::TypeReal,
|
||||
boost::bind(&LLSettingsBase::Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f)))));
|
||||
legacyHazeValidation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_DENSITY_MULTIPLIER, true, LLSD::TypeReal,
|
||||
boost::bind(&LLSettingsBase::Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(0.0009f)))));
|
||||
legacyHazeValidation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_DISTANCE_MULTIPLIER, true, LLSD::TypeReal,
|
||||
boost::bind(&LLSettingsBase::Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(100.0f)))));
|
||||
}
|
||||
return legacyHazeValidation;
|
||||
}
|
||||
|
||||
LLSettingsSky::validation_list_t rayleighValidationList()
|
||||
{
|
||||
static LLSettingsBase::validation_list_t rayleighValidation;
|
||||
|
|
@ -183,6 +210,24 @@ LLSettingsSky::validation_list_t mieValidationList()
|
|||
return mieValidation;
|
||||
}
|
||||
|
||||
bool validateLegacyHaze(LLSD &value)
|
||||
{
|
||||
LLSettingsSky::validation_list_t legacyHazeValidations = legacyHazeValidationList();
|
||||
llassert(value.type() == LLSD::Type::TypeMap);
|
||||
LLSD result = LLSettingsBase::settingValidation(value, legacyHazeValidations);
|
||||
if (result["errors"].size() > 0)
|
||||
{
|
||||
LL_WARNS("SETTINGS") << "Legacy Haze Config Validation errors: " << result["errors"] << LL_ENDL;
|
||||
return false;
|
||||
}
|
||||
if (result["warnings"].size() > 0)
|
||||
{
|
||||
LL_WARNS("SETTINGS") << "Legacy Haze Config Validation warnings: " << result["errors"] << LL_ENDL;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool validateRayleighLayers(LLSD &value)
|
||||
{
|
||||
LLSettingsSky::validation_list_t rayleighValidations = rayleighValidationList();
|
||||
|
|
@ -404,8 +449,9 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList()
|
|||
validation.push_back(Validator(SETTING_DENSITY_MULTIPLIER, false, LLSD::TypeReal,
|
||||
boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(0.0009f)))));
|
||||
validation.push_back(Validator(SETTING_DISTANCE_MULTIPLIER, false, LLSD::TypeReal,
|
||||
|
||||
boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(100.0f)))));
|
||||
|
||||
|
||||
validation.push_back(Validator(SETTING_BLOOM_TEXTUREID, true, LLSD::TypeUUID));
|
||||
validation.push_back(Validator(SETTING_CLOUD_COLOR, true, LLSD::TypeArray,
|
||||
boost::bind(&Validator::verifyVectorMinMax, _1,
|
||||
|
|
@ -470,6 +516,7 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList()
|
|||
validation.push_back(Validator(SETTING_RAYLEIGH_CONFIG, true, LLSD::TypeArray, &validateRayleighLayers));
|
||||
validation.push_back(Validator(SETTING_ABSORPTION_CONFIG, true, LLSD::TypeArray, &validateAbsorptionLayers));
|
||||
validation.push_back(Validator(SETTING_MIE_CONFIG, true, LLSD::TypeArray, &validateMieLayers));
|
||||
validation.push_back(Validator(SETTING_LEGACY_HAZE, false, LLSD::TypeMap, &validateLegacyHaze));
|
||||
}
|
||||
return validation;
|
||||
}
|
||||
|
|
@ -569,14 +616,45 @@ LLSD LLSettingsSky::defaults()
|
|||
return dfltsetting;
|
||||
}
|
||||
|
||||
LLSD LLSettingsSky::translateLegacySettings(LLSD legacy)
|
||||
LLSD LLSettingsSky::translateLegacyHazeSettings(const LLSD& legacy)
|
||||
{
|
||||
LLSD newsettings(defaults());
|
||||
LLSD legacyhazesettings;
|
||||
|
||||
// AdvancedAtmospherics TODO
|
||||
// These need to be translated into density profile info in the new settings format...
|
||||
// LEGACY_ATMOSPHERICS
|
||||
|
||||
// LEGACY_ATMOSPHERICS
|
||||
if (legacy.has(SETTING_BLUE_DENSITY))
|
||||
{
|
||||
legacyhazesettings[SETTING_BLUE_DENSITY] = LLColor3(legacy[SETTING_BLUE_DENSITY]).getValue();
|
||||
}
|
||||
if (legacy.has(SETTING_BLUE_HORIZON))
|
||||
{
|
||||
legacyhazesettings[SETTING_BLUE_HORIZON] = LLColor3(legacy[SETTING_BLUE_HORIZON]).getValue();
|
||||
}
|
||||
if (legacy.has(SETTING_DENSITY_MULTIPLIER))
|
||||
{
|
||||
legacyhazesettings[SETTING_DENSITY_MULTIPLIER] = LLSD::Real(legacy[SETTING_DENSITY_MULTIPLIER][0].asReal());
|
||||
}
|
||||
if (legacy.has(SETTING_DISTANCE_MULTIPLIER))
|
||||
{
|
||||
legacyhazesettings[SETTING_DISTANCE_MULTIPLIER] = LLSD::Real(legacy[SETTING_DISTANCE_MULTIPLIER][0].asReal());
|
||||
}
|
||||
if (legacy.has(SETTING_HAZE_DENSITY))
|
||||
{
|
||||
legacyhazesettings[SETTING_HAZE_DENSITY] = LLSD::Real(legacy[SETTING_HAZE_DENSITY][0].asReal());
|
||||
}
|
||||
if (legacy.has(SETTING_HAZE_HORIZON))
|
||||
{
|
||||
legacyhazesettings[SETTING_HAZE_HORIZON] = LLSD::Real(legacy[SETTING_HAZE_HORIZON][0].asReal());
|
||||
}
|
||||
|
||||
return legacyhazesettings;
|
||||
}
|
||||
|
||||
LLSD LLSettingsSky::translateLegacySettings(const LLSD& legacy)
|
||||
{
|
||||
LLSD newsettings(defaults());
|
||||
|
||||
if (legacy.has(SETTING_BLUE_DENSITY))
|
||||
{
|
||||
newsettings[SETTING_BLUE_DENSITY] = LLColor3(legacy[SETTING_BLUE_DENSITY]).getValue();
|
||||
|
|
|
|||
|
|
@ -79,6 +79,8 @@ public:
|
|||
static const std::string SETTING_DENSITY_PROFILE_CONSTANT_TERM;
|
||||
static const std::string SETTING_MIE_ANISOTROPY_FACTOR;
|
||||
|
||||
static const std::string SETTING_LEGACY_HAZE;
|
||||
|
||||
typedef std::shared_ptr<LLSettingsSky> ptr_t;
|
||||
typedef std::pair<F32, F32> azimalt_t;
|
||||
|
||||
|
|
@ -403,7 +405,8 @@ public:
|
|||
virtual validation_list_t getValidationList() const override;
|
||||
static validation_list_t validationList();
|
||||
|
||||
static LLSD translateLegacySettings(LLSD legacy);
|
||||
static LLSD translateLegacySettings(const LLSD& legacy);
|
||||
static LLSD translateLegacyHazeSettings(const LLSD& legacy);
|
||||
|
||||
LLColor3 getLightAttenuation(F32 distance) const;
|
||||
LLColor3 getLightTransmittance() const;
|
||||
|
|
|
|||
|
|
@ -257,9 +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();
|
||||
|
||||
LLColor3 blue_density = psky->getBlueDensity();
|
||||
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 lightnorm = psky->getLightNormal();
|
||||
|
||||
|
|
@ -294,10 +300,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars)
|
|||
// Initialize temp variables
|
||||
LLColor3 sunlight = psky->getSunlightColor();
|
||||
LLColor3 ambient = psky->getAmbientColor();
|
||||
LLColor3 blue_horizon = psky->getBlueHorizon();
|
||||
F32 haze_density = psky->getHazeDensity();
|
||||
F32 haze_horizon = psky->getHazeHorizon();
|
||||
F32 density_multiplier = psky->getDensityMultiplier();
|
||||
|
||||
LLColor3 glow = psky->getGlow();
|
||||
F32 cloud_shadow = psky->getCloudShadow();
|
||||
|
||||
|
|
@ -307,7 +310,8 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars)
|
|||
|
||||
// Calculate relative weights
|
||||
LLColor3 temp2(0.f, 0.f, 0.f);
|
||||
LLColor3 temp1 = blue_density + smear(haze_density);
|
||||
LLColor3 temp1 = psky->getLightTransmittance();
|
||||
|
||||
LLColor3 blue_weight = componentDiv(blue_density, temp1);
|
||||
LLColor3 haze_weight = componentDiv(smear(haze_density), temp1);
|
||||
|
||||
|
|
@ -350,7 +354,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars)
|
|||
sunlight *= (1.f - cloud_shadow);
|
||||
|
||||
// Haze color below cloud
|
||||
LLColor3 additiveColorBelowCloud = (blue_horizon * blue_weight * (sunlight + tmpAmbient) + componentMult(haze_horizon * haze_weight, sunlight * temp2.mV[0] + tmpAmbient));
|
||||
vars.hazeColorBelowCloud = (blue_horizon * blue_weight * (sunlight + tmpAmbient) + componentMult(haze_horizon * haze_weight, sunlight * temp2.mV[0] + tmpAmbient));
|
||||
|
||||
// Final atmosphere additive
|
||||
componentMultBy(vars.hazeColor, LLColor3::white - temp1);
|
||||
|
|
@ -364,8 +368,8 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars)
|
|||
temp1 = componentSqrt(temp1); //less atmos opacity (more transparency) below clouds
|
||||
|
||||
// At horizon, blend high altitude sky color towards the darker color below the clouds
|
||||
vars.hazeColor += componentMult(additiveColorBelowCloud - vars.hazeColor, LLColor3::white - componentSqrt(temp1));
|
||||
|
||||
vars.hazeColor += componentMult(vars.hazeColorBelowCloud - vars.hazeColor, LLColor3::white - componentSqrt(temp1));
|
||||
|
||||
if (Pn[1] < 0.f)
|
||||
{
|
||||
// Eric's original:
|
||||
|
|
@ -390,27 +394,23 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars)
|
|||
LLColor3 LLAtmospherics::calcSkyColorWLFrag(LLVector3 & Pn, AtmosphericsVars& vars)
|
||||
{
|
||||
LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
|
||||
F32 gamma = psky->getGamma();
|
||||
|
||||
|
||||
LLColor3 res;
|
||||
LLColor3 color0 = vars.hazeColor;
|
||||
|
||||
if (!gPipeline.canUseWindLightShaders())
|
||||
{
|
||||
LLColor3 color1 = color0 * 2.0f;
|
||||
color1 = smear(1.f) - componentSaturate(color1);
|
||||
componentPow(color1, gamma);
|
||||
res = smear(1.f) - color1;
|
||||
res = psky->gammaCorrect(color0 * 2.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = color0;
|
||||
}
|
||||
|
||||
# ifndef LL_RELEASE_FOR_DOWNLOAD
|
||||
|
||||
#ifndef LL_RELEASE_FOR_DOWNLOAD
|
||||
F32 gamma = psky->getGamma();
|
||||
LLColor3 color2 = 2.f * color0;
|
||||
|
||||
LLColor3 color3 = LLColor3(1.f, 1.f, 1.f) - componentSaturate(color2);
|
||||
componentPow(color3, gamma);
|
||||
color3 = LLColor3(1.f, 1.f, 1.f) - color3;
|
||||
|
|
@ -440,7 +440,7 @@ LLColor3 LLAtmospherics::calcSkyColorWLFrag(LLVector3 & Pn, AtmosphericsVars& va
|
|||
res = vars.hazeColor;
|
||||
break;
|
||||
}
|
||||
# endif // LL_RELEASE_FOR_DOWNLOAD
|
||||
#endif // LL_RELEASE_FOR_DOWNLOAD
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -555,77 +555,77 @@ BOOL LLVOSky::updateSky()
|
|||
|
||||
if (mForceUpdate || total_no_tiles == frame)
|
||||
{
|
||||
LLSkyTex::stepCurrent();
|
||||
LLSkyTex::stepCurrent();
|
||||
|
||||
const static F32 LIGHT_DIRECTION_THRESHOLD = (F32) cos(DEG_TO_RAD * 1.f);
|
||||
const static F32 COLOR_CHANGE_THRESHOLD = 0.01f;
|
||||
const static F32 LIGHT_DIRECTION_THRESHOLD = (F32) cos(DEG_TO_RAD * 1.f);
|
||||
const static F32 COLOR_CHANGE_THRESHOLD = 0.01f;
|
||||
|
||||
LLVector3 direction = mSun.getDirection();
|
||||
direction.normalize();
|
||||
const F32 dot_lighting = direction * mLastLightingDirection;
|
||||
LLVector3 direction = mSun.getDirection();
|
||||
direction.normalize();
|
||||
const F32 dot_lighting = direction * mLastLightingDirection;
|
||||
|
||||
LLColor3 delta_color;
|
||||
delta_color.setVec(mLastTotalAmbient.mV[0] - total_ambient.mV[0],
|
||||
mLastTotalAmbient.mV[1] - total_ambient.mV[1],
|
||||
mLastTotalAmbient.mV[2] - total_ambient.mV[2]);
|
||||
LLColor3 delta_color;
|
||||
delta_color.setVec(mLastTotalAmbient.mV[0] - total_ambient.mV[0],
|
||||
mLastTotalAmbient.mV[1] - total_ambient.mV[1],
|
||||
mLastTotalAmbient.mV[2] - total_ambient.mV[2]);
|
||||
|
||||
if ( mForceUpdate
|
||||
|| (((dot_lighting < LIGHT_DIRECTION_THRESHOLD)
|
||||
|| (delta_color.length() > COLOR_CHANGE_THRESHOLD)
|
||||
|| !mInitialized)
|
||||
&& !direction.isExactlyZero()))
|
||||
if ( mForceUpdate
|
||||
|| (((dot_lighting < LIGHT_DIRECTION_THRESHOLD)
|
||||
|| (delta_color.length() > COLOR_CHANGE_THRESHOLD)
|
||||
|| !mInitialized)
|
||||
&& !direction.isExactlyZero()))
|
||||
{
|
||||
mLastLightingDirection = direction;
|
||||
mLastTotalAmbient = total_ambient;
|
||||
mInitialized = TRUE;
|
||||
|
||||
if (mCubeMap)
|
||||
{
|
||||
mLastLightingDirection = direction;
|
||||
mLastTotalAmbient = total_ambient;
|
||||
mInitialized = TRUE;
|
||||
|
||||
if (mCubeMap)
|
||||
{
|
||||
if (mForceUpdate)
|
||||
{
|
||||
updateFog(LLViewerCamera::getInstance()->getFar());
|
||||
updateFog(LLViewerCamera::getInstance()->getFar());
|
||||
|
||||
for (int side = 0; side < 6; side++)
|
||||
{
|
||||
for (int tile = 0; tile < NUM_TILES; tile++)
|
||||
{
|
||||
createSkyTexture(side, tile);
|
||||
}
|
||||
}
|
||||
for (int side = 0; side < 6; side++)
|
||||
{
|
||||
for (int tile = 0; tile < NUM_TILES; tile++)
|
||||
{
|
||||
createSkyTexture(side, tile);
|
||||
}
|
||||
}
|
||||
|
||||
for (int side = 0; side < 6; side++)
|
||||
{
|
||||
LLImageRaw* raw1 = mSkyTex[side].getImageRaw(TRUE);
|
||||
LLImageRaw* raw2 = mSkyTex[side].getImageRaw(FALSE);
|
||||
raw2->copy(raw1);
|
||||
mSkyTex[side].createGLImage(mSkyTex[side].getWhich(FALSE));
|
||||
for (int side = 0; side < 6; side++)
|
||||
{
|
||||
LLImageRaw* raw1 = mSkyTex[side].getImageRaw(TRUE);
|
||||
LLImageRaw* raw2 = mSkyTex[side].getImageRaw(FALSE);
|
||||
raw2->copy(raw1);
|
||||
mSkyTex[side].createGLImage(mSkyTex[side].getWhich(FALSE));
|
||||
|
||||
raw1 = mShinyTex[side].getImageRaw(TRUE);
|
||||
raw2 = mShinyTex[side].getImageRaw(FALSE);
|
||||
raw2->copy(raw1);
|
||||
mShinyTex[side].createGLImage(mShinyTex[side].getWhich(FALSE));
|
||||
}
|
||||
next_frame = 0;
|
||||
raw1 = mShinyTex[side].getImageRaw(TRUE);
|
||||
raw2 = mShinyTex[side].getImageRaw(FALSE);
|
||||
raw2->copy(raw1);
|
||||
mShinyTex[side].createGLImage(mShinyTex[side].getWhich(FALSE));
|
||||
}
|
||||
next_frame = 0;
|
||||
|
||||
// update the sky texture
|
||||
for (S32 i = 0; i < 6; ++i)
|
||||
{
|
||||
mSkyTex[i].create(1.0f);
|
||||
mShinyTex[i].create(1.0f);
|
||||
}
|
||||
// update the sky texture
|
||||
for (S32 i = 0; i < 6; ++i)
|
||||
{
|
||||
mSkyTex[i].create(1.0f);
|
||||
mShinyTex[i].create(1.0f);
|
||||
}
|
||||
|
||||
// update the environment map
|
||||
// update the environment map
|
||||
if (mCubeMap)
|
||||
{
|
||||
std::vector<LLPointer<LLImageRaw> > images;
|
||||
images.reserve(6);
|
||||
for (S32 side = 0; side < 6; side++)
|
||||
{
|
||||
images.push_back(mShinyTex[side].getImageRaw(TRUE));
|
||||
}
|
||||
mCubeMap->init(images);
|
||||
gGL.getTexUnit(0)->disable();
|
||||
}
|
||||
std::vector<LLPointer<LLImageRaw> > images;
|
||||
images.reserve(6);
|
||||
for (S32 side = 0; side < 6; side++)
|
||||
{
|
||||
images.push_back(mShinyTex[side].getImageRaw(TRUE));
|
||||
}
|
||||
mCubeMap->init(images);
|
||||
gGL.getTexUnit(0)->disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue