diff options
author | Dave Parks <davep@lindenlab.com> | 2011-11-04 17:07:40 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2011-11-04 17:07:40 -0500 |
commit | 367d6212ae9e18c398c25fe9e11646bfc801fd90 (patch) | |
tree | a4f73bd7099a441a8d710bea8b454703e07dbce3 /indra | |
parent | 785dcfe6d496bd44730b6ba0004614b2c6d04c6a (diff) |
SH-2652 Better DoF combine foo
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llrender/llshadermgr.cpp | 1 | ||||
-rw-r--r-- | indra/llrender/llshadermgr.h | 1 | ||||
-rw-r--r-- | indra/newview/app_settings/settings.xml | 12 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/cofF.glsl | 3 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl | 5 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl | 5 | ||||
-rw-r--r-- | indra/newview/pipeline.cpp | 9 | ||||
-rw-r--r-- | indra/newview/pipeline.h | 1 |
8 files changed, 32 insertions, 5 deletions
diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 84dc768983..b390037a9c 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1046,6 +1046,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("blur_constant"); mReservedUniforms.push_back("tan_pixel_angle"); mReservedUniforms.push_back("magnification"); + mReservedUniforms.push_back("max_cof"); mReservedUniforms.push_back("depthMap"); mReservedUniforms.push_back("shadowMap0"); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index a5150b3e51..82ce2dfff2 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -141,6 +141,7 @@ public: DOF_BLUR_CONSTANT, DOF_TAN_PIXEL_ANGLE, DOF_MAGNIFICATION, + DOF_MAX_COF, DEFERRED_DEPTH, DEFERRED_SHADOW0, diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index fb73ddf219..d057323e51 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -1392,6 +1392,18 @@ <real>0.5</real> </map> + <key>CameraMaxCoF</key> + <map> + <key>Comment</key> + <string>Maximum camera circle of confusion for DoF effect</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>10.0</real> + </map> + <key>CameraFNumber</key> <map> <key>Comment</key> diff --git a/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl index 81f00f7d0f..56fa4e693b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl @@ -39,6 +39,7 @@ uniform float focal_distance; uniform float blur_constant; uniform float tan_pixel_angle; uniform float magnification; +uniform float max_cof; uniform mat4 inv_proj; uniform vec2 screen_res; @@ -78,7 +79,7 @@ void main() vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy); float sc = calc_cof(depth); - sc = min(abs(sc), 10.0); + sc = min(abs(sc), max_cof); vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy/screen_res); gl_FragColor.rgb = diff.rgb + bloom.rgb; diff --git a/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl b/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl index de0c70cfe9..c639f25fc6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl @@ -35,6 +35,8 @@ uniform sampler2DRect lightMap; uniform mat4 inv_proj; uniform vec2 screen_res; +uniform float max_cof; + VARYING vec2 vary_fragcoord; void main() @@ -45,5 +47,6 @@ void main() vec4 diff = texture2DRect(lightMap, vary_fragcoord.xy); - gl_FragColor = mix(diff, dof, diff.a); + float a = min(diff.a * max_cof*0.125, 1.0); + gl_FragColor = mix(diff, dof, a); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl index 1db638b943..629648ddc3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl @@ -33,6 +33,7 @@ uniform sampler2DRect diffuseRect; uniform mat4 inv_proj; uniform vec2 screen_res; +uniform float max_cof; VARYING vec2 vary_fragcoord; @@ -40,7 +41,7 @@ void dofSample(inout vec4 diff, inout float w, float min_sc, vec2 tc) { vec4 s = texture2DRect(diffuseRect, tc); - float sc = s.a*10.0; + float sc = s.a*max_cof; if (sc > min_sc) //sampled pixel is more "out of focus" than current sample radius { @@ -64,7 +65,7 @@ void main() { float w = 1.0; - float sc = diff.a*10.0; + float sc = diff.a*max_cof; float PI = 3.14159265358979323846264; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 8ae7e97f4a..1fff954b96 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -185,6 +185,7 @@ LLVector3 LLPipeline::RenderShadowSplitExponent; F32 LLPipeline::RenderShadowErrorCutoff; F32 LLPipeline::RenderShadowFOVCutoff; BOOL LLPipeline::CameraOffset; +F32 LLPipeline::CameraMaxCoF; const F32 BACKLIGHT_DAY_MAGNITUDE_AVATAR = 0.2f; const F32 BACKLIGHT_NIGHT_MAGNITUDE_AVATAR = 0.1f; @@ -926,6 +927,7 @@ void LLPipeline::refreshCachedSettings() RenderShadowErrorCutoff = gSavedSettings.getF32("RenderShadowErrorCutoff"); RenderShadowFOVCutoff = gSavedSettings.getF32("RenderShadowFOVCutoff"); CameraOffset = gSavedSettings.getBOOL("CameraOffset"); + CameraMaxCoF = gSavedSettings.getF32("CameraMaxCoF"); } void LLPipeline::releaseGLBuffers() @@ -6461,7 +6463,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) shader->uniform2f(LLShaderMgr::FXAA_RCP_SCREEN_RES, 1.f/width*scale_x, 1.f/height*scale_y); shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT, -0.5f/width*scale_x, -0.5f/height*scale_y, 0.5f/width*scale_x, 0.5f/height*scale_y); shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT2, -2.f/width*scale_x, -2.f/height*scale_y, 2.f/width*scale_x, 2.f/height*scale_y); - + gGL.begin(LLRender::TRIANGLE_STRIP); gGL.vertex2f(-1,-1); gGL.vertex2f(-1,3); @@ -6620,6 +6622,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) 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_MAX_COF, CameraMaxCoF); gGL.begin(LLRender::TRIANGLE_STRIP); gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); @@ -6650,6 +6653,8 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) mDeferredLight.bindTexture(0, channel); } + shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); + gGL.begin(LLRender::TRIANGLE_STRIP); gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); gGL.vertex2f(-1,-1); @@ -6677,6 +6682,8 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) mScreen.bindTexture(0, channel); } + shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); + gGL.begin(LLRender::TRIANGLE_STRIP); gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); gGL.vertex2f(-1,-1); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index d653990977..e607e0aec6 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -845,6 +845,7 @@ public: static F32 RenderShadowErrorCutoff; static F32 RenderShadowFOVCutoff; static BOOL CameraOffset; + static F32 CameraMaxCoF; }; void render_bbox(const LLVector3 &min, const LLVector3 &max); |