diff options
author | Dave Parks <davep@lindenlab.com> | 2011-11-04 16:42:00 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2011-11-04 16:42:00 -0500 |
commit | 785dcfe6d496bd44730b6ba0004614b2c6d04c6a (patch) | |
tree | 1622d0835730b794d9dcacf6e890f7d76e0cbff4 /indra/newview/pipeline.cpp | |
parent | 8a8e9ccdb67e7e8a492a4fe1505407ebe128ee18 (diff) |
SH-2652 Even faster depth of field
Diffstat (limited to 'indra/newview/pipeline.cpp')
-rw-r--r-- | indra/newview/pipeline.cpp | 120 |
1 files changed, 77 insertions, 43 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 85899b5ad6..8ae7e97f4a 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6595,68 +6595,102 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) blur_constant /= 1000.f; //convert to meters for shader F32 magnification = focal_length/(subject_distance-focal_length); - mDeferredLight.bindTarget(); - shader = &gDeferredCoFProgram; + { //build diffuse+bloom+CoF + mDeferredLight.bindTarget(); + shader = &gDeferredCoFProgram; - bindDeferredShader(*shader); - - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage()); - if (channel > -1) - { - mScreen.bindTexture(0, channel); - } + bindDeferredShader(*shader); - if (multisample) - { //bloom has already been added, bind black - channel = shader->enableTexture(LLShaderMgr::DEFERRED_BLOOM); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage()); if (channel > -1) { - gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sBlackImagep); + mScreen.bindTexture(0, channel); + } + + if (multisample) + { //bloom has already been added, bind black + channel = shader->enableTexture(LLShaderMgr::DEFERRED_BLOOM); + if (channel > -1) + { + gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sBlackImagep); + } } - } - shader->uniform1f(LLShaderMgr::DOF_FOCAL_DISTANCE, -subject_distance/1000.f); - shader->uniform1f(LLShaderMgr::DOF_BLUR_CONSTANT, blur_constant); - shader->uniform1f(LLShaderMgr::DOF_TAN_PIXEL_ANGLE, tanf(1.f/LLDrawable::sCurPixelAngle)); - shader->uniform1f(LLShaderMgr::DOF_MAGNIFICATION, magnification); + shader->uniform1f(LLShaderMgr::DOF_FOCAL_DISTANCE, -subject_distance/1000.f); + shader->uniform1f(LLShaderMgr::DOF_BLUR_CONSTANT, blur_constant); + shader->uniform1f(LLShaderMgr::DOF_TAN_PIXEL_ANGLE, tanf(1.f/LLDrawable::sCurPixelAngle)); + shader->uniform1f(LLShaderMgr::DOF_MAGNIFICATION, magnification); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1,-1); + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); + gGL.vertex2f(-1,-1); - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1,3); + gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); + gGL.vertex2f(-1,3); - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3,-1); + gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); + gGL.vertex2f(3,-1); - gGL.end(); + gGL.end(); - unbindDeferredShader(*shader); - mDeferredLight.flush(); + unbindDeferredShader(*shader); + mDeferredLight.flush(); + } + { //perform DoF sampling at half-res (preserve alpha channel) + mScreen.bindTarget(); + glViewport(0,0,mScreen.getWidth()/2, mScreen.getHeight()/2); + gGL.setColorMask(true, false); - shader = &gDeferredPostProgram; - bindDeferredShader(*shader); - channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mDeferredLight.getUsage()); - if (channel > -1) - { - mDeferredLight.bindTexture(0, channel); + shader = &gDeferredPostProgram; + bindDeferredShader(*shader); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mDeferredLight.getUsage()); + if (channel > -1) + { + mDeferredLight.bindTexture(0, channel); + } + + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); + gGL.vertex2f(-1,-1); + + gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); + gGL.vertex2f(-1,3); + + gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); + gGL.vertex2f(3,-1); + + gGL.end(); + + unbindDeferredShader(*shader); + mScreen.flush(); + gGL.setColorMask(true, true); } - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1,-1); + { //combine result based on alpha + shader = &gDeferredDoFCombineProgram; + bindDeferredShader(*shader); + glViewport(0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight()); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage()); + if (channel > -1) + { + mScreen.bindTexture(0, channel); + } + + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); + gGL.vertex2f(-1,-1); - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1,3); + gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); + gGL.vertex2f(-1,3); - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3,-1); + gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); + gGL.vertex2f(3,-1); - gGL.end(); + gGL.end(); - unbindDeferredShader(*shader); + unbindDeferredShader(*shader); + } } else { |