From 8890c3238ab4ae8bbf1bc123284f9c6d4db4f9d6 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 6 Feb 2019 16:42:23 -0800 Subject: SL-10478 Fix side-effects of having both sun and moon as potential directional light contributors. We pass an int to the shader indicating which to prefer instead of making per-pixel decisions and pass the moonlight color/di independently. Obsolete llsettingssky fade color which was unused elsewhere and cached for no reason. --- indra/llinventory/llsettingssky.cpp | 13 ++----------- indra/llinventory/llsettingssky.h | 3 +-- indra/llrender/llrender.cpp | 13 ++++++++++++- indra/llrender/llrender.h | 2 ++ indra/llrender/llshadermgr.cpp | 2 ++ indra/llrender/llshadermgr.h | 2 ++ .../shaders/class1/deferred/cloudsV.glsl | 4 +++- .../shaders/class1/deferred/moonF.glsl | 2 ++ .../shaders/class1/deferred/shadowUtil.glsl | 15 ++++++++------- .../app_settings/shaders/class1/deferred/skyV.glsl | 4 +++- .../shaders/class1/deferred/starsF.glsl | 1 - .../shaders/class1/windlight/moonF.glsl | 10 ++++++---- .../app_settings/shaders/class2/deferred/skyF.glsl | 4 +++- .../shaders/class2/deferred/softenLightF.glsl | 5 ++++- .../shaders/class2/windlight/atmosphericsF.glsl | 4 +++- .../shaders/class2/windlight/atmosphericsV.glsl | 4 +++- .../shaders/class2/windlight/cloudsV.glsl | 4 +++- .../shaders/class2/windlight/skyV.glsl | 4 +++- .../shaders/class3/deferred/cloudShadowF.glsl | 1 - .../shaders/class3/deferred/cloudsF.glsl | 1 - .../shaders/class3/windlight/atmosphericsF.glsl | 4 +++- .../shaders/class3/windlight/atmosphericsV.glsl | 4 +++- indra/newview/lldrawpoolterrain.cpp | 4 ++++ indra/newview/lldrawpooltree.cpp | 4 ++++ indra/newview/lldrawpoolwlsky.cpp | 1 + indra/newview/pipeline.cpp | 22 +++++++++++++++------- 26 files changed, 92 insertions(+), 45 deletions(-) diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 612c97168c..2a503664ad 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -1238,12 +1238,6 @@ LLVector3 LLSettingsSky::getMoonDirection() const return mMoonDirection; } -LLColor4U LLSettingsSky::getFadeColor() const -{ - update(); - return mFadeColor; -} - LLColor4 LLSettingsSky::getMoonAmbient() const { update(); @@ -1305,12 +1299,9 @@ void LLSettingsSky::calculateLightSettings() const mSunDiffuse = gammaCorrect(componentMult(sunlight, light_transmittance)); mSunAmbient = gammaCorrect(componentMult(tmpAmbient, light_transmittance) * 0.5); - mMoonDiffuse = gammaCorrect(componentMult(LLColor3::white, light_transmittance)); - mMoonAmbient = gammaCorrect(componentMult(LLColor3::white, light_transmittance) * 0.5f); + mMoonDiffuse = gammaCorrect(componentMult(LLColor3::white, light_transmittance) * 0.5f); + mMoonAmbient = gammaCorrect(componentMult(LLColor3::white, light_transmittance) * 0.25f); mTotalAmbient = mSunAmbient; - - mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f; - mFadeColor.setAlpha(0); } LLUUID LLSettingsSky::GetDefaultAssetId() diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 65c0f2c581..cd173a6b18 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -280,7 +280,7 @@ public: LLVector3 getSunDirection() const; LLVector3 getMoonDirection() const; - LLColor4U getFadeColor() const; + LLColor4 getMoonAmbient() const; LLColor3 getMoonDiffuse() const; LLColor4 getSunAmbient() const; @@ -347,7 +347,6 @@ private: static const F32 DOME_RADIUS; static const F32 DOME_OFFSET; - mutable LLColor4U mFadeColor; mutable LLColor4 mMoonAmbient; mutable LLColor3 mMoonDiffuse; mutable LLColor4 mSunAmbient; diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 173444f708..6e15f52866 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -895,6 +895,15 @@ void LLLightState::setDiffuse(const LLColor4& diffuse) } } +void LLLightState::setDiffuseB(const LLColor4& diffuse) +{ + if (mDiffuseB != diffuse) + { + ++gGL.mLightHash; + mDiffuseB = diffuse; + } +} + void LLLightState::setAmbient(const LLColor4& ambient) { if (mAmbient != ambient) @@ -1153,6 +1162,7 @@ void LLRender::syncLightState() LLVector3 direction[8]; LLVector4 attenuation[8]; LLVector3 diffuse[8]; + LLVector3 diffuseB[8]; for (U32 i = 0; i < 8; i++) { @@ -1162,6 +1172,7 @@ void LLRender::syncLightState() direction[i] = light->mSpotDirection; attenuation[i].set(light->mLinearAtten, light->mQuadraticAtten, light->mSpecular.mV[2], light->mSpecular.mV[3]); diffuse[i].set(light->mDiffuse.mV); + diffuseB[i].set(light->mDiffuseB.mV); } shader->uniform4fv(LLShaderMgr::LIGHT_POSITION, 8, position[0].mV); @@ -1169,8 +1180,8 @@ void LLRender::syncLightState() shader->uniform4fv(LLShaderMgr::LIGHT_ATTENUATION, 8, attenuation[0].mV); shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, 8, diffuse[0].mV); shader->uniform4fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV); - //HACK -- duplicate sunlight color for compatibility with drivers that can't deal with multiple shader objects referencing the same uniform shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV); + shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuseB[0].mV); } } diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index a79db80ebe..012a8da4ce 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -229,6 +229,7 @@ public: void enable(); void disable(); void setDiffuse(const LLColor4& diffuse); + void setDiffuseB(const LLColor4& diffuse); void setAmbient(const LLColor4& ambient); void setSpecular(const LLColor4& specular); void setPosition(const LLVector4& position); @@ -245,6 +246,7 @@ protected: S32 mIndex; bool mEnabled; LLColor4 mDiffuse; + LLColor4 mDiffuseB; LLColor4 mAmbient; LLColor4 mSpecular; LLVector4 mPosition; diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 3989c1e2e4..11e84d8785 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1352,6 +1352,8 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("sun_moon_glow_factor"); mReservedUniforms.push_back("water_edge"); + mReservedUniforms.push_back("sun_up_factor"); + mReservedUniforms.push_back("moonlight_color"); llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index ef6f33f2e5..497c3eb231 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -250,6 +250,8 @@ public: SUN_MOON_GLOW_FACTOR, WATER_EDGE_FACTOR, + SUN_UP_FACTOR, + MOONLIGHT_COLOR, END_RESERVED_UNIFORMS } eGLSLReservedUniforms; diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl index 53391da9aa..4beb334f5a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl @@ -47,6 +47,8 @@ uniform vec3 camPosLocal; uniform vec4 lightnorm; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; uniform vec4 ambient; uniform vec4 blue_horizon; uniform vec4 blue_density; @@ -94,7 +96,7 @@ void main() vec4 temp2 = vec4(0.); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index c6c12f80f8..d964ce8eee 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -35,6 +35,7 @@ out vec4 frag_data[3]; uniform vec4 color; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; uniform vec3 lumWeights; uniform float moon_brightness; uniform float minLuminance; @@ -57,6 +58,7 @@ void main() vec3 exp = vec3(1.0 - mix * moon_brightness) * 2.0 - 1.0; c.rgb = pow(c.rgb, exp); + //c.rgb *= moonlight_color.rgb; frag_data[0] = vec4(c.rgb, c.a); frag_data[1] = vec4(0.0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl index 6c509b7616..39fdd9ec44 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl @@ -44,12 +44,13 @@ uniform float spot_shadow_bias; uniform float spot_shadow_offset; uniform mat4 inv_proj; uniform vec2 screen_res; +int sun_up_factor; float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir) { stc.xyz /= stc.w; float offset = max(0.75, light_dir.z); - stc.z += offset * shadow_bias * 3.33 * bias_mul; + stc.z += offset * shadow_bias * bias_mul; stc.x = floor(stc.x*shadow_res.x + fract(stc.y*pos_screen.y*3.14159))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here @@ -85,14 +86,14 @@ float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2 float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) { + vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; + float dp_sun = max(0.0, dot(sun_dir.xyz, norm)); float dp_moon = max(0.0, dot(moon_dir.xyz, norm)); float dp_directional_light = max(dp_sun,dp_moon); dp_directional_light = clamp(dp_directional_light, 0.0, 1.0); - vec3 light_dir = (dp_moon > dp_sun) ? moon_dir : sun_dir; - vec3 offset = light_dir * (1.0-dp_directional_light); - vec3 shadow_pos = pos.xyz + (offset * shadow_bias); + vec3 shadow_pos = pos.xyz; float shadow = 0.0f; vec4 spos = vec4(shadow_pos,1.0); @@ -117,7 +118,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) float w = 1.0; w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap3, lpos, 1.0, pos_screen, light_dir)*w; + shadow += pcfShadow(shadowMap3, lpos, 0.5, pos_screen, light_dir)*w; weight += w; shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); } @@ -129,7 +130,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) float w = 1.0; w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap2, lpos, 1.0, pos_screen, light_dir)*w; + shadow += pcfShadow(shadowMap2, lpos, 0.75, pos_screen, light_dir)*w; weight += w; } @@ -140,7 +141,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) float w = 1.0; w -= max(spos.z-far_split.x, 0.0)/transition_domain.x; w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; - shadow += pcfShadow(shadowMap1, lpos, 1.0, pos_screen, light_dir)*w; + shadow += pcfShadow(shadowMap1, lpos, 0.88, pos_screen, light_dir)*w; weight += w; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl index 7c02d31d43..83dd9da091 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl @@ -39,6 +39,8 @@ uniform vec3 camPosLocal; uniform vec4 lightnorm; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; uniform vec4 ambient; uniform vec4 blue_horizon; uniform vec4 blue_density; @@ -82,7 +84,7 @@ void main() vec4 temp2 = vec4(0.); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index 67e7604e22..8a98d6a489 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -39,7 +39,6 @@ uniform sampler2D diffuseMap; uniform sampler2D altDiffuseMap; uniform float blend_factor; uniform float custom_alpha; -uniform vec4 sunlight_color; uniform float time; float twinkle(){ diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl index b66b56e0fb..947c301110 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl @@ -35,6 +35,7 @@ out vec4 frag_color; uniform vec4 color; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; uniform vec3 lumWeights; uniform float moon_brightness; uniform float minLuminance; @@ -45,8 +46,8 @@ VARYING vec2 vary_texcoord0; void main() { - vec4 moonA = texture2D(diffuseMap, vary_texcoord0.xy); - vec4 moonB = texture2D(altDiffuseMap, vary_texcoord0.xy); + vec4 moonA = texture2D(diffuseMap, vary_texcoord0.xy); + vec4 moonB = texture2D(altDiffuseMap, vary_texcoord0.xy); vec4 c = mix(moonA, moonB, blend_factor); // mix factor which blends when sunlight is brighter @@ -55,8 +56,9 @@ void main() float mix = 1.0f - dot(normalize(sunlight_color.rgb), luma_weights); vec3 exp = vec3(1.0 - mix * moon_brightness) * 2.0 - 1.0; - c.rgb = pow(c.rgb, exp); + c.rgb = pow(c.rgb, exp); + //c.rgb *= moonlight_color.rgb; - frag_color = vec4(c.rgb, c.a); + frag_color = vec4(c.rgb, c.a); } diff --git a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl index 7e2d41cf7b..26f8095dc1 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl @@ -34,6 +34,8 @@ uniform vec3 camPosLocal; uniform vec4 lightnorm; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; uniform vec4 ambient; uniform vec4 blue_horizon; uniform vec4 blue_density; @@ -112,7 +114,7 @@ void main() vec4 temp2 = vec4(0.); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 2c1cc3026f..9a159e57f0 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -57,6 +57,8 @@ uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; uniform vec3 moon_dir; +uniform int sun_up_factor; + VARYING vec2 vary_fragcoord; uniform mat4 inv_proj; @@ -91,7 +93,8 @@ void main() float da_sun = dot(norm.xyz, normalize(sun_dir.xyz)); float da_moon = dot(norm.xyz, normalize(moon_dir.xyz)); - float da = (da_sun > 0.0) ? da_sun : da_moon; + float da = (sun_up_factor == 1) ? da_sun : da_moon; + //float da = (da_sun > 0.0) ? da_sun : da_moon; da = clamp(da, 0.0, 1.0); da = pow(da, global_gamma + 0.3); diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl index 683ab794d3..efcf848ab1 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl @@ -29,6 +29,8 @@ vec3 getAtmosAttenuation(); uniform vec4 gamma; uniform vec4 lightnorm; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; uniform vec4 ambient; uniform vec4 blue_horizon; uniform vec4 blue_density; @@ -75,7 +77,7 @@ void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, vec3 temp2 = vec3(0); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; //sunlight attenuation effect (hue and brightness) due to atmosphere diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl index 86cdae8768..a26752f741 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl @@ -44,6 +44,8 @@ uniform vec3 camPosLocal; uniform vec4 lightnorm; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; uniform vec4 ambient; uniform vec4 blue_horizon; uniform vec4 blue_density; @@ -74,7 +76,7 @@ void calcAtmospherics(vec3 inPositionEye) { vec3 temp2 = vec3(0); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; //sunlight attenuation effect (hue and brightness) due to atmosphere diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl index 3e3bd929e1..fb978691da 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl @@ -46,6 +46,8 @@ uniform vec3 camPosLocal; uniform vec4 lightnorm; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; uniform vec4 ambient; uniform vec4 blue_horizon; uniform vec4 blue_density; @@ -93,7 +95,7 @@ void main() vec4 temp2 = vec4(0.); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl index f9f1eb7355..a65cc09c73 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl @@ -39,6 +39,8 @@ uniform vec3 camPosLocal; uniform vec4 lightnorm; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; uniform vec4 ambient; uniform vec4 blue_horizon; uniform vec4 blue_density; @@ -82,7 +84,7 @@ void main() vec4 temp2 = vec4(0.); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; // Sunlight attenuation effect (hue and brightness) due to atmosphere diff --git a/indra/newview/app_settings/shaders/class3/deferred/cloudShadowF.glsl b/indra/newview/app_settings/shaders/class3/deferred/cloudShadowF.glsl index 95d5b52b45..c0ba804a30 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/cloudShadowF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/cloudShadowF.glsl @@ -44,7 +44,6 @@ uniform sampler2D cloud_noise_texture_next; uniform float blend_factor; uniform vec4 cloud_pos_density1; uniform vec4 cloud_pos_density2; -uniform vec4 sunlight_color; uniform vec4 cloud_color; uniform float cloud_shadow; uniform float cloud_scale; diff --git a/indra/newview/app_settings/shaders/class3/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class3/deferred/cloudsF.glsl index c111456782..cc7a86f35c 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/cloudsF.glsl @@ -47,7 +47,6 @@ uniform sampler2D cloud_noise_texture_next; uniform float blend_factor; uniform vec4 cloud_pos_density1; uniform vec4 cloud_pos_density2; -uniform vec4 sunlight_color; uniform vec4 cloud_color; uniform float cloud_shadow; uniform float cloud_scale; diff --git a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl index a1b67fc31e..852c2478bc 100644 --- a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl @@ -29,6 +29,8 @@ vec3 getAtmosAttenuation(); uniform vec4 gamma; uniform vec4 lightnorm; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; uniform vec4 ambient; uniform vec4 blue_horizon; uniform vec4 blue_density; @@ -69,7 +71,7 @@ void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, vec3 temp2 = vec3(0); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; //sunlight attenuation effect (hue and brightness) due to atmosphere diff --git a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl index 3270c243a4..9bd75cf118 100644 --- a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl +++ b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl @@ -38,6 +38,8 @@ uniform vec3 camPosLocal; uniform vec4 lightnorm; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; uniform vec4 ambient; uniform vec4 blue_horizon; uniform vec4 blue_density; @@ -63,7 +65,7 @@ void calcAtmospherics(vec3 inPositionEye) { vec3 temp2 = vec3(0); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; //sunlight attenuation effect (hue and brightness) due to atmosphere diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp index e716214d72..ba2b00ee4e 100644 --- a/indra/newview/lldrawpoolterrain.cpp +++ b/indra/newview/lldrawpoolterrain.cpp @@ -48,6 +48,7 @@ #include "pipeline.h" #include "llviewershadermgr.h" #include "llrender.h" +#include "llenvironment.h" const F32 DETAIL_SCALE = 1.f/16.f; int DebugDetailMap = 0; @@ -259,6 +260,9 @@ void LLDrawPoolTerrain::beginShadowPass(S32 pass) LLFacePool::beginRenderPass(pass); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gDeferredShadowProgram.bind(); + + LLEnvironment& environment = LLEnvironment::instance(); + gDeferredShadowProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); } void LLDrawPoolTerrain::endShadowPass(S32 pass) diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp index 81b0c8b1bb..aa8812ab9d 100644 --- a/indra/newview/lldrawpooltree.cpp +++ b/indra/newview/lldrawpooltree.cpp @@ -38,6 +38,7 @@ #include "llrender.h" #include "llviewercontrol.h" #include "llviewerregion.h" +#include "llenvironment.h" S32 LLDrawPoolTree::sDiffTex = 0; static LLGLSLShader* shader = NULL; @@ -178,7 +179,10 @@ void LLDrawPoolTree::beginShadowPass(S32 pass) glPolygonOffset(gSavedSettings.getF32("RenderDeferredTreeShadowOffset"), gSavedSettings.getF32("RenderDeferredTreeShadowBias")); + LLEnvironment& environment = LLEnvironment::instance(); + gDeferredTreeShadowProgram.bind(); + gDeferredTreeShadowProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); gDeferredTreeShadowProgram.setMinimumAlpha(0.5f); } diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index acf2a6ea6e..313e74d5cd 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -701,6 +701,7 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() F32 moon_brightness = (float)psky->getMoonBrightness(); moon_shader->uniform1f(LLShaderMgr::MOON_BRIGHTNESS, moon_brightness); + moon_shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, gSky.mVOSkyp->getMoon().getColor().mV); moon_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV); moon_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 82c59282d5..49b39eb067 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6351,9 +6351,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) gGL.setAmbientLightColor(ambient); } - bool sun_up = environment.getIsSunUp(); - bool moon_up = environment.getIsMoonUp(); - bool sun_is_primary = sun_up || !moon_up; + bool sun_up = environment.getIsSunUp(); // Light 0 = Sun or Moon (All objects) { @@ -6379,15 +6377,15 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) } mMoonDiffuse.clamp(); - LLColor4 light_diffuse = sun_is_primary ? mSunDiffuse : mMoonDiffuse; - LLVector4 light_dir = sun_is_primary ? mSunDir : mMoonDir; + LLVector4 light_dir = sun_up ? mSunDir : mMoonDir; - mHWLightColors[0] = light_diffuse; + mHWLightColors[0] = mSunDiffuse; LLLightState* light = gGL.getLight(0); light->setPosition(light_dir); - light->setDiffuse(light_diffuse); + light->setDiffuse(mSunDiffuse); + light->setDiffuseB(mMoonDiffuse); light->setAmbient(LLColor4::black); light->setSpecular(LLColor4::black); light->setConstantAttenuation(1.f); @@ -8757,6 +8755,10 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) LL_RECORD_BLOCK_TIME(FTM_ATMOSPHERICS); bindDeferredShader(soften_shader); + + LLEnvironment& environment = LLEnvironment::instance(); + soften_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); + { LLGLDepthTest depth(GL_FALSE); LLGLDisable blend(GL_BLEND); @@ -9870,6 +9872,8 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera stop_glerror(); + LLEnvironment& environment = LLEnvironment::instance(); + LLVertexBuffer::unbind(); { @@ -9880,6 +9884,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera else { gDeferredShadowProgram.bind(); + gDeferredShadowProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); } gGL.diffuseColor4f(1,1,1,1); @@ -9911,6 +9916,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gDeferredShadowProgram.unbind(); renderGeomShadow(shadow_cam); gDeferredShadowProgram.bind(); + gDeferredShadowProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); } else { @@ -9921,6 +9927,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA); gDeferredShadowAlphaMaskProgram.bind(); gDeferredShadowAlphaMaskProgram.uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); + gDeferredShadowAlphaMaskProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | @@ -9935,6 +9942,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera mask = mask & ~LLVertexBuffer::MAP_TEXTURE_INDEX; gDeferredTreeShadowProgram.bind(); + gDeferredTreeShadowProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); renderMaskedObjects(LLRenderPass::PASS_NORMSPEC_MASK, mask); renderMaskedObjects(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, mask); renderMaskedObjects(LLRenderPass::PASS_SPECMAP_MASK, mask); -- cgit v1.2.3 From 5bdc941b431ffd7757897d7982ebcfbf01119f09 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 7 Feb 2019 08:40:10 -0800 Subject: Fix apply of model matrix expecting upstream code to be in the correct matrix mode (which was not true as the assert on same fired). --- indra/newview/lldrawpool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index 00493c83df..b7504b16bf 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -449,10 +449,10 @@ void LLRenderPass::applyModelMatrix(const LLDrawInfo& params) if (params.mModelMatrix != gGLLastMatrix) { gGLLastMatrix = params.mModelMatrix; + gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.loadMatrix(gGLModelView); if (params.mModelMatrix) { - llassert(gGL.getMatrixMode() == LLRender::MM_MODELVIEW); gGL.multMatrix((GLfloat*) params.mModelMatrix->mMatrix); } gPipeline.mMatrixOpCount++; -- cgit v1.2.3 From 4952736a063b674f5a91904686920b11b0e04b69 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 7 Feb 2019 11:06:03 -0800 Subject: SL-10486 Use brighter moon texture for both default and blank moon texture ids in picker. --- indra/llinventory/llsettingssky.cpp | 2 +- indra/newview/llpaneleditsky.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 2a503664ad..72a3c7b01c 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -140,7 +140,7 @@ const std::string LLSettingsSky::SETTING_SKY_ICE_LEVEL("ice_level"); const LLUUID LLSettingsSky::DEFAULT_ASSET_ID("eb3a7080-831f-9f37-10f0-7b1f9ea4043c"); static const LLUUID DEFAULT_SUN_ID("32bfbcea-24b1-fb9d-1ef9-48a28a63730f"); // dataserver -static const LLUUID DEFAULT_MOON_ID("db13b827-7e6a-7ace-bed4-4419ee00984d"); // dataserver +static const LLUUID DEFAULT_MOON_ID("d07f6eed-b96a-47cd-b51d-400ad4a1c428"); // dataserver static const LLUUID DEFAULT_CLOUD_ID("1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b"); const std::string LLSettingsSky::SETTING_LEGACY_HAZE("legacy_haze"); diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp index b011522728..bbd1beb246 100644 --- a/indra/newview/llpaneleditsky.cpp +++ b/indra/newview/llpaneleditsky.cpp @@ -451,7 +451,7 @@ BOOL LLPanelSettingsSkySunMoonTab::postBuild() getChild(FIELD_SKY_MOON_ROTATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonRotationChanged(); }); getChild(FIELD_SKY_MOON_IMAGE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonImageChanged(); }); getChild(FIELD_SKY_MOON_IMAGE)->setDefaultImageAssetID(LLSettingsSky::GetDefaultMoonTextureId()); - getChild(FIELD_SKY_MOON_IMAGE)->setBlankImageAssetID(LLUUID::null); + getChild(FIELD_SKY_MOON_IMAGE)->setBlankImageAssetID(LLSettingsSky::GetDefaultMoonTextureId()); getChild(FIELD_SKY_MOON_IMAGE)->setAllowNoTexture(TRUE); getChild(FIELD_SKY_MOON_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonScaleChanged(); }); getChild(FIELD_SKY_MOON_BRIGHTNESS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonBrightnessChanged(); }); -- cgit v1.2.3 From 90f9078d1f931774b5a6e866e26f4e0294f1e2d1 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 7 Feb 2019 16:00:21 -0800 Subject: SL-10486, SL-10501, SL-10487 Make moon texture from default daycycle the default moon texture id and use it for the default and blank assets in the picker. Fix handling of MM_TEXTURE to correctly detect when texture units outside the range 0-3 are used with texture matrix ops to prevent mem overwrite bug and/or asserts. --- indra/llinventory/llsettingssky.cpp | 11 +---------- indra/llinventory/llsettingssky.h | 3 +-- indra/llrender/llrender.cpp | 7 +++++++ indra/newview/lldrawpoolavatar.cpp | 7 ++++--- indra/newview/llweb.cpp | 11 ++++------- 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 612c97168c..48352d685b 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -140,7 +140,7 @@ const std::string LLSettingsSky::SETTING_SKY_ICE_LEVEL("ice_level"); const LLUUID LLSettingsSky::DEFAULT_ASSET_ID("eb3a7080-831f-9f37-10f0-7b1f9ea4043c"); static const LLUUID DEFAULT_SUN_ID("32bfbcea-24b1-fb9d-1ef9-48a28a63730f"); // dataserver -static const LLUUID DEFAULT_MOON_ID("db13b827-7e6a-7ace-bed4-4419ee00984d"); // dataserver +static const LLUUID DEFAULT_MOON_ID("d07f6eed-b96a-47cd-b51d-400ad4a1c428"); // dataserver static const LLUUID DEFAULT_CLOUD_ID("1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b"); const std::string LLSettingsSky::SETTING_LEGACY_HAZE("legacy_haze"); @@ -1238,12 +1238,6 @@ LLVector3 LLSettingsSky::getMoonDirection() const return mMoonDirection; } -LLColor4U LLSettingsSky::getFadeColor() const -{ - update(); - return mFadeColor; -} - LLColor4 LLSettingsSky::getMoonAmbient() const { update(); @@ -1308,9 +1302,6 @@ void LLSettingsSky::calculateLightSettings() const mMoonDiffuse = gammaCorrect(componentMult(LLColor3::white, light_transmittance)); mMoonAmbient = gammaCorrect(componentMult(LLColor3::white, light_transmittance) * 0.5f); mTotalAmbient = mSunAmbient; - - mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f; - mFadeColor.setAlpha(0); } LLUUID LLSettingsSky::GetDefaultAssetId() diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 65c0f2c581..cd173a6b18 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -280,7 +280,7 @@ public: LLVector3 getSunDirection() const; LLVector3 getMoonDirection() const; - LLColor4U getFadeColor() const; + LLColor4 getMoonAmbient() const; LLColor3 getMoonDiffuse() const; LLColor4 getSunAmbient() const; @@ -347,7 +347,6 @@ private: static const F32 DOME_RADIUS; static const F32 DOME_OFFSET; - mutable LLColor4U mFadeColor; mutable LLColor4 mMoonAmbient; mutable LLColor3 mMoonDiffuse; mutable LLColor4 mSunAmbient; diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 173444f708..de04ea601a 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1477,6 +1477,13 @@ void LLRender::matrixMode(U32 mode) { if (mode == MM_TEXTURE) { + U32 tex_index = gGL.getCurrentTexUnitIndex(); + // the shaders don't actually reference anything beyond texture_matrix0/1 + if (tex_index > 3) + { + LL_WARNS_ONCE("render") << "Cannot use texture matrix with texture unit " << tex_index << " forcing texture matrix 3!" << LL_ENDL; + tex_index = 3; + } mode = MM_TEXTURE0 + gGL.getCurrentTexUnitIndex(); } diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index eaf5b7dd68..9fa76c0d97 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -1999,13 +1999,14 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow) if (face->mTextureMatrix && vobj->mTexAnimMode) { + // we don't support tex matrix ops on anything but texture_matrix0 and texture_matrix1 + // if you hit this assert, you most likely need to fix your content + llassert(gGL.getCurrentTexUnitIndex() <= 1); + gGL.matrixMode(LLRender::MM_TEXTURE); gGL.loadMatrix((F32*) face->mTextureMatrix->mMatrix); - buff->setBuffer(data_mask); buff->drawRange(LLRender::TRIANGLES, start, end, count, offset); - - gGL.matrixMode(LLRender::MM_TEXTURE); gGL.loadIdentity(); } diff --git a/indra/newview/llweb.cpp b/indra/newview/llweb.cpp index 768db047a4..2760ebd1df 100644 --- a/indra/newview/llweb.cpp +++ b/indra/newview/llweb.cpp @@ -268,12 +268,9 @@ bool LLWeb::useExternalBrowser(const std::string &url) boost::match_results matches; return !(boost::regex_search(uri_string, matches, pattern)); } - else - { - boost::regex pattern = boost::regex("^mailto:", boost::regex::perl | boost::regex::icase); - boost::match_results matches; - return boost::regex_search(url, matches, pattern); - } - return false; + + boost::regex pattern = boost::regex("^mailto:", boost::regex::perl | boost::regex::icase); + boost::match_results matches; + return boost::regex_search(url, matches, pattern); #endif } -- cgit v1.2.3 From 9f2a0d2a082495ce878f0eb0d7348b181939d348 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 8 Feb 2019 10:17:39 -0800 Subject: SL-10415 Another pass at playing with shadow_offset/bias to balance between peter-panning and shadow acne while sun and/or moon are near the horizon. --- .../shaders/class1/deferred/shadowUtil.glsl | 38 ++++++++---------- .../shaders/class2/deferred/softenLightF.glsl | 15 +++++--- indra/newview/pipeline.cpp | 45 ++++++---------------- 3 files changed, 36 insertions(+), 62 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl index 39fdd9ec44..e762871ba1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl @@ -39,20 +39,18 @@ uniform vec2 proj_shadow_res; uniform mat4 shadow_matrix[6]; uniform vec4 shadow_clip; uniform float shadow_bias; - +uniform float shadow_offset; uniform float spot_shadow_bias; uniform float spot_shadow_offset; uniform mat4 inv_proj; uniform vec2 screen_res; -int sun_up_factor; +uniform int sun_up_factor; -float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir) +float pcfShadow(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir) { stc.xyz /= stc.w; - float offset = max(0.75, light_dir.z); - stc.z += offset * shadow_bias * bias_mul; - - stc.x = floor(stc.x*shadow_res.x + fract(stc.y*pos_screen.y*3.14159))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here + stc.z += shadow_bias * bias_mul* 2.0; + stc.x = floor(stc.x*shadow_res.x + fract(stc.y*pos_screen.y*pos_screen.x))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here float cs = shadow2D(shadowMap, stc.xyz).x; float shadow = cs * 4.0; @@ -62,7 +60,7 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float bias_mul, vec2 pos_sc shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - return shadow*0.125; + return shadow * 0.125; } float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2 pos_screen) @@ -86,23 +84,18 @@ float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2 float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) { + float shadow = 0.0f; vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; float dp_sun = max(0.0, dot(sun_dir.xyz, norm)); float dp_moon = max(0.0, dot(moon_dir.xyz, norm)); - float dp_directional_light = max(dp_sun,dp_moon); + float dp_directional_light = (sun_up_factor == 1) ? dp_sun : dp_moon; dp_directional_light = clamp(dp_directional_light, 0.0, 1.0); vec3 shadow_pos = pos.xyz; - - float shadow = 0.0f; - vec4 spos = vec4(shadow_pos,1.0); - - // if we know this point is facing away from the sun then we know it's in shadow without having to do a squirrelly shadow-map lookup - if (dp_directional_light <= 0.0) - { - return 0.0; - } + vec3 offset = abs(light_dir.xyz) * (1.0 - dp_directional_light* 0.8); + shadow_pos += offset; + vec4 spos = vec4(shadow_pos.xyz, 1.0); if (spos.z > -shadow_clip.w) { @@ -118,7 +111,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) float w = 1.0; w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap3, lpos, 0.5, pos_screen, light_dir)*w; + shadow += pcfShadow(shadowMap3, norm, lpos, 4.0, pos_screen, light_dir)*w; weight += w; shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); } @@ -130,7 +123,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) float w = 1.0; w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap2, lpos, 0.75, pos_screen, light_dir)*w; + shadow += pcfShadow(shadowMap2, norm, lpos, 2.0, pos_screen, light_dir)*w; weight += w; } @@ -141,7 +134,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) float w = 1.0; w -= max(spos.z-far_split.x, 0.0)/transition_domain.x; w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; - shadow += pcfShadow(shadowMap1, lpos, 0.88, pos_screen, light_dir)*w; + shadow += pcfShadow(shadowMap1, norm, lpos, 1.0, pos_screen, light_dir)*w; weight += w; } @@ -152,14 +145,13 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) float w = 1.0; w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; - shadow += pcfShadow(shadowMap0, lpos, 1.0, pos_screen, light_dir)*w; + shadow += pcfShadow(shadowMap0, norm, lpos, 1.0, pos_screen, light_dir)*w; weight += w; } shadow /= weight; } - shadow = min(dp_directional_light, shadow); return shadow; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 9a159e57f0..8bc9add5cf 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -91,10 +91,9 @@ void main() float envIntensity = norm.z; norm.xyz = getNorm(tc); // unpack norm - float da_sun = dot(norm.xyz, normalize(sun_dir.xyz)); - float da_moon = dot(norm.xyz, normalize(moon_dir.xyz)); + float da_sun = dot(norm.xyz, sun_dir.xyz); + float da_moon = dot(norm.xyz, moon_dir.xyz); float da = (sun_up_factor == 1) ? da_sun : da_moon; - //float da = (da_sun > 0.0) ? da_sun : da_moon; da = clamp(da, 0.0, 1.0); da = pow(da, global_gamma + 0.3); @@ -109,7 +108,7 @@ void main() vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; scol_ambocc = pow(scol_ambocc, vec2(global_gamma + 0.3)); - float scol = max(scol_ambocc.r, diffuse.a); + float scol = max(scol_ambocc.r, diffuse.a); float ambocc = scol_ambocc.g; vec3 sunlit; @@ -119,7 +118,8 @@ void main() calcFragAtmospherics(pos.xyz, ambocc, sunlit, amblit, additive, atten); - float ambient = dot(norm.xyz, sun_dir.xyz); + float ambient = da; + ambient *= 0.5; ambient *= ambient; ambient = (1.0-ambient); @@ -127,7 +127,7 @@ void main() col.rgb = amblit; col.rgb *= min(ambient, max(scol, 0.5)); - col += (sunlit * da) * scol; + col += sunlit * da * scol; col *= diffuse.rgb; @@ -165,6 +165,9 @@ void main() col = fogged.rgb; bloom = fogged.a; #endif + +//col.rgb = vec3(scol); +//col.rgb = vec3(da * scol); } frag_color.rgb = col; frag_color.a = bloom; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 49b39eb067..0898b0d53d 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6075,9 +6075,7 @@ void LLPipeline::setupAvatarLights(bool for_edit) LLEnvironment& environment = LLEnvironment::instance(); LLSettingsSky::ptr_t psky = environment.getCurrentSky(); - bool sun_up = environment.getIsSunUp(); - bool moon_up = environment.getIsMoonUp(); - bool sun_is_primary = sun_up || !moon_up; + bool sun_up = environment.getIsSunUp(); if (for_edit) { @@ -6113,13 +6111,13 @@ void LLPipeline::setupAvatarLights(bool for_edit) } else if (gAvatarBacklight) // Always true (unless overridden in a devs .ini) { - LLVector3 light_dir = sun_is_primary ? LLVector3(mSunDir) : LLVector3(mMoonDir); + LLVector3 light_dir = sun_up ? LLVector3(mSunDir) : LLVector3(mMoonDir); LLVector3 opposite_pos = -light_dir; LLVector3 orthog_light_pos = light_dir % LLVector3::z_axis; LLVector4 backlight_pos = LLVector4(lerp(opposite_pos, orthog_light_pos, 0.3f), 0.0f); backlight_pos.normalize(); - LLColor4 light_diffuse = sun_is_primary ? mSunDiffuse : mMoonDiffuse; + LLColor4 light_diffuse = sun_up ? mSunDiffuse : mMoonDiffuse; LLColor4 backlight_diffuse(1.f - light_diffuse.mV[VRED], 1.f - light_diffuse.mV[VGREEN], 1.f - light_diffuse.mV[VBLUE], 1.f); F32 max_component = 0.001f; @@ -6377,7 +6375,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) } mMoonDiffuse.clamp(); - LLVector4 light_dir = sun_up ? mSunDir : mMoonDir; + LLVector4 light_dir = sun_up ? mSunDir : mMoonDir; mHWLightColors[0] = mSunDiffuse; @@ -8594,32 +8592,14 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) vert[1].set(-1,-3,0); vert[2].set(3,1,0); - const LLEnvironment& environment = LLEnvironment::instance(); - - bool sun_up = environment.getIsSunUp(); - bool moon_up = environment.getIsMoonUp(); - - { - setupHWLights(NULL); //to set mSun/MoonDir; - glh::vec4f tc(mSunDir.mV); - mat.mult_matrix_vec(tc); + setupHWLights(NULL); //to set mSun/MoonDir; - glh::vec4f tc_moon(mMoonDir.mV); - mTransformedMoonDir.set(tc_moon.v); - mTransformedMoonDir.normalize(); + glh::vec4f tc(mSunDir.mV); + mat.mult_matrix_vec(tc); + mTransformedSunDir.set(tc.v); - bool sun_is_primary = sun_up || !moon_up; - if (sun_is_primary) - { - mTransformedSunDir.set(tc.v); - mTransformedSunDir.normalize(); - } - else - { - mTransformedSunDir.set(tc_moon.v); - mTransformedSunDir.normalize(); - } - } + glh::vec4f tc_moon(mMoonDir.mV); + mTransformedMoonDir.set(tc_moon.v); gGL.pushMatrix(); gGL.loadIdentity(); @@ -10633,9 +10613,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) bool sun_up = environment.getIsSunUp(); bool moon_up = environment.getIsMoonUp(); - bool sun_is_primary = sun_up || !moon_up; - bool ignore_shadows = (sun_is_primary && (mSunDiffuse == LLColor4::black)) - || (moon_up && (mMoonDiffuse == LLColor4::black)) + bool ignore_shadows = (sun_up && (mSunDiffuse == LLColor4::black)) + || (moon_up && (mMoonDiffuse == LLColor4::black)) || !(sun_up || moon_up); if (ignore_shadows) -- cgit v1.2.3 From c909e496fd1a0710e5349441ef4e3cae5ff98de6 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 8 Feb 2019 12:43:27 -0800 Subject: SL-10501 Remove assert and replace with warning when rigged mesh tries to use tex anim on tex index > 1. --- indra/newview/lldrawpoolavatar.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 9fa76c0d97..3e1d78e6df 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -1999,16 +1999,24 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow) if (face->mTextureMatrix && vobj->mTexAnimMode) { - // we don't support tex matrix ops on anything but texture_matrix0 and texture_matrix1 - // if you hit this assert, you most likely need to fix your content - llassert(gGL.getCurrentTexUnitIndex() <= 1); + U32 tex_index = gGL.getCurrentTexUnitIndex(); + if (tex_index <= 1) + { + gGL.matrixMode(LLRender::MM_TEXTURE); + gGL.loadMatrix((F32*) face->mTextureMatrix->mMatrix); + } + else + { + LL_WARNS_ONCE("render") << "Cannot use tex anim of tex index " << tex_index << " ignoring!" << LL_ENDL; + } - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.loadMatrix((F32*) face->mTextureMatrix->mMatrix); buff->setBuffer(data_mask); buff->drawRange(LLRender::TRIANGLES, start, end, count, offset); - gGL.loadIdentity(); - + + if (tex_index <= 1) + { + gGL.loadIdentity(); + } } else { -- cgit v1.2.3 From 0a7bc35335666cc310ef900d4e4144c658b92522 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 8 Feb 2019 13:19:45 -0800 Subject: Replace funcs dropped in merge. --- indra/llrender/llrender.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index de04ea601a..dc9affb596 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -895,6 +895,15 @@ void LLLightState::setDiffuse(const LLColor4& diffuse) } } +void LLLightState::setDiffuseB(const LLColor4& diffuse) +{ + if (mDiffuseB != diffuse) + { + ++gGL.mLightHash; + mDiffuseB = diffuse; + } +} + void LLLightState::setAmbient(const LLColor4& ambient) { if (mAmbient != ambient) @@ -1153,6 +1162,7 @@ void LLRender::syncLightState() LLVector3 direction[8]; LLVector4 attenuation[8]; LLVector3 diffuse[8]; + LLVector3 diffuseB[8]; for (U32 i = 0; i < 8; i++) { @@ -1162,6 +1172,7 @@ void LLRender::syncLightState() direction[i] = light->mSpotDirection; attenuation[i].set(light->mLinearAtten, light->mQuadraticAtten, light->mSpecular.mV[2], light->mSpecular.mV[3]); diffuse[i].set(light->mDiffuse.mV); + diffuseB[i].set(light->mDiffuseB.mV); } shader->uniform4fv(LLShaderMgr::LIGHT_POSITION, 8, position[0].mV); @@ -1169,8 +1180,8 @@ void LLRender::syncLightState() shader->uniform4fv(LLShaderMgr::LIGHT_ATTENUATION, 8, attenuation[0].mV); shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, 8, diffuse[0].mV); shader->uniform4fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV); - //HACK -- duplicate sunlight color for compatibility with drivers that can't deal with multiple shader objects referencing the same uniform shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV); + shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuseB[0].mV); } } -- cgit v1.2.3