<p>So I have implemented motion blur via depth re-construction using the depth texture and a previous view projection matrix. The shader basically finds the texel coordinate in by using the previous (frame) view projection matrix and subtract the current UV (what's given to fragment) to find a blurring vector. Then I simply blur along this vector by sampling along it and then normalize it with the number of samples, a constant I set at the beginning.</p>

<p>The problem I'm having is that even a tiny movement will cause the motion blur to ... well blur the scene. I find this too invasive and would like to ... "soften" this effect. I have tried to cap it by saying if the dot product of this blur vector is greater than 0.01, then blur. This sadly creates an oval like artifact in the middle the screen ...</p>

<p>Anyone have good suggestions on how to handle this? </p>

CC BY-SA 3.0
2017-07-05T07:54:32.630Z
"the dot product of this blur vector" with what? dot product has two operands. For your question, don't forget the possibility that an error in the code itself is what's making the effect too strong.
Dan Hulme
CC BY-SA 3.0
2017-07-05T11:38:47.997Z
Are you happy to show your code?
trichoplax is on Codidact now
CC BY-SA 3.0
2017-07-05T17:09:16.700Z
@DanHulme, I'm using the dot product of the blur vector, so basically dot(blurVector, blurVector). This is basically the length squared to see if the blur vector is large enough.
ChaoSXDemon
CC BY-SA 3.0
2017-07-07T06:01:10.907Z
Is the 'oval like artefact' because the blur is sampled in device coordinate space?
PaulHK
CC BY-SA 3.0
2017-07-07T20:30:36.610Z
@PaulHK, what do you mean? NDC? I'm drawing the screen as a post-processing effect, meaning I'm drawing a square that's the size of the screen and with texture coordinate (0,0) being top left and (1, 1) being bottom right. Therefore the UV will be interpolated from top left to bottom right.
ChaoSXDemon
CC BY-SA 3.0
2017-07-09T08:03:40.343Z
Yes that's what I was thinking. The problem is that if you go, say, 0.01 in any direction, it will be stretched horizontally because it is not corrected for aspect. When sampling for a blur, you want to be in pixel space, or at least a aspect corrected version of NDC, e.g. vec2 samplePos = ndcPos + blurOffset * vec2(aspectRatio, 1);
PaulHK
CC BY-SA 3.0
2017-07-10T17:37:35.277Z
@PaulHK I will try that but I doubt it will change much. I'm already calculating everything in pixel space ... so I reconstruct the 3D position from uv and depth texture, then multiply by inverse view-projection matrix. I then do perspective divide myself after multiplying by previous view-projection matrix. This coordinate is then converted to texture space [0, 1]. I then use this to subtract uv in fragment shader to get the delta uv.
ChaoSXDemon
<post-processing>
Motion Blur via depth re-construction too sensitive
ChaoSXDemon
# Motion Blur via depth re-construction too sensitive

(Asked by: username_0 on 2017-07-05)

So I have implemented motion blur via depth re-construction using the depth texture and a previous view projection matrix. The shader basically finds the texel coordinate in by using the previous (frame) view projection matrix and subtract the current UV (what's given to fragment) to find a blurring vector. Then I simply blur along this vector by sampling along it and then normalize it with the number of samples, a constant I set at the beginning.

The problem I'm having is that even a tiny movement will cause the motion blur to ... well blur the scene. I find this too invasive and would like to ... "soften" this effect. I have tried to cap it by saying if the dot product of this blur vector is greater than 0.01, then blur. This sadly creates an oval like artifact in the middle the screen ...

Anyone have good suggestions on how to handle this?

**Tags:** post-processing

> **Comments:**
> **username_1**: "the dot product of this blur vector" with what? dot product has two operands. For your question, don't forget the possibility that an error in the code itself is what's making the effect too strong.  
> **username_2**: Are you happy to show your code?  
> **username_0**: @username_1, I'm using the dot product of the blur vector, so basically dot(blurVector, blurVector). This is basically the length squared to see if the blur vector is large enough.  
> **username_3**: Is the 'oval like artefact' because the blur is sampled in device coordinate space?  
> **username_0**: @username_3, what do you mean? NDC? I'm drawing the screen as a post-processing effect, meaning I'm drawing a square that's the size of the screen and with texture coordinate (0,0) being top left and (1, 1) being bottom right. Therefore the UV will be interpolated from top left to bottom right.  
> **username_3**: Yes that's what I was thinking. The problem is that if you go, say, 0.01 in any direction, it will be stretched horizontally because it is not corrected for aspect. When sampling for a blur, you want to be in pixel space, or at least a aspect corrected version of NDC, e.g. vec2 samplePos = ndcPos + blurOffset * vec2(aspectRatio, 1);  
> **username_0**: @username_3 I will try that but I doubt it will change much. I'm already calculating everything in pixel space ... so I reconstruct the 3D position from uv and depth texture, then multiply by inverse view-projection matrix. I then do perspective divide myself after multiplying by previous view-projection matrix. This coordinate is then converted to texture space [0, 1]. I then use this to subtract uv in fragment shader to get the delta uv.  

---

## 0 answers

