diff options
author | Jonathan "Geenz" Goodman <geenz@geenzo.com> | 2023-04-12 14:50:14 -0700 |
---|---|---|
committer | Jonathan "Geenz" Goodman <geenz@geenzo.com> | 2023-04-12 14:50:14 -0700 |
commit | 58df456675f37146d9a6cdaaf75c0f2b93f234c6 (patch) | |
tree | 2d90a62dac8785faf3aa4d1fe7601633414d8d61 /indra | |
parent | d839bfe43a8a35c64906551c8ac7de3e42cd86f5 (diff) |
Fixed DoF
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llrender/llglslshader.cpp | 1 | ||||
-rw-r--r-- | indra/newview/pipeline.cpp | 71 | ||||
-rw-r--r-- | indra/newview/pipeline.h | 2 |
3 files changed, 30 insertions, 44 deletions
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 8f06ef4a42..d213aa05ed 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -1091,7 +1091,6 @@ S32 LLGLSLShader::bindTexture(S32 uniform, LLRenderTarget* texture, bool depth, if (uniform < 0 || uniform >= (S32)mTexture.size()) { - //LL_SHADER_UNIFORM_ERRS() << "Uniform out of range: " << uniform << LL_ENDL; return -1; } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 572d388b15..db477f64e3 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7098,7 +7098,7 @@ void LLPipeline::copyScreenSpaceReflections(LLRenderTarget* src, LLRenderTarget* } } -void LLPipeline::renderGlow(LLRenderTarget* src, LLRenderTarget* dst) { +void LLPipeline::generateGlow(LLRenderTarget* src) { if (sRenderGlow) { LL_PROFILE_GPU_ZONE("glow"); @@ -7325,7 +7325,6 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { if (dof_enabled) { LL_PROFILE_GPU_ZONE("dof"); - LLGLSLShader* shader = &gDeferredPostProgram; LLGLDisable blend(GL_BLEND); // depth of field focal plane calculations @@ -7433,12 +7432,11 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { gDeferredCoFProgram.bind(); - S32 channel = gDeferredCoFProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); - gDeferredCoFProgram.bindTexture(channel, src); - - channel = gDeferredCoFProgram.enableTexture(LLShaderMgr::DEFERRED_DEPTH, mRT->deferredScreen.getUsage()); - gDeferredCoFProgram.bindTexture(channel, &mRT->deferredScreen, true); + gDeferredCoFProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, LLTexUnit::TFO_POINT); + gDeferredCoFProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true); + gDeferredCoFProgram.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); + gDeferredCoFProgram.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); gDeferredCoFProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, dst->getWidth(), dst->getHeight()); gDeferredCoFProgram.uniform1f(LLShaderMgr::DOF_FOCAL_DISTANCE, -subject_distance / 1000.f); gDeferredCoFProgram.uniform1f(LLShaderMgr::DOF_BLUR_CONSTANT, blur_constant); @@ -7449,7 +7447,6 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - gDeferredCoFProgram.unbind(); mRT->deferredLight.flush(); } @@ -7462,54 +7459,43 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { glViewport(0, 0, dof_width, dof_height); gGL.setColorMask(true, false); - shader = &gDeferredPostProgram; - bindDeferredShader(*shader); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); - if (channel > -1) - { - mRT->deferredLight.bindTexture(0, channel); - } + gDeferredPostProgram.bind(); + gDeferredPostProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, &mRT->deferredLight, LLTexUnit::TFO_POINT); - shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); - shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); + gDeferredPostProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, dst->getWidth(), dst->getHeight()); + gDeferredPostProgram.uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); + gDeferredPostProgram.uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - unbindDeferredShader(*shader); + gDeferredPostProgram.unbind(); + src->flush(); gGL.setColorMask(true, true); } { // combine result based on alpha - { - dst->bindTarget(); - glViewport(0, 0, dst->getWidth(), dst->getHeight()); - } + dst->bindTarget(); + glViewport(0, 0, dst->getWidth(), dst->getHeight()); - shader = &gDeferredDoFCombineProgram; - bindDeferredShader(*shader); + gDeferredDoFCombineProgram.bind(); + gDeferredDoFCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, LLTexUnit::TFO_POINT); + gDeferredDoFCombineProgram.bindTexture(LLShaderMgr::DEFERRED_LIGHT, &mRT->deferredLight, LLTexUnit::TFO_POINT); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); - if (channel > -1) - { - src->bindTexture(0, channel); - } - - shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); - shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); - shader->uniform1f(LLShaderMgr::DOF_WIDTH, (dof_width - 1) / (F32)src->getWidth()); - shader->uniform1f(LLShaderMgr::DOF_HEIGHT, (dof_height - 1) / (F32)src->getHeight()); + gDeferredDoFCombineProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, dst->getWidth(), dst->getHeight()); + gDeferredDoFCombineProgram.uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); + gDeferredDoFCombineProgram.uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); + gDeferredDoFCombineProgram.uniform1f(LLShaderMgr::DOF_WIDTH, (dof_width - 1) / (F32)src->getWidth()); + gDeferredDoFCombineProgram.uniform1f(LLShaderMgr::DOF_HEIGHT, (dof_height - 1) / (F32)src->getHeight()); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); - unbindDeferredShader(*shader); + gDeferredDoFCombineProgram.unbind(); - { - dst->flush(); - } + dst->flush(); } } else @@ -7554,13 +7540,14 @@ void LLPipeline::renderFinalize() LLVertexBuffer::unbind(); } - renderGlow(&mPostMap, &mRT->screen); // We don't actually write to the screen buffer here. Should probably pass in mGlow[2] as our destination. + generateGlow(&mPostMap); - renderDoF(&mPostMap, &mRT->screen); + combineGlow(&mPostMap, &mRT->screen); - applyFXAA(&mRT->screen, &mPostMap); + renderDoF(&mRT->screen, &mPostMap); + + applyFXAA(&mPostMap, &mRT->screen); - combineGlow(&mPostMap, &mRT->screen); // Present the screen target. diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 072ae2bf14..ed9e2dc452 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -139,7 +139,7 @@ public: void generateLuminance(LLRenderTarget* src, LLRenderTarget* dst); void generateExposure(LLRenderTarget* src, LLRenderTarget* dst); void gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst); - void renderGlow(LLRenderTarget* src, LLRenderTarget* dst); + void generateGlow(LLRenderTarget* src); void applyFXAA(LLRenderTarget* src, LLRenderTarget* dst); void renderDoF(LLRenderTarget* src, LLRenderTarget* dst); void copyRenderTarget(LLRenderTarget* src, LLRenderTarget* dst); |