diff options
author | Dave Parks <davep@lindenlab.com> | 2022-09-28 19:14:00 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2022-09-28 19:14:00 -0500 |
commit | 2e499bcc40871b6a68700203cc83fe7d81c79c24 (patch) | |
tree | 5204d535fb875bc65f2278aa1be19ad1da54fd73 /indra | |
parent | 2f082bb4ee433cba857499559dbfb30886fd0fb4 (diff) |
SL-18190 Prune srgb_to_linear from atmosphericsFuncs.glsl
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llmath/v3color.h | 18 | ||||
-rw-r--r-- | indra/llrender/llrender.cpp | 4 | ||||
-rw-r--r-- | indra/llrender/llshadermgr.cpp | 3 | ||||
-rw-r--r-- | indra/llrender/llshadermgr.h | 7 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl | 28 | ||||
-rw-r--r-- | indra/newview/llsettingsvo.cpp | 4 |
6 files changed, 39 insertions, 25 deletions
diff --git a/indra/llmath/v3color.h b/indra/llmath/v3color.h index 43a632408c..c3c6ae2242 100644 --- a/indra/llmath/v3color.h +++ b/indra/llmath/v3color.h @@ -484,13 +484,23 @@ inline const LLColor3 srgbColor3(const LLColor3 &a) { return srgbColor; } -inline const LLColor3 linearColor3(const LLColor3 &a) { +inline const LLColor3 linearColor3(const F32* v) { LLColor3 linearColor; - linearColor.mV[0] = sRGBtoLinear(a.mV[0]); - linearColor.mV[1] = sRGBtoLinear(a.mV[1]); - linearColor.mV[2] = sRGBtoLinear(a.mV[2]); + linearColor.mV[0] = sRGBtoLinear(v[0]); + linearColor.mV[1] = sRGBtoLinear(v[1]); + linearColor.mV[2] = sRGBtoLinear(v[2]); return linearColor; } +template<class T> +inline const LLColor3 linearColor3(const T& a) { + return linearColor3(a.mV); +} + +template<class T> +inline const LLVector3 linearColor3v(const T& a) { + return LLVector3(linearColor3(a.mV).mV); +} + #endif diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 6e659641fe..c7eb4613c1 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -979,6 +979,10 @@ void LLRender::syncLightState() shader->uniform4fv(LLShaderMgr::AMBIENT, 1, mAmbientLightColor.mV); shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV); shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuse_b[0].mV); + + shader->uniform3fv(LLShaderMgr::AMBIENT_LINEAR, 1, linearColor3(mAmbientLightColor).mV); + shader->uniform3fv(LLShaderMgr::SUNLIGHT_LINEAR, 1, linearColor3(diffuse[0]).mV); + shader->uniform3fv(LLShaderMgr::MOONLIGHT_LINEAR, 1, linearColor3(diffuse_b[0]).mV); } } diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index c817a59189..8807433d80 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1231,9 +1231,12 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("sunlight_color"); mReservedUniforms.push_back("ambient_color"); mReservedUniforms.push_back("blue_horizon"); + mReservedUniforms.push_back("blue_horizon_linear"); mReservedUniforms.push_back("blue_density"); + mReservedUniforms.push_back("blue_density_linear"); mReservedUniforms.push_back("haze_horizon"); mReservedUniforms.push_back("haze_density"); + mReservedUniforms.push_back("haze_density_linear"); mReservedUniforms.push_back("cloud_shadow"); mReservedUniforms.push_back("density_multiplier"); mReservedUniforms.push_back("distance_multiplier"); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 4d32a62ca6..b803a8b129 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -85,8 +85,8 @@ public: BUMP_MAP, // "bumpMap" BUMP_MAP2, // "bumpMap2" ENVIRONMENT_MAP, // "environmentMap" - REFLECTION_PROBES, // "reflectionProbes" - IRRADIANCE_PROBES, // "irradianceProbes" + REFLECTION_PROBES, // "reflectionProbes" + IRRADIANCE_PROBES, // "irradianceProbes" CLOUD_NOISE_MAP, // "cloud_noise_texture" CLOUD_NOISE_MAP_NEXT, // "cloud_noise_texture_next" FULLBRIGHT, // "fullbright" @@ -94,9 +94,12 @@ public: SUNLIGHT_COLOR, // "sunlight_color" AMBIENT, // "ambient_color" BLUE_HORIZON, // "blue_horizon" + BLUE_HORIZON_LINEAR, // "blue_horizon_linear" BLUE_DENSITY, // "blue_density" + BLUE_DENSITY_LINEAR, // "blue_density_linear" HAZE_HORIZON, // "haze_horizon" HAZE_DENSITY, // "haze_density" + HAZE_DENSITY_LINEAR, // "haze_density_linear" CLOUD_SHADOW, // "cloud_shadow" DENSITY_MULTIPLIER, // "density_multiplier" DISTANCE_MULTIPLIER, // "distance_multiplier" diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl index 516550be1c..3d6c15fe55 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl @@ -23,23 +23,21 @@ * $/LicenseInfo$ */ -vec3 srgb_to_linear(vec3 col); - uniform vec4 lightnorm; uniform vec4 sunlight_color; -vec3 sunlight_linear = srgb_to_linear(sunlight_color.rgb); +uniform vec3 sunlight_linear; uniform vec4 moonlight_color; -vec3 moonlight_linear = srgb_to_linear(moonlight_color.rgb); +uniform vec3 moonlight_linear; uniform int sun_up_factor; uniform vec4 ambient_color; -vec3 ambient_linear = srgb_to_linear(ambient_color.rgb); +uniform vec3 ambient_linear; uniform vec4 blue_horizon; -vec3 blue_horizon_linear = srgb_to_linear(blue_horizon.rgb); +uniform vec3 blue_horizon_linear; uniform vec4 blue_density; -vec3 blue_density_linear = srgb_to_linear(blue_density.rgb); +uniform vec3 blue_density_linear; uniform float haze_horizon; uniform float haze_density; -vec3 haze_density_linear = srgb_to_linear(vec3(haze_density)); +uniform float haze_density_linear; uniform float cloud_shadow; uniform float density_multiplier; uniform float distance_multiplier; @@ -150,13 +148,6 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao) { -#if 0 - calcAtmosphericVars(inPositionEye, light_dir, 1.0, sunlit, amblit, additive, atten, false); - sunlit = srgb_to_linear(sunlit)*2.25; - amblit = srgb_to_linear(amblit)*0.15; - additive = srgb_to_linear(additive); - atten = srgb_to_linear(atten); -#else vec3 rel_pos = inPositionEye; //(TERRAIN) limit altitude @@ -168,15 +159,15 @@ void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 light_dir, float ambFact // sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes - vec3 light_atten = (blue_density_linear + (haze_density_linear * 0.25)) * (density_multiplier * max_y); + vec3 light_atten = (blue_density_linear + vec3(haze_density_linear * 0.25)) * (density_multiplier * max_y); // I had thought blue_density and haze_density should have equal weighting, // but attenuation due to haze_density tends to seem too strong - vec3 combined_haze_linear = blue_density_linear + haze_density_linear; + vec3 combined_haze_linear = blue_density_linear + vec3(haze_density_linear); vec3 combined_haze = blue_density.rgb + vec3(haze_density); vec3 blue_weight = blue_density_linear / combined_haze_linear; - vec3 haze_weight = haze_density_linear / combined_haze_linear; + vec3 haze_weight = vec3(haze_density_linear) / combined_haze_linear; //(TERRAIN) compute sunlight from lightnorm y component. Factor is roughly cosecant(sun elevation) (for short rays like terrain) float above_horizon_factor = 1.0 / max(1e-6, lightnorm.y); @@ -234,5 +225,4 @@ void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 light_dir, float ambFact sunlit *= 0.8; amblit *= 0.05; additive *= 0.25; -#endif } diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index fd1e69b9d3..a5a8ec4a93 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -723,6 +723,10 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force) shader->uniform1f(LLShaderMgr::GAMMA, g); shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, display_gamma); + + shader->uniform3fv(LLShaderMgr::BLUE_HORIZON_LINEAR, linearColor3v(getBlueHorizon())); + shader->uniform3fv(LLShaderMgr::BLUE_DENSITY_LINEAR, linearColor3v(getBlueDensity())); + shader->uniform1f(LLShaderMgr::HAZE_DENSITY_LINEAR, sRGBtoLinear(getHazeDensity())); } LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const |