From 1f7f30aea4bb67bc9de9a6354085b7f0b0849617 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 11 Dec 2023 15:49:51 -0600 Subject: SL-20611 Brute force fix for water haze -- paid for by cycles saved by not drawing water twice, but needs a better long term solution. --- indra/newview/pipeline.cpp | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'indra') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f448983ac2..adad22d0a8 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -787,10 +787,8 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) resY /= res_mod; } - if (LLPipeline::sRenderTransparentWater) - { //water reflection texture - mWaterDis.allocate(resX, resY, GL_RGBA16F, true); - } + //water reflection texture (always needed as scratch space whether or not transparent water is enabled) + mWaterDis.allocate(resX, resY, GL_RGBA16F, true); if (RenderUIBuffer) { @@ -8239,7 +8237,6 @@ void LLPipeline::doAtmospherics() if (RenderDeferredAtmospheric) { - if (!sUnderWaterRender) { // copy depth buffer for use in haze shader (use water displacement map as temp storage) LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); @@ -8274,7 +8271,7 @@ void LLPipeline::doAtmospherics() LLGLSLShader& haze_shader = gHazeProgram; LL_PROFILE_GPU_ZONE("haze"); - bindDeferredShader(haze_shader, nullptr, sUnderWaterRender ? nullptr : &mWaterDis); + bindDeferredShader(haze_shader, nullptr, &mWaterDis); LLEnvironment& environment = LLEnvironment::instance(); haze_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); @@ -8300,6 +8297,32 @@ void LLPipeline::doWaterHaze() if (RenderDeferredAtmospheric) { + // copy depth buffer for use in haze shader (use water displacement map as temp storage) + { + LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); + + LLRenderTarget& src = gPipeline.mRT->screen; + LLRenderTarget& depth_src = gPipeline.mRT->deferredScreen; + LLRenderTarget& dst = gPipeline.mWaterDis; + + mRT->screen.flush(); + dst.bindTarget(); + gCopyDepthProgram.bind(); + + S32 diff_map = gCopyDepthProgram.getTextureChannel(LLShaderMgr::DIFFUSE_MAP); + S32 depth_map = gCopyDepthProgram.getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); + + gGL.getTexUnit(diff_map)->bind(&src); + gGL.getTexUnit(depth_map)->bind(&depth_src, true); + + gGL.setColorMask(false, false); + gPipeline.mScreenTriangleVB->setBuffer(); + gPipeline.mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + dst.flush(); + mRT->screen.bindTarget(); + } + LLGLEnable blend(GL_BLEND); gGL.blendFunc(LLRender::BF_ONE, LLRender::BF_SOURCE_ALPHA, LLRender::BF_ZERO, LLRender::BF_SOURCE_ALPHA); @@ -8309,7 +8332,7 @@ void LLPipeline::doWaterHaze() LLGLSLShader& haze_shader = gHazeWaterProgram; LL_PROFILE_GPU_ZONE("haze"); - bindDeferredShader(haze_shader); + bindDeferredShader(haze_shader, nullptr, &mWaterDis); haze_shader.uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, LLDrawPoolAlpha::sWaterPlane.mV); -- cgit v1.2.3