Avoid running the motionblur shader if there hasn't been camera movement. Also clamp per-frame fragment velocity to reduce visual artifacts.

This commit is contained in:
Shyotl
2013-07-03 17:12:12 -05:00
parent 8ccf3a20b3
commit b3d97b0860
2 changed files with 5 additions and 2 deletions

View File

@@ -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)