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/newview/pipeline.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'indra/newview/pipeline.cpp') 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 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. --- indra/newview/pipeline.cpp | 45 ++++++++++++--------------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) (limited to 'indra/newview/pipeline.cpp') 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