From 62a0d579b5eb23ea306ade07afba76f7cba685c7 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Wed, 7 Mar 2018 18:37:09 +0000 Subject: Move legacy atmospherics code outside of llvosky (begin teasing apart). --- indra/newview/lllegacyatmospherics.cpp | 649 +++++++++++++++++++++++++++++++++ 1 file changed, 649 insertions(+) create mode 100644 indra/newview/lllegacyatmospherics.cpp (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp new file mode 100644 index 0000000000..a589ef0a68 --- /dev/null +++ b/indra/newview/lllegacyatmospherics.cpp @@ -0,0 +1,649 @@ +/** + * @file lllegacyatmospherics.cpp + * @brief LLAtmospherics class implementation + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "lllegacyatmospherics.h" + +#include "llfeaturemanager.h" +#include "llviewercontrol.h" +#include "llframetimer.h" + +#include "llagent.h" +#include "llagentcamera.h" +#include "lldrawable.h" +#include "llface.h" +#include "llglheaders.h" +#include "llsky.h" +#include "llviewercamera.h" +#include "llviewertexturelist.h" +#include "llviewerobjectlist.h" +#include "llviewerregion.h" +#include "llworld.h" +#include "pipeline.h" +#include "v3colorutil.h" + +#include "llsettingssky.h" +#include "llenvironment.h" +#include "lldrawpoolwater.h" + +class LLFastLn +{ +public: + LLFastLn() + { + mTable[0] = 0; + for( S32 i = 1; i < 257; i++ ) + { + mTable[i] = log((F32)i); + } + } + + F32 ln( F32 x ) + { + const F32 OO_255 = 0.003921568627450980392156862745098f; + const F32 LN_255 = 5.5412635451584261462455391880218f; + + if( x < OO_255 ) + { + return log(x); + } + else + if( x < 1 ) + { + x *= 255.f; + S32 index = llfloor(x); + F32 t = x - index; + F32 low = mTable[index]; + F32 high = mTable[index + 1]; + return low + t * (high - low) - LN_255; + } + else + if( x <= 255 ) + { + S32 index = llfloor(x); + F32 t = x - index; + F32 low = mTable[index]; + F32 high = mTable[index + 1]; + return low + t * (high - low); + } + else + { + return log( x ); + } + } + + F32 pow( F32 x, F32 y ) + { + return (F32)LL_FAST_EXP(y * ln(x)); + } + + +private: + F32 mTable[257]; // index 0 is unused +}; + +static LLFastLn gFastLn; + + +// Functions used a lot. + +inline F32 LLHaze::calcPhase(const F32 cos_theta) const +{ + const F32 g2 = mG * mG; + const F32 den = 1 + g2 - 2 * mG * cos_theta; + return (1 - g2) * gFastLn.pow(den, -1.5); +} + +inline void color_pow(LLColor3 &col, const F32 e) +{ + col.mV[0] = gFastLn.pow(col.mV[0], e); + col.mV[1] = gFastLn.pow(col.mV[1], e); + col.mV[2] = gFastLn.pow(col.mV[2], e); +} + +inline LLColor3 color_norm(const LLColor3 &col) +{ + const F32 m = color_max(col); + if (m > 1.f) + { + return 1.f/m * col; + } + else return col; +} + +inline void color_gamma_correct(LLColor3 &col) +{ + const F32 gamma_inv = 1.f/1.2f; + if (col.mV[0] != 0.f) + { + col.mV[0] = gFastLn.pow(col.mV[0], gamma_inv); + } + if (col.mV[1] != 0.f) + { + col.mV[1] = gFastLn.pow(col.mV[1], gamma_inv); + } + if (col.mV[2] != 0.f) + { + col.mV[2] = gFastLn.pow(col.mV[2], gamma_inv); + } +} + +static LLColor3 calc_air_sca_sea_level() +{ + static LLColor3 WAVE_LEN(675, 520, 445); + static LLColor3 refr_ind = refr_ind_calc(WAVE_LEN); + static LLColor3 n21 = refr_ind * refr_ind - LLColor3(1, 1, 1); + static LLColor3 n4 = n21 * n21; + static LLColor3 wl2 = WAVE_LEN * WAVE_LEN * 1e-6f; + static LLColor3 wl4 = wl2 * wl2; + static LLColor3 mult_const = fsigma * 2.0f/ 3.0f * 1e24f * (F_PI * F_PI) * n4; + static F32 dens_div_N = F32( ATM_SEA_LEVEL_NDENS / Ndens2); + return dens_div_N * mult_const.divide(wl4); +} + +// static constants. +LLColor3 const LLHaze::sAirScaSeaLevel = calc_air_sca_sea_level(); +F32 const LLHaze::sAirScaIntense = color_intens(LLHaze::sAirScaSeaLevel); +F32 const LLHaze::sAirScaAvg = LLHaze::sAirScaIntense / 3.f; + +/*************************************** + Atmospherics +***************************************/ + +LLAtmospherics::LLAtmospherics() +: mCloudDensity(0.2f), + mWind(0.f), + mWorldScale(1.f) +{ + /// WL PARAMS + mInitialized = FALSE; + mUpdateTimer.reset(); + mAmbientScale = gSavedSettings.getF32("SkyAmbientScale"); + mNightColorShift = gSavedSettings.getColor3("SkyNightColorShift"); + mFogColor.mV[VRED] = mFogColor.mV[VGREEN] = mFogColor.mV[VBLUE] = 0.5f; + mFogColor.mV[VALPHA] = 0.0f; + mFogRatio = 1.2f; + mHazeConcentration = 0.f; + mInterpVal = 0.f; +} + + +LLAtmospherics::~LLAtmospherics() +{ +} + +void LLAtmospherics::init() +{ + const F32 haze_int = color_intens(mHaze.calcSigSca(0)); + mHazeConcentration = haze_int / (color_intens(mHaze.calcAirSca(0)) + haze_int); + calc(); + mInitialized = true; +} + +LLColor4 LLAtmospherics::calcSkyColorInDir(const LLVector3 &dir, bool isShiny) +{ + F32 saturation = 0.3f; + if (dir.mV[VZ] < -0.02f) + { + LLColor4 col = LLColor4(llmax(mFogColor[0],0.2f), llmax(mFogColor[1],0.2f), llmax(mFogColor[2],0.22f),0.f); + if (isShiny) + { + LLColor3 desat_fog = LLColor3(mFogColor); + F32 brightness = desat_fog.brightness(); + // So that shiny somewhat shows up at night. + if (brightness < 0.15f) + { + brightness = 0.15f; + desat_fog = smear(0.15f); + } + LLColor3 greyscale = smear(brightness); + desat_fog = desat_fog * saturation + greyscale * (1.0f - saturation); + if (!gPipeline.canUseWindLightShaders()) + { + col = LLColor4(desat_fog, 0.f); + } + else + { + col = LLColor4(desat_fog * 0.5f, 0.f); + } + } + float x = 1.0f-fabsf(-0.1f-dir.mV[VZ]); + x *= x; + col.mV[0] *= x*x; + col.mV[1] *= powf(x, 2.5f); + col.mV[2] *= x*x*x; + return col; + } + + // 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); + if (isShiny) + { + F32 brightness = sky_color.brightness(); + LLColor3 greyscale = smear(brightness); + sky_color = sky_color * saturation + greyscale * (1.0f - saturation); + sky_color *= (0.5f + 0.5f * brightness); + } + return LLColor4(sky_color, 0.0f); +} + +void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) +{ + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + LLColor3 blue_density = psky->getBlueDensity(); + F32 max_y = psky->getMaxY(); + LLVector3 lightnorm = psky->getLightNormal(); + + // project the direction ray onto the sky dome. + F32 phi = acos(Pn[1]); + F32 sinA = sin(F_PI - phi); + if (fabsf(sinA) < 0.01f) + { //avoid division by zero + sinA = 0.01f; + } + + F32 Plen = psky->getDomeRadius() * sin(F_PI + phi + asin(psky->getDomeOffset() * sinA)) / sinA; + + Pn *= Plen; + + vars.horizontalProjection[0] = LLVector2(Pn[0], Pn[2]); + vars.horizontalProjection[0] /= - 2.f * Plen; + + // Set altitude + if (Pn[1] > 0.f) + { + Pn *= (max_y / Pn[1]); + } + else + { + Pn *= (-32000.f / Pn[1]); + } + + Plen = Pn.length(); + Pn /= Plen; + + // 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(); + + // Sunlight attenuation effect (hue and brightness) due to atmosphere + // this is used later for sunlight modulation at various altitudes + LLColor3 light_atten = (blue_density * 1.0 + smear(haze_density * 0.25f)) * (density_multiplier * max_y); + + // Calculate relative weights + LLColor3 temp2(0.f, 0.f, 0.f); + LLColor3 temp1 = blue_density + smear(haze_density); + LLColor3 blue_weight = componentDiv(blue_density, temp1); + LLColor3 haze_weight = componentDiv(smear(haze_density), temp1); + + // Compute sunlight from P & lightnorm (for long rays like sky) + temp2.mV[1] = llmax(F_APPROXIMATELY_ZERO, llmax(0.f, Pn[1]) * 1.0f + lightnorm[1] ); + + temp2.mV[1] = 1.f / temp2.mV[1]; + componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); + + // Distance + temp2.mV[2] = Plen * density_multiplier; + + // Transparency (-> temp1) + temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]); + + + // Compute haze glow + temp2.mV[0] = Pn * lightnorm; + + temp2.mV[0] = 1.f - temp2.mV[0]; + // temp2.x is 0 at the sun and increases away from sun + temp2.mV[0] = llmax(temp2.mV[0], .001f); + // Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + temp2.mV[0] *= glow.mV[0]; + // Higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.mV[0] = pow(temp2.mV[0], glow.mV[2]); + // glow.z should be negative, so we're doing a sort of (1 / "angle") function + + // Add "minimum anti-solar illumination" + temp2.mV[0] += .25f; + + + // Haze color above cloud + vars.hazeColor = (blue_horizon * blue_weight * (sunlight + ambient) + componentMult(haze_horizon * haze_weight, sunlight * temp2.mV[0] + ambient)); + + // Increase ambient when there are more clouds + LLColor3 tmpAmbient = ambient + (LLColor3::white - ambient) * cloud_shadow * 0.5f; + + // Dim sunlight by cloud shadow percentage + 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)); + + // Final atmosphere additive + componentMultBy(vars.hazeColor, LLColor3::white - temp1); + + sunlight = psky->getSunlightColor(); + temp2.mV[1] = llmax(0.f, lightnorm[1] * 2.f); + temp2.mV[1] = 1.f / temp2.mV[1]; + componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); + + // Attenuate cloud color by atmosphere + 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)); + + if (Pn[1] < 0.f) + { + // Eric's original: + // LLColor3 dark_brown(0.143f, 0.129f, 0.114f); + LLColor3 dark_brown(0.082f, 0.076f, 0.066f); + LLColor3 brown(0.430f, 0.386f, 0.322f); + LLColor3 sky_lighting = sunlight + ambient; + F32 haze_brightness = vars.hazeColor.brightness(); + + if (Pn[1] < -0.05f) + { + vars.hazeColor = colorMix(dark_brown, brown, -Pn[1] * 0.9f) * sky_lighting * haze_brightness; + } + + if (Pn[1] > -0.1f) + { + vars.hazeColor = colorMix(LLColor3::white * haze_brightness, vars.hazeColor, fabs((Pn[1] + 0.05f) * -20.f)); + } + } +} + +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; + } + else + { + res = color0; + } + +# ifndef LL_RELEASE_FOR_DOWNLOAD + + 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; + + static enum { + OUT_DEFAULT = 0, + OUT_SKY_BLUE = 1, + OUT_RED = 2, + OUT_PN = 3, + OUT_HAZE = 4, + } debugOut = OUT_DEFAULT; + + switch(debugOut) + { + case OUT_DEFAULT: + break; + case OUT_SKY_BLUE: + res = LLColor3(0.4f, 0.4f, 0.9f); + break; + case OUT_RED: + res = LLColor3(1.f, 0.f, 0.f); + break; + case OUT_PN: + res = LLColor3(Pn[0], Pn[1], Pn[2]); + break; + case OUT_HAZE: + res = vars.hazeColor; + break; + } +# endif // LL_RELEASE_FOR_DOWNLOAD + return res; +} + +void LLAtmospherics::calc() +{ + +} + +void LLAtmospherics::updateFog(const F32 distance, LLVector3& tosun) +{ + if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FOG)) + { + if (!LLGLSLShader::sNoFixedFunction) + { + glFogf(GL_FOG_DENSITY, 0); + glFogfv(GL_FOG_COLOR, (F32 *) &LLColor4::white.mV); + glFogf(GL_FOG_END, 1000000.f); + } + return; + } + + const BOOL hide_clip_plane = TRUE; + LLColor4 target_fog(0.f, 0.2f, 0.5f, 0.f); + + const F32 water_height = gAgent.getRegion() ? gAgent.getRegion()->getWaterHeight() : 0.f; + // LLWorld::getInstance()->getWaterHeight(); + F32 camera_height = gAgentCamera.getCameraPositionAgent().mV[2]; + + F32 near_clip_height = LLViewerCamera::getInstance()->getAtAxis().mV[VZ] * LLViewerCamera::getInstance()->getNear(); + camera_height += near_clip_height; + + F32 fog_distance = 0.f; + LLColor3 res_color[3]; + + LLColor3 sky_fog_color = LLColor3::white; + LLColor3 render_fog_color = LLColor3::white; + + const F32 tosun_z = tosun.mV[VZ]; + tosun.mV[VZ] = 0.f; + tosun.normalize(); + LLVector3 perp_tosun; + perp_tosun.mV[VX] = -tosun.mV[VY]; + perp_tosun.mV[VY] = tosun.mV[VX]; + LLVector3 tosun_45 = tosun + perp_tosun; + tosun_45.normalize(); + + F32 delta = 0.06f; + tosun.mV[VZ] = delta; + perp_tosun.mV[VZ] = delta; + tosun_45.mV[VZ] = delta; + tosun.normalize(); + perp_tosun.normalize(); + 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); + + sky_fog_color = color_norm(res_color[0] + res_color[1] + res_color[2]); + + F32 full_off = -0.25f; + F32 full_on = 0.00f; + F32 on = (tosun_z - full_off) / (full_on - full_off); + on = llclamp(on, 0.01f, 1.f); + sky_fog_color *= 0.5f * on; + + + // We need to clamp these to non-zero, in order for the gamma correction to work. 0^y = ??? + S32 i; + for (i = 0; i < 3; i++) + { + sky_fog_color.mV[i] = llmax(0.0001f, sky_fog_color.mV[i]); + } + + color_gamma_correct(sky_fog_color); + + render_fog_color = sky_fog_color; + + F32 fog_density = 0.f; + fog_distance = mFogRatio * distance; + + if (camera_height > water_height) + { + LLColor4 fog(render_fog_color); + if (!LLGLSLShader::sNoFixedFunction) + { + glFogfv(GL_FOG_COLOR, fog.mV); + } + mGLFogCol = fog; + + if (hide_clip_plane) + { + // For now, set the density to extend to the cull distance. + const F32 f_log = 2.14596602628934723963618357029f; // sqrt(fabs(log(0.01f))) + fog_density = f_log/fog_distance; + if (!LLGLSLShader::sNoFixedFunction) + { + glFogi(GL_FOG_MODE, GL_EXP2); + } + } + else + { + const F32 f_log = 4.6051701859880913680359829093687f; // fabs(log(0.01f)) + fog_density = (f_log)/fog_distance; + if (!LLGLSLShader::sNoFixedFunction) + { + glFogi(GL_FOG_MODE, GL_EXP); + } + } + } + else + { + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + F32 depth = water_height - camera_height; + + // get the water param manager variables + float water_fog_density = pwater->getFogDensity(); + LLColor4 water_fog_color(pwater->getFogColor()); + + // adjust the color based on depth. We're doing linear approximations + float depth_scale = gSavedSettings.getF32("WaterGLFogDepthScale"); + float depth_modifier = 1.0f - llmin(llmax(depth / depth_scale, 0.01f), + gSavedSettings.getF32("WaterGLFogDepthFloor")); + + LLColor4 fogCol = water_fog_color * depth_modifier; + fogCol.setAlpha(1); + + // set the gl fog color + mGLFogCol = fogCol; + + // set the density based on what the shaders use + fog_density = water_fog_density * gSavedSettings.getF32("WaterGLFogDensityScale"); + + if (!LLGLSLShader::sNoFixedFunction) + { + glFogfv(GL_FOG_COLOR, (F32 *) &fogCol.mV); + glFogi(GL_FOG_MODE, GL_EXP2); + } + } + + mFogColor = sky_fog_color; + mFogColor.setAlpha(1); + + LLDrawPoolWater::sWaterFogEnd = fog_distance*2.2f; + + if (!LLGLSLShader::sNoFixedFunction) + { + LLGLSFog gls_fog; + glFogf(GL_FOG_END, fog_distance*2.2f); + glFogf(GL_FOG_DENSITY, fog_density); + glHint(GL_FOG_HINT, GL_NICEST); + } + stop_glerror(); +} + +// Functions used a lot. +F32 color_norm_pow(LLColor3& col, F32 e, BOOL postmultiply) +{ + F32 mv = color_max(col); + if (0 == mv) + { + return 0; + } + + col *= 1.f / mv; + color_pow(col, e); + if (postmultiply) + { + col *= mv; + } + return mv; +} + +// Returns angle (RADIANs) between the horizontal projection of "v" and the x_axis. +// Range of output is 0.0f to 2pi //359.99999...f +// Returns 0.0f when "v" = +/- z_axis. +F32 azimuth(const LLVector3 &v) +{ + F32 azimuth = 0.0f; + if (v.mV[VX] == 0.0f) + { + if (v.mV[VY] > 0.0f) + { + azimuth = F_PI * 0.5f; + } + else if (v.mV[VY] < 0.0f) + { + azimuth = F_PI * 1.5f;// 270.f; + } + } + else + { + azimuth = (F32) atan(v.mV[VY] / v.mV[VX]); + if (v.mV[VX] < 0.0f) + { + azimuth += F_PI; + } + else if (v.mV[VY] < 0.0f) + { + azimuth += F_PI * 2; + } + } + return azimuth; +} -- cgit v1.2.3 From 6d77503542216ece1eecf82dce19ebd8d6be7327 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Wed, 7 Mar 2018 23:49:37 +0000 Subject: Isolate more legacy atmo param use in sky (convert to getLightAttenuation and getLightTransmittance). Optimize sky texture creation. --- indra/newview/lllegacyatmospherics.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index a589ef0a68..622f75a88b 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -200,7 +200,6 @@ void LLAtmospherics::init() { const F32 haze_int = color_intens(mHaze.calcSigSca(0)); mHazeConcentration = haze_int / (color_intens(mHaze.calcAirSca(0)) + haze_int); - calc(); mInitialized = true; } @@ -445,11 +444,6 @@ LLColor3 LLAtmospherics::calcSkyColorWLFrag(LLVector3 & Pn, AtmosphericsVars& va return res; } -void LLAtmospherics::calc() -{ - -} - void LLAtmospherics::updateFog(const F32 distance, LLVector3& tosun) { if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FOG)) -- cgit v1.2.3 From 096ea05a936d178ce0533708edab27708e9e718f Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Thu, 8 Mar 2018 00:04:03 +0000 Subject: Rename getFogColor from water and sky settings to getWaterFogColor and getSkyFogColor. --- indra/newview/lllegacyatmospherics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 622f75a88b..6bc95c367c 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -553,8 +553,8 @@ void LLAtmospherics::updateFog(const F32 distance, LLVector3& tosun) F32 depth = water_height - camera_height; // get the water param manager variables - float water_fog_density = pwater->getFogDensity(); - LLColor4 water_fog_color(pwater->getFogColor()); + float water_fog_density = pwater->getWaterFogDensity(); + LLColor4 water_fog_color(pwater->getWaterFogColor()); // adjust the color based on depth. We're doing linear approximations float depth_scale = gSavedSettings.getF32("WaterGLFogDepthScale"); -- cgit v1.2.3 From 087e21082512bce899e435537d7d60a09ef6eaca Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Thu, 8 Mar 2018 16:09:29 +0000 Subject: Add LLVoSky wrapper for current env sky light direction. Make LLVo classes use LLVoSky wrappers instead of direct access. Isolate more legacy haze param usage w/in settings. --- indra/newview/lllegacyatmospherics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 6bc95c367c..0a788b95c7 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -303,7 +303,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes - LLColor3 light_atten = (blue_density * 1.0 + smear(haze_density * 0.25f)) * (density_multiplier * max_y); + LLColor3 light_atten = psky->getLightAttenuation(psky->getMaxY()); // Calculate relative weights LLColor3 temp2(0.f, 0.f, 0.f); -- cgit v1.2.3 From 89d71617f08825d8def694b3b0ef337d18ee5bf9 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Thu, 8 Mar 2018 17:45:43 +0000 Subject: Prepare for validation and storage of legacy haze settings (still pass-through for now). Isolate more use of legacy haze params behind wrapper funcs. --- indra/newview/lllegacyatmospherics.cpp | 36 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 0a788b95c7..ff09e62f76 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -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; } -- cgit v1.2.3 From 64302d3000b69b31e72eb6a3bd8a981c80cb88de Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 1 Jun 2018 00:18:36 +0100 Subject: Modify use of sky settings, reduce complexity, and name funcs to indicate coord systems in use. Fix class2 softenLightF shader. --- indra/newview/lllegacyatmospherics.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index ff09e62f76..59cfab61fd 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -267,7 +267,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) F32 density_multiplier = psky->getDensityMultiplier(); F32 max_y = psky->getMaxY(); - LLVector3 lightnorm = psky->getLightNormal(); + LLVector3 lightnorm = LLVector3(LLEnvironment::instance().getClampedLightNorm()); // project the direction ray onto the sky dome. F32 phi = acos(Pn[1]); @@ -444,8 +444,10 @@ LLColor3 LLAtmospherics::calcSkyColorWLFrag(LLVector3 & Pn, AtmosphericsVars& va return res; } -void LLAtmospherics::updateFog(const F32 distance, LLVector3& tosun) +void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) { + LLVector3 tosun = tosun_in; + if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FOG)) { if (!LLGLSLShader::sNoFixedFunction) -- cgit v1.2.3 From 67ab0084f87c40bf31d7fadded55cc9ea6299ca2 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 12 Jun 2018 18:42:07 +0100 Subject: Fix env panel forward action. Make env panel update environment when jumping frame to frame. Add separate funcs for sun/moon vectors in various coord systems. Make haze glow only pay attention to sun (i.e. fix sun glow when moon is near horizon in daytime). --- indra/newview/lllegacyatmospherics.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 59cfab61fd..36460475a8 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -267,7 +267,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) F32 density_multiplier = psky->getDensityMultiplier(); F32 max_y = psky->getMaxY(); - LLVector3 lightnorm = LLVector3(LLEnvironment::instance().getClampedLightNorm()); + LLVector3 sun_norm = LLVector3(LLEnvironment::instance().getClampedSunNorm()); // project the direction ray onto the sky dome. F32 phi = acos(Pn[1]); @@ -316,7 +316,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) LLColor3 haze_weight = componentDiv(smear(haze_density), temp1); // Compute sunlight from P & lightnorm (for long rays like sky) - temp2.mV[1] = llmax(F_APPROXIMATELY_ZERO, llmax(0.f, Pn[1]) * 1.0f + lightnorm[1] ); + temp2.mV[1] = llmax(F_APPROXIMATELY_ZERO, llmax(0.f, Pn[1]) * 1.0f + sun_norm[1] ); temp2.mV[1] = 1.f / temp2.mV[1]; componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); @@ -329,7 +329,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) // Compute haze glow - temp2.mV[0] = Pn * lightnorm; + temp2.mV[0] = Pn * sun_norm; temp2.mV[0] = 1.f - temp2.mV[0]; // temp2.x is 0 at the sun and increases away from sun @@ -360,7 +360,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) componentMultBy(vars.hazeColor, LLColor3::white - temp1); sunlight = psky->getSunlightColor(); - temp2.mV[1] = llmax(0.f, lightnorm[1] * 2.f); + 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])); -- cgit v1.2.3 From 1f69a685eb7d403b8ad5b2ebc24978151da49910 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 7 Sep 2018 22:10:14 +0100 Subject: 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.00 --- indra/newview/lllegacyatmospherics.cpp | 65 ++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 23 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 36460475a8..04623c4452 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -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]); -- cgit v1.2.3 From 8acb87aaf32e6f27d2f8caba6178cdd7a80c2086 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 4 Oct 2018 17:00:07 +0300 Subject: SL-9809 [EEP] Environment becomes dark after setting "Glow Size" to the maximum value --- indra/newview/lllegacyatmospherics.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 04623c4452..0c4e5b48e8 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -333,8 +333,17 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) // temp2.x is 0 at the sun and increases away from sun temp2.mV[0] = llmax(temp2.mV[0], .001f); // Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) - temp2.mV[0] *= glow.mV[0]; + + if (glow.mV[0] > 0) // don't pow(zero,negative value), glow from 0 to 2 + { // Higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.mV[0] *= glow.mV[0]; + } + else + { + temp2.mV[0] = F32_MIN; + } + temp2.mV[0] = pow(temp2.mV[0], glow.mV[2]); // glow.z should be negative, so we're doing a sort of (1 / "angle") function -- cgit v1.2.3 From 79d33f9d19a0c6e5ed34ffbd01a31cb2625e1ecc Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 10 Oct 2018 18:44:03 +0100 Subject: Fix names of WATER_BLUR_MULTIPILER. Give wave direction uniforms more meaningful names in shaders. Add comments on glow size/focus conversions for clarity. --- indra/newview/lllegacyatmospherics.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 0c4e5b48e8..371bd1b7c2 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -264,6 +264,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) F32 haze_horizon = vars.haze_horizon; F32 haze_density = vars.haze_density; F32 density_multiplier = vars.density_multiplier; + //F32 distance_multiplier = vars.distance_multiplier; F32 max_y = vars.max_y; LLVector4 sun_norm = vars.sun_norm; @@ -323,7 +324,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) temp2.mV[2] = Plen * density_multiplier; // Transparency (-> temp1) - temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]); + temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]);// * distance_multiplier); // Compute haze glow @@ -510,6 +511,7 @@ void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) vars.haze_density = psky->getHazeDensity(); vars.haze_horizon = psky->getHazeHorizon(); vars.density_multiplier = psky->getDensityMultiplier(); + vars.distance_multiplier = psky->getDistanceMultiplier(); vars.max_y = psky->getMaxY(); vars.sun_norm = LLEnvironment::instance().getClampedSunNorm(); vars.sunlight = psky->getSunlightColor(); -- cgit v1.2.3 From 866f9ab17a893f2c10d2a4ee1797c7afb2eb12ce Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 17 Oct 2018 11:38:18 +0300 Subject: division by zero protection --- indra/newview/lllegacyatmospherics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 371bd1b7c2..b631e5498d 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -368,7 +368,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) componentMultBy(vars.hazeColor, LLColor3::white - temp1); sunlight = vars.sunlight; - temp2.mV[1] = llmax(0.f, sun_norm[1] * 2.f); + temp2.mV[1] = llmax(F_APPROXIMATELY_ZERO, sun_norm[1] * 2.f); temp2.mV[1] = 1.f / temp2.mV[1]; componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); -- cgit v1.2.3 From 65927e0a76aaf8ff4dc268acdb12007265ff3a14 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 13 Feb 2019 13:09:14 -0800 Subject: SL-10181, SL-10546 Fix distortion map rendering in deferred mode not including underwater fog effects. Fix distortion map rendering not including post-deferred content at all. Fix distortion map rendering not including anything but sky when camera is underwater. Update sun_up_factor/sunmoon_glow_factor uniforms even when sun disc isn't in use. --- indra/newview/lllegacyatmospherics.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index b631e5498d..017c21df39 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -585,9 +585,10 @@ void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) F32 depth = water_height - camera_height; // get the water param manager variables - float water_fog_density = pwater->getWaterFogDensity(); + float water_fog_density = pwater->getModifiedWaterFogDensity(depth <= 0.0f); + LLColor4 water_fog_color(pwater->getWaterFogColor()); - + // adjust the color based on depth. We're doing linear approximations float depth_scale = gSavedSettings.getF32("WaterGLFogDepthScale"); float depth_modifier = 1.0f - llmin(llmax(depth / depth_scale, 0.01f), -- cgit v1.2.3 From 7c770e97be0a0862ec5fbb927805259b220b55f4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 20 Jun 2019 16:11:31 -0700 Subject: SL-11371 Remove the ugly band of fog color at the horizon in Low/Low+ entirely. --- indra/newview/lllegacyatmospherics.cpp | 53 ++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 21 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 017c21df39..a09f54c303 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -206,29 +206,27 @@ void LLAtmospherics::init() LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVector3 &dir, bool isShiny) { F32 saturation = 0.3f; - if (dir.mV[VZ] < -0.02f) + + if (isShiny && dir.mV[VZ] < -0.02f) { LLColor4 col = LLColor4(llmax(mFogColor[0],0.2f), llmax(mFogColor[1],0.2f), llmax(mFogColor[2],0.22f),0.f); - if (isShiny) + LLColor3 desat_fog = LLColor3(mFogColor); + F32 brightness = desat_fog.brightness(); + // So that shiny somewhat shows up at night. + if (brightness < 0.15f) { - LLColor3 desat_fog = LLColor3(mFogColor); - F32 brightness = desat_fog.brightness(); - // So that shiny somewhat shows up at night. - if (brightness < 0.15f) - { - brightness = 0.15f; - desat_fog = smear(0.15f); - } - LLColor3 greyscale = smear(brightness); - desat_fog = desat_fog * saturation + greyscale * (1.0f - saturation); - if (!gPipeline.canUseWindLightShaders()) - { - col = LLColor4(desat_fog, 0.f); - } - else - { - col = LLColor4(desat_fog * 0.5f, 0.f); - } + brightness = 0.15f; + desat_fog = smear(0.15f); + } + LLColor3 greyscale = smear(brightness); + desat_fog = desat_fog * saturation + greyscale * (1.0f - saturation); + if (!gPipeline.canUseWindLightShaders()) + { + col = LLColor4(desat_fog, 0.f); + } + else + { + col = LLColor4(desat_fog * 0.5f, 0.f); } float x = 1.0f-fabsf(-0.1f-dir.mV[VZ]); x *= x; @@ -242,7 +240,17 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVecto LLVector3 Pn = LLVector3(-dir[1] , -dir[2], -dir[0]); calcSkyColorWLVert(Pn, vars); - + +#if SL_11371 + if (dir.mV[VZ] < 0.4f) + { + LLColor4 col = LLColor4(llmax(mFogColor[0],0.2f), llmax(mFogColor[1],0.2f), llmax(mFogColor[2],0.22f),0.f); + col *= dir * LLVector3(0,1,0); + col += vars.hazeColor; + return col; + } +#endif + LLColor3 sky_color = calcSkyColorWLFrag(Pn, vars); if (isShiny) { @@ -378,6 +386,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) // At horizon, blend high altitude sky color towards the darker color below the clouds vars.hazeColor += componentMult(vars.hazeColorBelowCloud - vars.hazeColor, LLColor3::white - componentSqrt(temp1)); +#if SL_11371 if (Pn[1] < 0.f) { // Eric's original: @@ -397,6 +406,8 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) vars.hazeColor = colorMix(LLColor3::white * haze_brightness, vars.hazeColor, fabs((Pn[1] + 0.05f) * -20.f)); } } +#endif + } LLColor3 LLAtmospherics::calcSkyColorWLFrag(LLVector3 & Pn, AtmosphericsVars& vars) -- cgit v1.2.3 From 8ba159fed90fc221003e85c5d2d3b82ec30d81bf Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 27 Jun 2019 09:10:38 -0700 Subject: SL-11151, SL-11504 Remove update threshold logic causing hiccups and rework sky updates. Make deferred water do double transport again to match non-ALM rendering more closely. --- indra/newview/lllegacyatmospherics.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index a09f54c303..b6c46b9ff9 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -181,7 +181,6 @@ LLAtmospherics::LLAtmospherics() { /// WL PARAMS mInitialized = FALSE; - mUpdateTimer.reset(); mAmbientScale = gSavedSettings.getF32("SkyAmbientScale"); mNightColorShift = gSavedSettings.getColor3("SkyNightColorShift"); mFogColor.mV[VRED] = mFogColor.mV[VGREEN] = mFogColor.mV[VBLUE] = 0.5f; -- cgit v1.2.3 From d23bf2c16e2d36b18c920bbd42f49c47f3c58bd9 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 10 Jul 2019 13:02:09 -0700 Subject: 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. --- indra/newview/lllegacyatmospherics.cpp | 166 +++++++++------------------------ 1 file changed, 43 insertions(+), 123 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index b6c46b9ff9..d56e6bd5d6 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -204,6 +204,8 @@ void LLAtmospherics::init() LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVector3 &dir, bool isShiny) { + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + F32 saturation = 0.3f; if (isShiny && dir.mV[VZ] < -0.02f) @@ -240,17 +242,8 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVecto calcSkyColorWLVert(Pn, vars); -#if SL_11371 - if (dir.mV[VZ] < 0.4f) - { - LLColor4 col = LLColor4(llmax(mFogColor[0],0.2f), llmax(mFogColor[1],0.2f), llmax(mFogColor[2],0.22f),0.f); - col *= dir * LLVector3(0,1,0); - col += vars.hazeColor; - return col; - } -#endif - - LLColor3 sky_color = calcSkyColorWLFrag(Pn, vars); + LLColor3 sky_color = psky->gammaCorrect(vars.hazeColor * 2.0f); + if (isShiny) { F32 brightness = sky_color.brightness(); @@ -261,17 +254,19 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVecto return LLColor4(sky_color, 0.0f); } +const F32 NIGHTTIME_ELEVATION = -8.0f; // degrees +const F32 NIGHTTIME_ELEVATION_SIN = (F32)sinf(NIGHTTIME_ELEVATION*DEG_TO_RAD); + 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 = 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 distance_multiplier = vars.distance_multiplier; + F32 distance_multiplier = vars.distance_multiplier; F32 max_y = vars.max_y; LLVector4 sun_norm = vars.sun_norm; @@ -287,9 +282,6 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) Pn *= Plen; - vars.horizontalProjection[0] = LLVector2(Pn[0], Pn[2]); - vars.horizontalProjection[0] /= - 2.f * Plen; - // Set altitude if (Pn[1] > 0.f) { @@ -313,26 +305,38 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes LLColor3 light_atten = vars.light_atten; + LLColor3 light_transmittance = psky->getLightTransmittance(Plen); // Calculate relative weights LLColor3 temp2(0.f, 0.f, 0.f); - LLColor3 temp1 = vars.light_transmittance; + LLColor3 temp1 = vars.total_density; LLColor3 blue_weight = componentDiv(blue_density, temp1); LLColor3 haze_weight = componentDiv(smear(haze_density), temp1); + F32 lighty = sun_norm.mV[1]; + if(lighty < NIGHTTIME_ELEVATION_SIN) + { + lighty = -lighty; + } + // Compute sunlight from P & lightnorm (for long rays like sky) - temp2.mV[1] = llmax(F_APPROXIMATELY_ZERO, llmax(0.f, Pn[1]) * 1.0f + sun_norm[1] ); + temp2.mV[1] = llmax(F_APPROXIMATELY_ZERO, llmax(0.f, lighty)); + + if (temp2.mV[1] > 0.0000001f) + { + temp2.mV[1] = 1.f / temp2.mV[1]; + } + temp2.mV[1] = llmax(temp2.mV[1], 0.0000001f); - temp2.mV[1] = 1.f / temp2.mV[1]; - componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); + componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); + componentMultBy(sunlight, light_transmittance); - // Distance + // Distance temp2.mV[2] = Plen * density_multiplier; - // Transparency (-> temp1) - temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]);// * distance_multiplier); - + // Transparency (-> temp1) + temp1 = componentExp((temp1 * -1.f) * temp2.mV[2] * distance_multiplier); // Compute haze glow temp2.mV[0] = Pn * LLVector3(sun_norm); @@ -342,15 +346,8 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) temp2.mV[0] = llmax(temp2.mV[0], .001f); // Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) - if (glow.mV[0] > 0) // don't pow(zero,negative value), glow from 0 to 2 - { - // Higher glow.x gives dimmer glow (because next step is 1 / "angle") - temp2.mV[0] *= glow.mV[0]; - } - else - { - temp2.mV[0] = F32_MIN; - } + // Higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.mV[0] *= (glow.mV[0] > 0) ? glow.mV[0] : F32_MIN; temp2.mV[0] = pow(temp2.mV[0], glow.mV[2]); // glow.z should be negative, so we're doing a sort of (1 / "angle") function @@ -371,95 +368,16 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) // Haze color below cloud 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); - - sunlight = vars.sunlight; - temp2.mV[1] = llmax(F_APPROXIMATELY_ZERO, sun_norm[1] * 2.f); - temp2.mV[1] = 1.f / temp2.mV[1]; - componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); + LLColor3 final_atten = LLColor3::white - temp1; + final_atten.mV[0] = llmax(final_atten.mV[0], 0.0f); + final_atten.mV[1] = llmax(final_atten.mV[1], 0.0f); + final_atten.mV[2] = llmax(final_atten.mV[2], 0.0f); - // Attenuate cloud color by atmosphere - temp1 = componentSqrt(temp1); //less atmos opacity (more transparency) below clouds + // Final atmosphere additive + componentMultBy(vars.hazeColor, final_atten); // At horizon, blend high altitude sky color towards the darker color below the clouds - vars.hazeColor += componentMult(vars.hazeColorBelowCloud - vars.hazeColor, LLColor3::white - componentSqrt(temp1)); - -#if SL_11371 - if (Pn[1] < 0.f) - { - // Eric's original: - // LLColor3 dark_brown(0.143f, 0.129f, 0.114f); - LLColor3 dark_brown(0.082f, 0.076f, 0.066f); - LLColor3 brown(0.430f, 0.386f, 0.322f); - LLColor3 sky_lighting = sunlight + ambient; - F32 haze_brightness = vars.hazeColor.brightness(); - - if (Pn[1] < -0.05f) - { - vars.hazeColor = colorMix(dark_brown, brown, -Pn[1] * 0.9f) * sky_lighting * haze_brightness; - } - - if (Pn[1] > -0.1f) - { - vars.hazeColor = colorMix(LLColor3::white * haze_brightness, vars.hazeColor, fabs((Pn[1] + 0.05f) * -20.f)); - } - } -#endif - -} - -LLColor3 LLAtmospherics::calcSkyColorWLFrag(LLVector3 & Pn, AtmosphericsVars& vars) -{ - LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - - - LLColor3 res; - LLColor3 color0 = vars.hazeColor; - - if (!gPipeline.canUseWindLightShaders()) - { - res = psky->gammaCorrect(color0 * 2.0f); - } - else - { - res = color0; - } - -#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; - - static enum { - OUT_DEFAULT = 0, - OUT_SKY_BLUE = 1, - OUT_RED = 2, - OUT_PN = 3, - OUT_HAZE = 4, - } debugOut = OUT_DEFAULT; - - switch(debugOut) - { - case OUT_DEFAULT: - break; - case OUT_SKY_BLUE: - res = LLColor3(0.4f, 0.4f, 0.9f); - break; - case OUT_RED: - res = LLColor3(1.f, 0.f, 0.f); - break; - case OUT_PN: - res = LLColor3(Pn[0], Pn[1], Pn[2]); - break; - case OUT_HAZE: - res = vars.hazeColor; - break; - } -#endif // LL_RELEASE_FOR_DOWNLOAD - return res; + vars.hazeColor += componentMult(vars.hazeColorBelowCloud - vars.hazeColor, final_atten); } void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) @@ -520,10 +438,10 @@ void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) vars.blue_horizon = psky->getBlueHorizon(); vars.haze_density = psky->getHazeDensity(); vars.haze_horizon = psky->getHazeHorizon(); - vars.density_multiplier = psky->getDensityMultiplier(); + vars.density_multiplier = psky->getDensityMultiplier(); vars.distance_multiplier = psky->getDistanceMultiplier(); vars.max_y = psky->getMaxY(); - vars.sun_norm = LLEnvironment::instance().getClampedSunNorm(); + vars.sun_norm = LLEnvironment::instance().getLightDirectionCFR(); vars.sunlight = psky->getSunlightColor(); vars.ambient = psky->getAmbientColor(); vars.glow = psky->getGlow(); @@ -531,7 +449,9 @@ void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) vars.dome_radius = psky->getDomeRadius(); vars.dome_offset = psky->getDomeOffset(); vars.light_atten = psky->getLightAttenuation(vars.max_y); - vars.light_transmittance = psky->getLightTransmittance(); + vars.light_transmittance = psky->getLightTransmittance(vars.max_y); + vars.total_density = psky->getTotalDensity(); + vars.gamma = psky->getGamma(); res_color[0] = calcSkyColorInDir(vars, tosun); res_color[1] = calcSkyColorInDir(vars, perp_tosun); -- cgit v1.2.3 From 695ec5229f6c8c80625e7d445232ae5fb0011327 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 11 Jul 2019 08:33:41 -0700 Subject: Fix knock-on from touching the sky tex gen which also generated the shiny env map. --- indra/newview/lllegacyatmospherics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index d56e6bd5d6..68613be19c 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -242,7 +242,7 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVecto calcSkyColorWLVert(Pn, vars); - LLColor3 sky_color = psky->gammaCorrect(vars.hazeColor * 2.0f); + LLColor3 sky_color = isShiny ? vars.hazeColor : psky->gammaCorrect(vars.hazeColor * 2.0f); if (isShiny) { -- cgit v1.2.3 From eb9a977a36742fb052b4d92c911c37816967cd6e Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 24 Jul 2019 16:07:53 -0700 Subject: SL-11550 --- indra/newview/lllegacyatmospherics.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 68613be19c..10603cf819 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -321,22 +321,18 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) } // Compute sunlight from P & lightnorm (for long rays like sky) - temp2.mV[1] = llmax(F_APPROXIMATELY_ZERO, llmax(0.f, lighty)); - - if (temp2.mV[1] > 0.0000001f) - { - temp2.mV[1] = 1.f / temp2.mV[1]; - } - temp2.mV[1] = llmax(temp2.mV[1], 0.0000001f); + temp2.mV[1] = llmax(F_APPROXIMATELY_ZERO, llmax(0.f, Pn[1]) * 1.0f + sun_norm.mV[1] ); + temp2.mV[1] = 1.f / temp2.mV[1]; componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); - componentMultBy(sunlight, light_transmittance); + //componentMultBy(sunlight, light_transmittance); // Distance temp2.mV[2] = Plen * density_multiplier; // Transparency (-> temp1) - temp1 = componentExp((temp1 * -1.f) * temp2.mV[2] * distance_multiplier); + temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]);// * distance_multiplier); + (void)distance_multiplier; // Compute haze glow temp2.mV[0] = Pn * LLVector3(sun_norm); @@ -347,7 +343,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) // Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) // Higher glow.x gives dimmer glow (because next step is 1 / "angle") - temp2.mV[0] *= (glow.mV[0] > 0) ? glow.mV[0] : F32_MIN; + temp2.mV[0] *= glow.mV[0]; temp2.mV[0] = pow(temp2.mV[0], glow.mV[2]); // glow.z should be negative, so we're doing a sort of (1 / "angle") function @@ -374,10 +370,13 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) final_atten.mV[2] = llmax(final_atten.mV[2], 0.0f); // Final atmosphere additive - componentMultBy(vars.hazeColor, final_atten); + componentMultBy(vars.hazeColor, LLColor3::white - temp1); + + // Attenuate cloud color by atmosphere + 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(vars.hazeColorBelowCloud - vars.hazeColor, final_atten); + vars.hazeColor += componentMult(vars.hazeColorBelowCloud - vars.hazeColor, LLColor3::white - componentSqrt(temp1)); } void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) -- cgit v1.2.3 From eaf39fc5731da75807aeebecbd49a326bfcb470a Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 29 Jul 2019 10:33:02 -0700 Subject: Silence Clang warnerror about (now) unused var. --- indra/newview/lllegacyatmospherics.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 10603cf819..e68f9da1a7 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -306,6 +306,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) // this is used later for sunlight modulation at various altitudes LLColor3 light_atten = vars.light_atten; LLColor3 light_transmittance = psky->getLightTransmittance(Plen); + (void)light_transmittance; // silence Clang warn-error // Calculate relative weights LLColor3 temp2(0.f, 0.f, 0.f); -- cgit v1.2.3 From fd3cf756a0e32bec5a35a7980deeede9b7be7665 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 29 Jul 2019 12:07:51 -0700 Subject: SL-11654 Make Low graphics not gamma correct the sky colors. --- indra/newview/lllegacyatmospherics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index e68f9da1a7..37661920a3 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -242,7 +242,7 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVecto calcSkyColorWLVert(Pn, vars); - LLColor3 sky_color = isShiny ? vars.hazeColor : psky->gammaCorrect(vars.hazeColor * 2.0f); + LLColor3 sky_color = (isShiny || !gPipeline.canUseWindLightShaders()) ? vars.hazeColor : psky->gammaCorrect(vars.hazeColor * 2.0f); if (isShiny) { -- cgit v1.2.3 From 2b99edc0992d2bdf3ec065393ab169316a344d13 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 29 Jul 2019 14:00:53 -0700 Subject: SL-11373 More tweaks to CPU-generated sky cubemap color handling. --- indra/newview/lllegacyatmospherics.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 37661920a3..1660a1897e 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -242,7 +242,8 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVecto calcSkyColorWLVert(Pn, vars); - LLColor3 sky_color = (isShiny || !gPipeline.canUseWindLightShaders()) ? vars.hazeColor : psky->gammaCorrect(vars.hazeColor * 2.0f); + LLColor3 sky_color = isShiny ? vars.hazeColor : + !gPipeline.canUseWindLightShaders() ? vars.hazeColor * 2.0f : psky->gammaCorrect(vars.hazeColor * 2.0f); if (isShiny) { -- cgit v1.2.3 From 41c7523e08aab7f2bf4a040ac1c1c8a1d24babed Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 12 Aug 2019 13:44:59 -0700 Subject: SL-11676 Make sun/moon textures render on Low/Low-Mid again. Fix solar additive being present when moon was only heavenly body in sky. --- indra/newview/lllegacyatmospherics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 1660a1897e..720c7e2388 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -442,7 +442,7 @@ void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) vars.density_multiplier = psky->getDensityMultiplier(); vars.distance_multiplier = psky->getDistanceMultiplier(); vars.max_y = psky->getMaxY(); - vars.sun_norm = LLEnvironment::instance().getLightDirectionCFR(); + vars.sun_norm = LLEnvironment::instance().getSunDirectionCFR(); vars.sunlight = psky->getSunlightColor(); vars.ambient = psky->getAmbientColor(); vars.glow = psky->getGlow(); -- cgit v1.2.3 From 8960a56f531745bc2d434bdddb6c65731621f596 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 22 Aug 2019 11:19:04 -0700 Subject: SL-11776 Fix false alarming sky updates and doing expensive CPU work for same sky pixels. --- indra/newview/lllegacyatmospherics.cpp | 117 ++++++++++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 3 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 720c7e2388..a1093df7e1 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -242,8 +242,10 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVecto calcSkyColorWLVert(Pn, vars); + bool low_end = !gPipeline.canUseWindLightShaders(); + LLColor3 sky_color = isShiny ? vars.hazeColor : - !gPipeline.canUseWindLightShaders() ? vars.hazeColor * 2.0f : psky->gammaCorrect(vars.hazeColor * 2.0f); + low_end ? vars.hazeColor * 2.0f : psky->gammaCorrect(vars.hazeColor * 2.0f); if (isShiny) { @@ -443,8 +445,8 @@ void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) vars.distance_multiplier = psky->getDistanceMultiplier(); vars.max_y = psky->getMaxY(); vars.sun_norm = LLEnvironment::instance().getSunDirectionCFR(); - vars.sunlight = psky->getSunlightColor(); - vars.ambient = psky->getAmbientColor(); + vars.sunlight = psky->getSunlightColorClamped(); + vars.ambient = psky->getAmbientColorClamped(); vars.glow = psky->getGlow(); vars.cloud_shadow = psky->getCloudShadow(); vars.dome_radius = psky->getDomeRadius(); @@ -605,3 +607,112 @@ F32 azimuth(const LLVector3 &v) } return azimuth; } + +bool operator==(const AtmosphericsVars& a, const AtmosphericsVars& b) +{ + if (a.hazeColor != b.hazeColor) + { + return false; + } + + if (a.hazeColorBelowCloud != b.hazeColorBelowCloud) + { + return false; + } + + if (a.cloudColorSun != b.cloudColorSun) + { + return false; + } + + if (a.cloudColorAmbient != b.cloudColorAmbient) + { + return false; + } + + if (a.cloudDensity != b.cloudDensity) + { + return false; + } + + if (a.density_multiplier != b.density_multiplier) + { + return false; + } + + if (a.haze_horizon != b.haze_horizon) + { + return false; + } + + if (a.haze_density != b.haze_density) + { + return false; + } + + if (a.blue_horizon != b.blue_horizon) + { + return false; + } + + if (a.blue_density != b.blue_density) + { + return false; + } + + if (a.dome_offset != b.dome_offset) + { + return false; + } + + if (a.dome_radius != b.dome_radius) + { + return false; + } + + if (a.cloud_shadow != b.cloud_shadow) + { + return false; + } + + if (a.glow != b.glow) + { + return false; + } + + if (a.ambient != b.ambient) + { + return false; + } + + if (a.sunlight != b.sunlight) + { + return false; + } + + if (a.sun_norm != b.sun_norm) + { + return false; + } + + if (a.gamma != b.gamma) + { + return false; + } + + if (a.max_y != b.max_y) + { + return false; + } + + if (a.distance_multiplier != b.distance_multiplier) + { + return false; + } + + // light_atten, light_transmittance, total_density + // are ignored as they always change when the values above do + // they're just shared calc across the sky map generation to save cycles + + return true; +} -- cgit v1.2.3 From 24537889fb444315b4074195f25d91919fbea36f Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 27 Aug 2019 13:05:04 -0700 Subject: SL-11550 Restore mul by light_transmittance in CPU version of atmospherics. --- indra/newview/lllegacyatmospherics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index a1093df7e1..13d5eb96c4 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -329,7 +329,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) temp2.mV[1] = 1.f / temp2.mV[1]; componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); - //componentMultBy(sunlight, light_transmittance); + componentMultBy(sunlight, light_transmittance); // Distance temp2.mV[2] = Plen * density_multiplier; @@ -445,8 +445,8 @@ void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) vars.distance_multiplier = psky->getDistanceMultiplier(); vars.max_y = psky->getMaxY(); vars.sun_norm = LLEnvironment::instance().getSunDirectionCFR(); - vars.sunlight = psky->getSunlightColorClamped(); - vars.ambient = psky->getAmbientColorClamped(); + vars.sunlight = psky->getSunlightColor(); + vars.ambient = psky->getAmbientColor(); vars.glow = psky->getGlow(); vars.cloud_shadow = psky->getCloudShadow(); vars.dome_radius = psky->getDomeRadius(); -- cgit v1.2.3 From fd4a90858c9beb147eb312f3c41396435d389c4d Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 28 Aug 2019 21:51:22 +0300 Subject: SL-11776 [EEP] Reduced frequency of sky updates by comparing data fuzzily --- indra/newview/lllegacyatmospherics.cpp | 183 ++++++++++++++++++++++++++++----- 1 file changed, 158 insertions(+), 25 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 13d5eb96c4..fb779bb1a7 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -205,12 +205,16 @@ void LLAtmospherics::init() LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVector3 &dir, bool isShiny) { LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + return calcSkyColorInDir(psky, vars, dir, isShiny); +} +LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, AtmosphericsVars& vars, const LLVector3 &dir, bool isShiny) +{ F32 saturation = 0.3f; if (isShiny && dir.mV[VZ] < -0.02f) { - LLColor4 col = LLColor4(llmax(mFogColor[0],0.2f), llmax(mFogColor[1],0.2f), llmax(mFogColor[2],0.22f),0.f); + LLColor4 col; LLColor3 desat_fog = LLColor3(mFogColor); F32 brightness = desat_fog.brightness(); // So that shiny somewhat shows up at night. @@ -219,8 +223,8 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVecto brightness = 0.15f; desat_fog = smear(0.15f); } - LLColor3 greyscale = smear(brightness); - desat_fog = desat_fog * saturation + greyscale * (1.0f - saturation); + F32 greyscale_sat = brightness * (1.0f - saturation); + desat_fog = desat_fog * saturation + smear(greyscale_sat); if (!gPipeline.canUseWindLightShaders()) { col = LLColor4(desat_fog, 0.f); @@ -240,36 +244,34 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVecto // undo OGL_TO_CFR_ROTATION and negate vertical direction. LLVector3 Pn = LLVector3(-dir[1] , -dir[2], -dir[0]); - calcSkyColorWLVert(Pn, vars); - - bool low_end = !gPipeline.canUseWindLightShaders(); - - LLColor3 sky_color = isShiny ? vars.hazeColor : - low_end ? vars.hazeColor * 2.0f : psky->gammaCorrect(vars.hazeColor * 2.0f); + //calculates hazeColor + calcSkyColorWLVert(psky, Pn, vars); if (isShiny) { - F32 brightness = sky_color.brightness(); - LLColor3 greyscale = smear(brightness); - sky_color = sky_color * saturation + greyscale * (1.0f - saturation); + F32 brightness = vars.hazeColor.brightness(); + F32 greyscale_sat = brightness * (1.0f - saturation); + LLColor3 sky_color = vars.hazeColor * saturation + smear(greyscale_sat); sky_color *= (0.5f + 0.5f * brightness); + return LLColor4(sky_color, 0.0f); } + + bool low_end = !gPipeline.canUseWindLightShaders(); + LLColor3 sky_color = low_end ? vars.hazeColor * 2.0f : psky->gammaCorrect(vars.hazeColor * 2.0f); + return LLColor4(sky_color, 0.0f); } const F32 NIGHTTIME_ELEVATION = -8.0f; // degrees const F32 NIGHTTIME_ELEVATION_SIN = (F32)sinf(NIGHTTIME_ELEVATION*DEG_TO_RAD); -void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) +void LLAtmospherics::calcSkyColorWLVert(const LLSettingsSky::ptr_t &psky, LLVector3 & Pn, AtmosphericsVars& vars) { - LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - 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 distance_multiplier = vars.distance_multiplier; F32 max_y = vars.max_y; LLVector4 sun_norm = vars.sun_norm; @@ -316,13 +318,10 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) LLColor3 temp1 = vars.total_density; LLColor3 blue_weight = componentDiv(blue_density, temp1); + LLColor3 blue_factor = blue_horizon * blue_weight; LLColor3 haze_weight = componentDiv(smear(haze_density), temp1); + LLColor3 haze_factor = haze_horizon * haze_weight; - F32 lighty = sun_norm.mV[1]; - if(lighty < NIGHTTIME_ELEVATION_SIN) - { - lighty = -lighty; - } // Compute sunlight from P & lightnorm (for long rays like sky) temp2.mV[1] = llmax(F_APPROXIMATELY_ZERO, llmax(0.f, Pn[1]) * 1.0f + sun_norm.mV[1] ); @@ -335,8 +334,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) temp2.mV[2] = Plen * density_multiplier; // Transparency (-> temp1) - temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]);// * distance_multiplier); - (void)distance_multiplier; + temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]); // Compute haze glow temp2.mV[0] = Pn * LLVector3(sun_norm); @@ -357,7 +355,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) // Haze color above cloud - vars.hazeColor = (blue_horizon * blue_weight * (sunlight + ambient) + componentMult(haze_horizon * haze_weight, sunlight * temp2.mV[0] + ambient)); + vars.hazeColor = (blue_factor * (sunlight + ambient) + componentMult(haze_factor, sunlight * temp2.mV[0] + ambient)); // Increase ambient when there are more clouds LLColor3 tmpAmbient = ambient + (LLColor3::white - ambient) * cloud_shadow * 0.5f; @@ -366,7 +364,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) sunlight *= (1.f - cloud_shadow); // Haze color below cloud - vars.hazeColorBelowCloud = (blue_horizon * blue_weight * (sunlight + tmpAmbient) + componentMult(haze_horizon * haze_weight, sunlight * temp2.mV[0] + tmpAmbient)); + vars.hazeColorBelowCloud = (blue_factor * (sunlight + tmpAmbient) + componentMult(haze_factor, sunlight * temp2.mV[0] + tmpAmbient)); LLColor3 final_atten = LLColor3::white - temp1; final_atten.mV[0] = llmax(final_atten.mV[0], 0.0f); @@ -716,3 +714,138 @@ bool operator==(const AtmosphericsVars& a, const AtmosphericsVars& b) return true; } + +bool aproximately_equal(const F32 &a, const F32 &b, const F32 &fraction_treshold) +{ + F32 diff = fabs(a - b); + if (diff < F_APPROXIMATELY_ZERO || diff < llmax(fabs(a), fabs(b)) * fraction_treshold) + { + return true; + } + return false; +} + +bool aproximately_equal(const LLColor3 &a, const LLColor3 &b, const F32 &fraction_treshold) +{ + return aproximately_equal(a.mV[0], b.mV[0], fraction_treshold) + && aproximately_equal(a.mV[1], b.mV[1], fraction_treshold) + && aproximately_equal(a.mV[2], b.mV[2], fraction_treshold); +} + +bool aproximately_equal(const LLVector4 &a, const LLVector4 &b, const F32 &fraction_treshold) +{ + return aproximately_equal(a.mV[0], b.mV[0], fraction_treshold) + && aproximately_equal(a.mV[1], b.mV[1], fraction_treshold) + && aproximately_equal(a.mV[2], b.mV[2], fraction_treshold) + && aproximately_equal(a.mV[3], b.mV[3], fraction_treshold); +} + +bool aproximatelyEqual(const AtmosphericsVars& a, const AtmosphericsVars& b, const F32 fraction_treshold) +{ + if (!aproximately_equal(a.hazeColor, b.hazeColor, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.hazeColorBelowCloud, b.hazeColorBelowCloud, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.cloudColorSun, b.cloudColorSun, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.cloudColorAmbient, b.cloudColorAmbient, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.cloudDensity, b.cloudDensity, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.density_multiplier, b.density_multiplier, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.haze_horizon, b.haze_horizon, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.haze_density, b.haze_density, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.blue_horizon, b.blue_horizon, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.blue_density, b.blue_density, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.dome_offset, b.dome_offset, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.dome_radius, b.dome_radius, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.cloud_shadow, b.cloud_shadow, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.glow, b.glow, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.ambient, b.ambient, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.sunlight, b.sunlight, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.sun_norm, b.sun_norm, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.gamma, b.gamma, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.max_y, b.max_y, fraction_treshold)) + { + return false; + } + + if (!aproximately_equal(a.distance_multiplier, b.distance_multiplier, fraction_treshold)) + { + return false; + } + + // light_atten, light_transmittance, total_density + // are ignored as they always change when the values above do + // they're just shared calc across the sky map generation to save cycles + + return true; +} + -- cgit v1.2.3 From c5724023dd80a6c8a77d15650161e7cf67f8650e Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 28 Aug 2019 15:27:23 -0700 Subject: Work around issue with friend ops not accepting default params on Clang. --- indra/newview/lllegacyatmospherics.cpp | 62 +++++++++++++++++----------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index fb779bb1a7..d9425b702a 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -715,7 +715,7 @@ bool operator==(const AtmosphericsVars& a, const AtmosphericsVars& b) return true; } -bool aproximately_equal(const F32 &a, const F32 &b, const F32 &fraction_treshold) +bool approximatelyEqual(const F32 &a, const F32 &b, const F32 &fraction_treshold) { F32 diff = fabs(a - b); if (diff < F_APPROXIMATELY_ZERO || diff < llmax(fabs(a), fabs(b)) * fraction_treshold) @@ -725,119 +725,119 @@ bool aproximately_equal(const F32 &a, const F32 &b, const F32 &fraction_treshol return false; } -bool aproximately_equal(const LLColor3 &a, const LLColor3 &b, const F32 &fraction_treshold) +bool approximatelyEqual(const LLColor3 &a, const LLColor3 &b, const F32 &fraction_treshold) { - return aproximately_equal(a.mV[0], b.mV[0], fraction_treshold) - && aproximately_equal(a.mV[1], b.mV[1], fraction_treshold) - && aproximately_equal(a.mV[2], b.mV[2], fraction_treshold); + return approximatelyEqual(a.mV[0], b.mV[0], fraction_treshold) + && approximatelyEqual(a.mV[1], b.mV[1], fraction_treshold) + && approximatelyEqual(a.mV[2], b.mV[2], fraction_treshold); } -bool aproximately_equal(const LLVector4 &a, const LLVector4 &b, const F32 &fraction_treshold) +bool approximatelyEqual(const LLVector4 &a, const LLVector4 &b, const F32 &fraction_treshold) { - return aproximately_equal(a.mV[0], b.mV[0], fraction_treshold) - && aproximately_equal(a.mV[1], b.mV[1], fraction_treshold) - && aproximately_equal(a.mV[2], b.mV[2], fraction_treshold) - && aproximately_equal(a.mV[3], b.mV[3], fraction_treshold); + return approximatelyEqual(a.mV[0], b.mV[0], fraction_treshold) + && approximatelyEqual(a.mV[1], b.mV[1], fraction_treshold) + && approximatelyEqual(a.mV[2], b.mV[2], fraction_treshold) + && approximatelyEqual(a.mV[3], b.mV[3], fraction_treshold); } -bool aproximatelyEqual(const AtmosphericsVars& a, const AtmosphericsVars& b, const F32 fraction_treshold) +bool approximatelyEqual(const AtmosphericsVars& a, const AtmosphericsVars& b, const F32 fraction_treshold) { - if (!aproximately_equal(a.hazeColor, b.hazeColor, fraction_treshold)) + if (!approximatelyEqual(a.hazeColor, b.hazeColor, fraction_treshold)) { return false; } - if (!aproximately_equal(a.hazeColorBelowCloud, b.hazeColorBelowCloud, fraction_treshold)) + if (!approximatelyEqual(a.hazeColorBelowCloud, b.hazeColorBelowCloud, fraction_treshold)) { return false; } - if (!aproximately_equal(a.cloudColorSun, b.cloudColorSun, fraction_treshold)) + if (!approximatelyEqual(a.cloudColorSun, b.cloudColorSun, fraction_treshold)) { return false; } - if (!aproximately_equal(a.cloudColorAmbient, b.cloudColorAmbient, fraction_treshold)) + if (!approximatelyEqual(a.cloudColorAmbient, b.cloudColorAmbient, fraction_treshold)) { return false; } - if (!aproximately_equal(a.cloudDensity, b.cloudDensity, fraction_treshold)) + if (!approximatelyEqual(a.cloudDensity, b.cloudDensity, fraction_treshold)) { return false; } - if (!aproximately_equal(a.density_multiplier, b.density_multiplier, fraction_treshold)) + if (!approximatelyEqual(a.density_multiplier, b.density_multiplier, fraction_treshold)) { return false; } - if (!aproximately_equal(a.haze_horizon, b.haze_horizon, fraction_treshold)) + if (!approximatelyEqual(a.haze_horizon, b.haze_horizon, fraction_treshold)) { return false; } - if (!aproximately_equal(a.haze_density, b.haze_density, fraction_treshold)) + if (!approximatelyEqual(a.haze_density, b.haze_density, fraction_treshold)) { return false; } - if (!aproximately_equal(a.blue_horizon, b.blue_horizon, fraction_treshold)) + if (!approximatelyEqual(a.blue_horizon, b.blue_horizon, fraction_treshold)) { return false; } - if (!aproximately_equal(a.blue_density, b.blue_density, fraction_treshold)) + if (!approximatelyEqual(a.blue_density, b.blue_density, fraction_treshold)) { return false; } - if (!aproximately_equal(a.dome_offset, b.dome_offset, fraction_treshold)) + if (!approximatelyEqual(a.dome_offset, b.dome_offset, fraction_treshold)) { return false; } - if (!aproximately_equal(a.dome_radius, b.dome_radius, fraction_treshold)) + if (!approximatelyEqual(a.dome_radius, b.dome_radius, fraction_treshold)) { return false; } - if (!aproximately_equal(a.cloud_shadow, b.cloud_shadow, fraction_treshold)) + if (!approximatelyEqual(a.cloud_shadow, b.cloud_shadow, fraction_treshold)) { return false; } - if (!aproximately_equal(a.glow, b.glow, fraction_treshold)) + if (!approximatelyEqual(a.glow, b.glow, fraction_treshold)) { return false; } - if (!aproximately_equal(a.ambient, b.ambient, fraction_treshold)) + if (!approximatelyEqual(a.ambient, b.ambient, fraction_treshold)) { return false; } - if (!aproximately_equal(a.sunlight, b.sunlight, fraction_treshold)) + if (!approximatelyEqual(a.sunlight, b.sunlight, fraction_treshold)) { return false; } - if (!aproximately_equal(a.sun_norm, b.sun_norm, fraction_treshold)) + if (!approximatelyEqual(a.sun_norm, b.sun_norm, fraction_treshold)) { return false; } - if (!aproximately_equal(a.gamma, b.gamma, fraction_treshold)) + if (!approximatelyEqual(a.gamma, b.gamma, fraction_treshold)) { return false; } - if (!aproximately_equal(a.max_y, b.max_y, fraction_treshold)) + if (!approximatelyEqual(a.max_y, b.max_y, fraction_treshold)) { return false; } - if (!aproximately_equal(a.distance_multiplier, b.distance_multiplier, fraction_treshold)) + if (!approximatelyEqual(a.distance_multiplier, b.distance_multiplier, fraction_treshold)) { return false; } -- cgit v1.2.3 From 82d976a110b429a244337c6acbb0196636460034 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 29 Aug 2019 07:44:10 -0700 Subject: Remove unref'd var reintroduced in upstream merges. --- indra/newview/lllegacyatmospherics.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index d9425b702a..165ef8c797 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -262,9 +262,6 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, Atm return LLColor4(sky_color, 0.0f); } -const F32 NIGHTTIME_ELEVATION = -8.0f; // degrees -const F32 NIGHTTIME_ELEVATION_SIN = (F32)sinf(NIGHTTIME_ELEVATION*DEG_TO_RAD); - void LLAtmospherics::calcSkyColorWLVert(const LLSettingsSky::ptr_t &psky, LLVector3 & Pn, AtmosphericsVars& vars) { LLColor3 blue_density = vars.blue_density; -- cgit v1.2.3 From c4c8d2017494dc1e673b2cb09f031a1715efa0af Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 25 Feb 2020 13:23:51 -0800 Subject: SL-12574 Tweak sky to better match Windlight --- indra/newview/lllegacyatmospherics.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 165ef8c797..e061b3ad17 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -208,23 +208,25 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVecto return calcSkyColorInDir(psky, vars, dir, isShiny); } +// This cubemap is used as "environmentMap" in indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, AtmosphericsVars& vars, const LLVector3 &dir, bool isShiny) { - F32 saturation = 0.3f; + F32 sky_saturation = 0.25f; + F32 land_saturation = 0.1f; if (isShiny && dir.mV[VZ] < -0.02f) { LLColor4 col; LLColor3 desat_fog = LLColor3(mFogColor); - F32 brightness = desat_fog.brightness(); + F32 brightness = desat_fog.brightness();// NOTE: Linear brightness! // So that shiny somewhat shows up at night. if (brightness < 0.15f) { brightness = 0.15f; desat_fog = smear(0.15f); } - F32 greyscale_sat = brightness * (1.0f - saturation); - desat_fog = desat_fog * saturation + smear(greyscale_sat); + F32 greyscale_sat = brightness * (1.0f - land_saturation); + desat_fog = desat_fog * land_saturation + smear(greyscale_sat); if (!gPipeline.canUseWindLightShaders()) { col = LLColor4(desat_fog, 0.f); @@ -250,9 +252,9 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, Atm if (isShiny) { F32 brightness = vars.hazeColor.brightness(); - F32 greyscale_sat = brightness * (1.0f - saturation); - LLColor3 sky_color = vars.hazeColor * saturation + smear(greyscale_sat); - sky_color *= (0.5f + 0.5f * brightness); + F32 greyscale_sat = brightness * (1.0f - sky_saturation); + LLColor3 sky_color = vars.hazeColor * sky_saturation + smear(greyscale_sat); + //sky_color *= (0.5f + 0.5f * brightness); // SL-12574 EEP sky was too dark dark grey/blue, lighten it slightly return LLColor4(sky_color, 0.0f); } -- cgit v1.2.3 From 49239e8fe178c313771a1d8b389844761cd740ad Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 16 Mar 2020 19:43:14 -0700 Subject: SL-12574: Tweak sky cubemap to not be as dark to better match Windlight --- indra/newview/lllegacyatmospherics.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index e061b3ad17..3c675f7c4f 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -254,7 +254,8 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, Atm F32 brightness = vars.hazeColor.brightness(); F32 greyscale_sat = brightness * (1.0f - sky_saturation); LLColor3 sky_color = vars.hazeColor * sky_saturation + smear(greyscale_sat); - //sky_color *= (0.5f + 0.5f * brightness); // SL-12574 EEP sky was too dark dark grey/blue, lighten it slightly + //sky_color *= (0.5f + 0.5f * brightness); + sky_color *= (0.85f + 0.15f*brightness); // SL-12574 EEP sky is being attenuated too much; brighten it slightly until calcSkyColorWLVert() is fixed to match Windlight return LLColor4(sky_color, 0.0f); } -- cgit v1.2.3 From bb99e50b2617a67fe65a92338363c76ec400f033 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Wed, 18 Mar 2020 23:21:32 -0700 Subject: SL-12574 Add note about duplicated procedurally generated sky texture --- indra/newview/lllegacyatmospherics.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 3c675f7c4f..5e3fc8be95 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -265,6 +265,10 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, Atm return LLColor4(sky_color, 0.0f); } +// NOTE: Keep these in sync! +// indra\newview\app_settings\shaders\class1\deferred\skyV.glsl +// indra\newview\app_settings\shaders\class1\deferred\cloudsV.glsl +// indra\newview\lllegacyatmospherics.cpp void LLAtmospherics::calcSkyColorWLVert(const LLSettingsSky::ptr_t &psky, LLVector3 & Pn, AtmosphericsVars& vars) { LLColor3 blue_density = vars.blue_density; -- cgit v1.2.3 From 03e0549d573a14c32f4fc4a57e007108851e9f1f Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Wed, 18 Mar 2020 23:34:53 -0700 Subject: SL-12574 Fix environmentMap being too dark on EEP --- indra/newview/lllegacyatmospherics.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 5e3fc8be95..2bba56f646 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -254,8 +254,7 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, Atm F32 brightness = vars.hazeColor.brightness(); F32 greyscale_sat = brightness * (1.0f - sky_saturation); LLColor3 sky_color = vars.hazeColor * sky_saturation + smear(greyscale_sat); - //sky_color *= (0.5f + 0.5f * brightness); - sky_color *= (0.85f + 0.15f*brightness); // SL-12574 EEP sky is being attenuated too much; brighten it slightly until calcSkyColorWLVert() is fixed to match Windlight + //sky_color *= (0.5f + 0.5f * brightness); // SL-12574 EEP sky is being attenuated too much return LLColor4(sky_color, 0.0f); } @@ -378,11 +377,15 @@ void LLAtmospherics::calcSkyColorWLVert(const LLSettingsSky::ptr_t &psky, LLVect // Final atmosphere additive componentMultBy(vars.hazeColor, LLColor3::white - temp1); +/* + // SL-12574 + // Attenuate cloud color by atmosphere 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(vars.hazeColorBelowCloud - vars.hazeColor, LLColor3::white - componentSqrt(temp1)); +*/ } void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) -- cgit v1.2.3 From e466ab255d8bda1d1c5e27dd2291d11d53a50691 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Wed, 18 Mar 2020 23:35:17 -0700 Subject: SL-12574 Cleanup unused final_atten --- indra/newview/lllegacyatmospherics.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'indra/newview/lllegacyatmospherics.cpp') diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 2bba56f646..a2acb3efe2 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -369,11 +369,6 @@ void LLAtmospherics::calcSkyColorWLVert(const LLSettingsSky::ptr_t &psky, LLVect // Haze color below cloud vars.hazeColorBelowCloud = (blue_factor * (sunlight + tmpAmbient) + componentMult(haze_factor, sunlight * temp2.mV[0] + tmpAmbient)); - LLColor3 final_atten = LLColor3::white - temp1; - final_atten.mV[0] = llmax(final_atten.mV[0], 0.0f); - final_atten.mV[1] = llmax(final_atten.mV[1], 0.0f); - final_atten.mV[2] = llmax(final_atten.mV[2], 0.0f); - // Final atmosphere additive componentMultBy(vars.hazeColor, LLColor3::white - temp1); -- cgit v1.2.3