From b3d97b086090a12373547567354193d8778e4367 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Wed, 3 Jul 2013 17:12:12 -0500 Subject: [PATCH] Avoid running the motionblur shader if there hasn't been camera movement. Also clamp per-frame fragment velocity to reduce visual artifacts. --- indra/llrender/llpostprocess.cpp | 3 ++- .../app_settings/shaders/class1/effects/MotionBlurF.glsl | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/indra/llrender/llpostprocess.cpp b/indra/llrender/llpostprocess.cpp index 0ab80bf68..1ea12e351 100644 --- a/indra/llrender/llpostprocess.cpp +++ b/indra/llrender/llpostprocess.cpp @@ -282,6 +282,7 @@ public: { addSetting(mStrength); } + /*virtual*/ bool isEnabled() const { return LLPostProcessShader::isEnabled() && llabs(gGLModelView[0] - gGLPreviousModelView[0]) > .0000001; } /*virtual*/ S32 getColorChannel() const { return 0; } /*virtual*/ S32 getDepthChannel() const { return 1; } /*virtual*/ QuadType preDraw() @@ -298,7 +299,7 @@ public: getShader().uniformMatrix4fv("inv_proj", 1, GL_FALSE, inv_proj.m); getShader().uniform2fv("screen_res", 1, screen_rect.mV); getShader().uniform1i("blur_strength", mStrength); - + return QUAD_NORMAL; } /*virtual*/ bool draw(U32 pass) diff --git a/indra/newview/app_settings/shaders/class1/effects/MotionBlurF.glsl b/indra/newview/app_settings/shaders/class1/effects/MotionBlurF.glsl index 89aaa8f10..efa1265a1 100644 --- a/indra/newview/app_settings/shaders/class1/effects/MotionBlurF.glsl +++ b/indra/newview/app_settings/shaders/class1/effects/MotionBlurF.glsl @@ -44,7 +44,9 @@ void main(void) vec4 prev_pos = prev_proj * pos; prev_pos/=prev_pos.w; prev_pos.w = 1.0; - vec2 vel = ((ndc.xy-prev_pos.xy) * .5) * screen_res * .001 * blur_strength; + vec2 vel = ((ndc.xy-prev_pos.xy) * .5) * screen_res * .01 * blur_strength * 1.0/SAMPLE_COUNT; + float len = length(vel); + vel = normalize(vel) * min(len, 50); vec3 color = texture2DRect(tex0, vary_texcoord0.st).rgb; vec2 texcoord = vary_texcoord0 + vel; for(int i = 1; i < SAMPLE_COUNT; ++i, texcoord += vel)