diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 8b969d81a6..26e2901968 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -353,7 +353,7 @@ protected: virtual validation_list_t getValidationList() const = 0; // Apply any settings that need special handling. - virtual void applySpecial(void *) { }; + virtual void applySpecial(void *, bool force = false) { }; virtual parammapping_t getParameterMap() const { return parammapping_t(); } diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 7e4fb054ef..39fb7ce60e 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -1326,26 +1326,13 @@ void LLSettingsSky::calculateLightSettings() const componentMultBy(sunlight, componentExp((light_atten * -1.f) * lighty)); componentMultBy(sunlight, light_transmittance); - //F32 max_color = llmax(sunlight.mV[0], sunlight.mV[1], sunlight.mV[2]); - //if (max_color > 1.0f) - //{ - // sunlight *= 1.0f/max_color; - //} - //increase ambient when there are more clouds LLColor3 tmpAmbient = ambient + (smear(1.f) - ambient) * cloud_shadow * 0.5; - componentMultBy(tmpAmbient, light_transmittance); - - //tmpAmbient = LLColor3::clamp(tmpAmbient, getGamma(), 1.0f); - //max_color = llmax(tmpAmbient.mV[0], tmpAmbient.mV[1], tmpAmbient.mV[2]); - //if (max_color > 1.0f) - //{ - // tmpAmbient *= 1.0f/max_color; - //} //brightness of surface both sunlight and ambient mSunDiffuse = sunlight; mSunAmbient = tmpAmbient; + F32 haze_horizon = getHazeHorizon(); sunlight *= 1.0 - cloud_shadow; @@ -1360,12 +1347,11 @@ void LLSettingsSky::calculateLightSettings() const LLColor3 moonlight_b(0.66f, 0.66f, 1.2f); // scotopic ambient value componentMultBy(moonlight, componentExp((light_atten * -1.f) * lighty)); - //clampColor(moonlight, getGamma(), 1.0f); mMoonDiffuse = componentMult(moonlight, light_transmittance) * moon_brightness; - mMoonAmbient = componentMult(moonlight_b, light_transmittance) * 0.0125f; + mMoonAmbient = moonlight_b * 0.0125f; - mTotalAmbient = mSunAmbient; + mTotalAmbient = ambient; } LLUUID LLSettingsSky::GetDefaultAssetId() diff --git a/indra/llrender/llglcommonfunc.h b/indra/llrender/llglcommonfunc.h index f1f8ff7bc4..e6d3755755 100644 --- a/indra/llrender/llglcommonfunc.h +++ b/indra/llrender/llglcommonfunc.h @@ -1,5 +1,5 @@ /** -* @file llphoenixfunc.h +* @file llglcommonfunc.h * @brief File include common opengl code snippets * * $LicenseInfo:firstyear=2003&license=viewerlgpl$ diff --git a/indra/llrender/llgltexture.h b/indra/llrender/llgltexture.h index 8d906751a5..8e340fcb44 100644 --- a/indra/llrender/llgltexture.h +++ b/indra/llrender/llgltexture.h @@ -1,5 +1,5 @@ /** - * @file llglviewertexture.h + * @file llgltexture.h * @brief Object for managing opengl textures * * $LicenseInfo:firstyear=2012&license=viewerlgpl$ diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 023172c844..fafecd57cc 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -274,20 +274,16 @@ void main() #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_EMISSIVE) final_color.a = diffuse_linear.a; #endif + final_color.a = max(final_color.a, emissive_brightness); -#if !defined(HAS_NORMAL_MAP) - final_color.a = 0.0f; -#endif - - vec4 final_specular = spec; - final_specular.a = specular_color.a; -#ifdef HAS_SPECULAR_MAP - final_specular.a *= norm.a; -#endif - vec4 final_normal = vec4(encode_normal(normalize(tnorm)), env_intensity, 0.0); -#ifdef HAS_SPECULAR_MAP + vec4 final_specular = spec; + + final_specular.a = specular_color.a; + +#if HAS_SPECULAR_MAP + final_specular.a *= norm.a; final_normal.z *= spec.a; #endif diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl index 4460ef905b..e5f1e11180 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl @@ -121,7 +121,7 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou temp2.x += .25; temp2.x *= sun_moon_glow_factor; - + vec4 amb_color = ambient_color; //increase ambient when there are more clouds diff --git a/indra/newview/llinventoryicon.cpp b/indra/newview/llinventoryicon.cpp index cae33cf84e..a6dd9269b3 100644 --- a/indra/newview/llinventoryicon.cpp +++ b/indra/newview/llinventoryicon.cpp @@ -207,6 +207,6 @@ LLInventoryType::EIconName LLInventoryIcon::assignWearableIcon(U32 misc_flag) LLInventoryType::EIconName LLInventoryIcon::assignSettingsIcon(U32 misc_flag) { - LLSettingsType::type_e settings_type = LLSettingsType::fromInventoryFlags(misc_flag); - return LLSettingsType::getIconName(settings_type); + LLSettingsType::type_e settings_type = LLSettingsType::fromInventoryFlags(misc_flag); + return LLSettingsType::getIconName(settings_type); } diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index a1093df7e1..165ef8c797 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,31 @@ 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,27 +315,23 @@ 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] ); 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); - (void)distance_multiplier; + temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]); // Compute haze glow temp2.mV[0] = Pn * LLVector3(sun_norm); @@ -357,7 +352,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 +361,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); @@ -445,8 +440,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(); @@ -716,3 +711,138 @@ bool operator==(const AtmosphericsVars& a, const AtmosphericsVars& b) return true; } + +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) + { + return true; + } + return false; +} + +bool approximatelyEqual(const LLColor3 &a, const LLColor3 &b, const F32 &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 approximatelyEqual(const LLVector4 &a, const LLVector4 &b, const F32 &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 approximatelyEqual(const AtmosphericsVars& a, const AtmosphericsVars& b, const F32 fraction_treshold) +{ + if (!approximatelyEqual(a.hazeColor, b.hazeColor, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.hazeColorBelowCloud, b.hazeColorBelowCloud, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.cloudColorSun, b.cloudColorSun, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.cloudColorAmbient, b.cloudColorAmbient, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.cloudDensity, b.cloudDensity, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.density_multiplier, b.density_multiplier, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.haze_horizon, b.haze_horizon, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.haze_density, b.haze_density, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.blue_horizon, b.blue_horizon, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.blue_density, b.blue_density, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.dome_offset, b.dome_offset, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.dome_radius, b.dome_radius, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.cloud_shadow, b.cloud_shadow, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.glow, b.glow, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.ambient, b.ambient, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.sunlight, b.sunlight, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.sun_norm, b.sun_norm, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.gamma, b.gamma, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(a.max_y, b.max_y, fraction_treshold)) + { + return false; + } + + if (!approximatelyEqual(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; +} + diff --git a/indra/newview/lllegacyatmospherics.h b/indra/newview/lllegacyatmospherics.h index cdfcead7a4..03c8efb91a 100644 --- a/indra/newview/lllegacyatmospherics.h +++ b/indra/newview/lllegacyatmospherics.h @@ -207,6 +207,8 @@ public: } friend bool operator==(const AtmosphericsVars& a, const AtmosphericsVars& b); + // returns true if values are within treshold of each other. + friend bool approximatelyEqual(const AtmosphericsVars& a, const AtmosphericsVars& b, const F32 fraction_treshold); LLColor3 hazeColor; LLColor3 hazeColorBelowCloud; @@ -256,10 +258,11 @@ public: void setWind ( const LLVector3& wind ) { mWind = wind.length(); } LLColor4 calcSkyColorInDir(AtmosphericsVars& vars, const LLVector3& dir, bool isShiny = false); + LLColor4 calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, AtmosphericsVars& vars, const LLVector3& dir, bool isShiny = false); protected: - void calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars); + void calcSkyColorWLVert(const LLSettingsSky::ptr_t &psky, LLVector3 & Pn, AtmosphericsVars& vars); LLColor3 getHazeColor(LLSettingsSky::ptr_t psky, AtmosphericsVars& vars, F32 costheta, F32 cloud_shadow); LLHaze mHaze; diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 11bb732be8..bbee94287d 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -663,7 +663,7 @@ void LLSettingsVOSky::updateSettings() gSky.setMoonScale(getMoonScale()); } -void LLSettingsVOSky::applySpecial(void *ptarget) +void LLSettingsVOSky::applySpecial(void *ptarget, bool force) { LLGLSLShader *shader = (LLGLSLShader *)ptarget; @@ -671,46 +671,38 @@ void LLSettingsVOSky::applySpecial(void *ptarget) if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); - shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); + shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); } else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); - LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); - vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta()); - shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV); + LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); + vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta()); + shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV); - LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - LLColor4 sunDiffuse = psky->getSunlightColor(); - LLColor4 moonDiffuse = psky->getMoonlightColor(); + LLColor4 sunDiffuse = psky->getSunlightColor(); + LLColor4 moonDiffuse = psky->getMoonlightColor(); - F32 max_color = llmax(sunDiffuse.mV[0], sunDiffuse.mV[1], sunDiffuse.mV[2]); - if (max_color > 1.f) - { - sunDiffuse *= 1.f/max_color; - } - sunDiffuse.clamp(); + shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, sunDiffuse.mV); + shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, moonDiffuse.mV); - max_color = llmax(moonDiffuse.mV[0], moonDiffuse.mV[1], moonDiffuse.mV[2]); - if (max_color > 1.f) - { - moonDiffuse *= 1.f/max_color; - } - moonDiffuse.clamp(); - - shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, sunDiffuse.mV); - shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, moonDiffuse.mV); - - LLColor4 cloud_color(psky->getCloudColor(), 1.0); - shader->uniform4fv(LLShaderMgr::CLOUD_COLOR, 1, cloud_color.mV); + LLColor4 cloud_color(psky->getCloudColor(), 1.0); + shader->uniform4fv(LLShaderMgr::CLOUD_COLOR, 1, cloud_color.mV); } - - shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength); + + LLColor4 ambient(getTotalAmbient()); + shader->uniform4fv(LLShaderMgr::AMBIENT, 1, ambient.mV); + + shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, getIsSunUp() ? 1 : 0); + shader->uniform1f(LLShaderMgr::SUN_MOON_GLOW_FACTOR, getSunMoonGlowFactor()); + shader->uniform1f(LLShaderMgr::DENSITY_MULTIPLIER, getDensityMultiplier()); + shader->uniform1f(LLShaderMgr::DISTANCE_MULTIPLIER, getDistanceMultiplier()); F32 g = getGamma(); F32 display_gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); @@ -904,13 +896,13 @@ LLSD LLSettingsVOWater::convertToLegacy(const LLSettingsWater::ptr_t &pwater) } //------------------------------------------------------------------------- //------------------------------------------------------------------------- -void LLSettingsVOWater::applySpecial(void *ptarget) +void LLSettingsVOWater::applySpecial(void *ptarget, bool force) { LLGLSLShader *shader = (LLGLSLShader *)ptarget; LLEnvironment& env = LLEnvironment::instance(); - if (shader->mShaderGroup == LLGLSLShader::SG_WATER) + if (force || (shader->mShaderGroup == LLGLSLShader::SG_WATER)) { F32 water_height = env.getWaterHeight(); diff --git a/indra/newview/llsettingsvo.h b/indra/newview/llsettingsvo.h index 6f105c9d61..1f29013ecf 100644 --- a/indra/newview/llsettingsvo.h +++ b/indra/newview/llsettingsvo.h @@ -102,7 +102,7 @@ public: bool isAdvanced() const { return m_isAdvanced; } - virtual void updateShader(LLGLSLShader* shader) { applySpecial(shader); } + virtual void updateShader(LLGLSLShader* shader) { applySpecial(shader, true); } protected: LLSettingsVOSky(); @@ -112,7 +112,7 @@ protected: virtual void updateSettings() override; - virtual void applySpecial(void *) override; + virtual void applySpecial(void *, bool) override; virtual parammapping_t getParameterMap() const override; @@ -136,13 +136,13 @@ public: static LLSD convertToLegacy(const ptr_t &); - virtual void updateShader(LLGLSLShader* shader) { applySpecial(shader); } + virtual void updateShader(LLGLSLShader* shader) { applySpecial(shader, true); } protected: LLSettingsVOWater(); virtual void updateSettings() override; - virtual void applySpecial(void *) override; + virtual void applySpecial(void *, bool) override; virtual parammapping_t getParameterMap() const override; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index b41f8c143a..4546e199c3 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -1100,6 +1100,11 @@ public: virtual bool earlyFail(LLViewerOctreeGroup* base_group) { + if (LLPipeline::sReflectionRender) + { + return false; + } + LLSpatialGroup* group = (LLSpatialGroup*)base_group; group->checkOcclusion(); diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 19299f55a2..ba2ba71e46 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -83,6 +83,8 @@ namespace LLTrace::BlockTimerStatHandle FTM_VOSKY_UPDATEFORCED("VOSky Update Forced"); F32Seconds UPDATE_EXPRY(0.25f); + + const F32 UPDATE_MIN_DELTA_THRESHOLD = 0.0005f; } /*************************************** SkyTex @@ -498,8 +500,7 @@ void LLVOSky::init() for (S32 tile = 0; tile < NUM_TILES; ++tile) { initSkyTextureDirs(side, tile); - createSkyTexture(m_atmosphericsVars, side, tile, mSkyTex); - createSkyTexture(m_atmosphericsVars, side, tile, mShinyTex, true); + createSkyTexture(m_atmosphericsVars, side, tile); } mSkyTex[side].create(1.0f); mShinyTex[side].create(1.0f); @@ -647,8 +648,10 @@ void LLVOSky::initSkyTextureDirs(const S32 side, const S32 tile) } } -void LLVOSky::createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 tile, LLSkyTex* tex, bool is_shiny) +void LLVOSky::createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 tile) { + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + S32 tile_x = tile % NUM_TILES_X; S32 tile_y = tile / NUM_TILES_X; @@ -660,7 +663,8 @@ void LLVOSky::createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 { for (x = tile_x_pos; x < (tile_x_pos + sTileResX); ++x) { - tex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(vars, tex[side].getDir(x, y), is_shiny), x, y); + mSkyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(psky, vars, mSkyTex[side].getDir(x, y), false), x, y); + mShinyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(psky, vars, mShinyTex[side].getDir(x, y), true), x, y); } } } @@ -710,8 +714,6 @@ bool LLVOSky::updateSky() return TRUE; } - bool is_alm_wl_sky = gPipeline.canUseWindLightShaders(); - static S32 next_frame = 0; const S32 total_no_tiles = NUM_CUBEMAP_FACES * NUM_TILES; const S32 cycle_frame_no = total_no_tiles + 1; @@ -737,7 +739,7 @@ bool LLVOSky::updateSky() LL_RECORD_BLOCK_TIME(FTM_VOSKY_CALC); calc(); - bool same_atmospherics = m_lastAtmosphericsVars == m_atmosphericsVars; + bool same_atmospherics = approximatelyEqual(m_lastAtmosphericsVars, m_atmosphericsVars, UPDATE_MIN_DELTA_THRESHOLD); mNeedUpdate = mNeedUpdate || !same_atmospherics; @@ -754,6 +756,8 @@ bool LLVOSky::updateSky() LL_RECORD_BLOCK_TIME(FTM_VOSKY_UPDATEFORCED); LLSkyTex::stepCurrent(); + bool is_alm_wl_sky = gPipeline.canUseWindLightShaders(); + int tex = mSkyTex[0].getWhich(TRUE); for (int side = 0; side < NUM_CUBEMAP_FACES; side++) @@ -807,14 +811,19 @@ bool LLVOSky::updateSky() } mCubeMapUpdateStage = -1; } + // run 0 to 5 faces, each face in own frame else if (mCubeMapUpdateStage >= 0 && mCubeMapUpdateStage < NUM_CUBEMAP_FACES) { LL_RECORD_BLOCK_TIME(FTM_VOSKY_CREATETEXTURES); S32 side = mCubeMapUpdateStage; - for (int tile = 0; tile < NUM_TILES; tile++) + // CPU hungry part, createSkyTexture() is math heavy + // Prior to EEP it was mostly per tile, but since EPP it is per face. + // This still can be optimized further + // (i.e. potentially can be made per tile again, can be moved to thread + // instead of executing per face, or may be can be moved to shaders) + for (S32 tile = 0; tile < NUM_TILES; tile++) { - createSkyTexture(m_atmosphericsVars, side, tile, mSkyTex); - createSkyTexture(m_atmosphericsVars, side, tile, mShinyTex, true); + createSkyTexture(m_atmosphericsVars, side, tile); } mCubeMapUpdateStage++; } diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index b1a01a9366..fc577ab5f8 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -302,7 +302,7 @@ protected: void updateDirections(void); void initSkyTextureDirs(const S32 side, const S32 tile); - void createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 tile, LLSkyTex* tex, bool is_shiny = false); + void createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 tile); LLPointer mSunTexturep[2]; LLPointer mMoonTexturep[2]; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 6d75d5ee53..a70309bdd4 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -123,6 +123,7 @@ #include "llenvironment.h" #include "llenvironment.h" +#include "llsettingsvo.h" #ifdef _DEBUG // Debug indices is disabled for now for debug performance - djs 4/24/02 @@ -2514,11 +2515,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl sCull->clear(); - bool to_texture = LLPipeline::sUseOcclusion > 1 && - !hasRenderType(LLPipeline::RENDER_TYPE_HUD) && - LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && - gPipeline.canUseVertexShaders() && - sRenderGlow; + bool to_texture = LLPipeline::sUseOcclusion > 1 && gPipeline.canUseVertexShaders(); if (to_texture) { @@ -2568,7 +2565,10 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); } - camera.disableUserClipPlane(); + if (!sReflectionRender) + { + camera.disableUserClipPlane(); + } for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) @@ -2592,6 +2592,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl if(vo_part) { bool do_occlusion_cull = can_use_occlusion && use_occlusion && !gUseWireframe && 0 > water_clip /* && !gViewerWindow->getProgressView()->getVisible()*/; + do_occlusion_cull &= !sReflectionRender; vo_part->cull(camera, do_occlusion_cull); } } @@ -2631,18 +2632,12 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl sCull->pushDrawable(gSky.mVOWLSkyp->mDrawable); } -// not currently enabled as it causes reflection/distortion map -// rendering to occur every frame instead of periodically for visible near water -#if PRECULL_WATER_OBJECTS bool render_water = !sReflectionRender && (hasRenderType(LLPipeline::RENDER_TYPE_WATER) || hasRenderType(LLPipeline::RENDER_TYPE_VOIDWATER)); if (render_water) { LLWorld::getInstance()->precullWaterObjects(camera, sCull, render_water); } -#endif - - gGL.matrixMode(LLRender::MM_PROJECTION); gGL.popMatrix(); @@ -8615,21 +8610,19 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); - shader.uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, mSunDiffuse.mV); - shader.uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); - - - LLEnvironment& environment = LLEnvironment::instance(); - LLColor4 ambient(environment.getCurrentSky()->getTotalAmbient()); - shader.uniform4fv(LLShaderMgr::AMBIENT, 1, ambient.mV); - shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); - shader.uniform1f(LLShaderMgr::SUN_MOON_GLOW_FACTOR, environment.getCurrentSky()->getSunMoonGlowFactor()); - if (shader.getUniformLocation(LLShaderMgr::DEFERRED_NORM_MATRIX) >= 0) { glh::matrix4f norm_mat = get_current_modelview().inverse().transpose(); shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, FALSE, norm_mat.m); } + + shader.uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, mSunDiffuse.mV); + shader.uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); + + LLEnvironment& environment = LLEnvironment::instance(); + LLSettingsSky::ptr_t sky = environment.getCurrentSky(); + + static_cast(sky.get())->updateShader(&shader); } LLColor3 pow3f(LLColor3 v, F32 f) @@ -9495,7 +9488,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) S32 detail = RenderReflectionDetail; F32 water_height = gAgent.getRegion()->getWaterHeight(); - F32 camera_height = camera_in.getOrigin().mV[2]; + F32 camera_height = camera_in.getOrigin().mV[VZ]; F32 distance_to_water = (water_height < camera_height) ? (camera_height - water_height) : (water_height - camera_height); LLVector3 reflection_offset = LLVector3(0, 0, distance_to_water * 2.0f); @@ -9530,7 +9523,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) glh::matrix4f current = get_current_modelview(); - if (!LLViewerCamera::getInstance()->cameraUnderWater()) + if (!camera_is_underwater) { //generate planar reflection map LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER0; @@ -9639,8 +9632,6 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) LLPipeline::RENDER_TYPE_GROUND, END_RENDER_TYPES); - bool camera_is_underwater = LLViewerCamera::getInstance()->cameraUnderWater(); - // intentionally inverted so that distortion map contents (objects under the water when we're above it) // will properly include water fog effects LLPipeline::sUnderWaterRender = !camera_is_underwater; @@ -9691,14 +9682,6 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) clip_plane.disable(); } - // SL-11370 prevent Low/Low-Mid graphics from rendering distortion map contents it should not - if (!canUseWindLightShaders()) - { - clearRenderTypeMask(LLPipeline::RENDER_TYPE_PARTICLES, END_RENDER_TYPES); - clearRenderTypeMask(LLPipeline::RENDER_TYPE_AVATAR, END_RENDER_TYPES); - clearRenderTypeMask(LLPipeline::RENDER_TYPE_VOLUME, END_RENDER_TYPES); - } - updateCull(camera, mRefractedObjects, water_clip, &plane); stateSort(camera, mRefractedObjects); renderGeom(camera); diff --git a/indra/newview/skins/default/xui/de/floater_adjust_environment.xml b/indra/newview/skins/default/xui/de/floater_adjust_environment.xml new file mode 100644 index 0000000000..776a866077 --- /dev/null +++ b/indra/newview/skins/default/xui/de/floater_adjust_environment.xml @@ -0,0 +1,24 @@ + + + + + + +