Paused motion blur artifact in built-in post processing stack v2

Hello!

When adding a motion blur effect using the built-in render pipeline and the post processing stack v2 from the package manager, if you pause the game and then move something there is an interesting artifacting that happens. From just basic debugging it’s clear that both the Render function in the motionblur.cs script as well as the motionblur shader are running every frame despite the game being paused. But this artifacting does not happen when the game is running, so clearly there’s something different. What is the thing that’s different? There must be a framebuffer or something that is being drawn upon that is not updating because the game is paused by my debugging thus far has not been able to locate what that is. Any tips in the right direction? I just want to understand this better!

Thanks!
Zach

Last Edit:
Ok, so I’m pretty sure now that the reason this happens is because the built-in CameraMotionVectorsTexture calculates the difference between the current frame and the last frame, and while the current frame gets updated while the game is paused, the last frame does NOT. So the vector difference is between the most recent “unpaused” frame and the current frame. Because this is built-in, I have no way to access it and build an array of buffers essentially to try to compare the current frame to a frame from longer ago while the game is unpaused. I mean, I could conceivably do my own math to calculate the my own motion vectors but I’d rather not. The effect is somewhat reproducible just by going into the MotionBlur.shader file and in the FragVelocitySetup function, multiplying v by some very large number. It’s not quite the same, because this just increases the magnitude of the motion vector rather than changing what it’s being compared to, but I don’t think I’ll be pursuing this inquiry any farther. I’d still love input from someone who actually knows something about shaders!

Original Post:
Oh! I think that it’s that nothing at all is different. It’s just that it doesn’t update during pause when there is no change. So we get to see the motion blur. Where as in play mode the blur goes away because the previous frames, the “blurred” frames, are so much similar to the current frame that they look the same to the naked eye. Can anyone confirm?

EDIT:
And if this is the case… how could I edit this to get some similar sort of artifact at runtime? For example, instead of by sampling the last 5 or 6 frames, sampling every 10th frame, perhaps?

EDIT 2:
No, it must be more complicated than this. Because upon pausing, the object’s original position or rotation (original being where it was when paused) matters, and it’s not just an accrual of frames. It’s more like how the new frames are different than the frame upon pausing. Some, I’m still totally lost on this. Any help?

EDIT 3:
I’m getting closer. I think it’s actually the motion vector, from this: _CameraMotionVectorsTexture in he shader. My guess is that doesn’t get updated during pause, so when I rotate the object it’s like it’s applying a previous motion vector to a new frame to which it doesn’t apply. The closest concept I can grasp is like datamoshing an H.264 video, when you remove the I frames so that the motion predictive P frames are applied to a frame set they aren’t “meant to.” Still would love some help on this if anyone knows more than I’ve figured out. If I wanted to get the same effect at runtime as I do when I pause, maybe I could somehow save the motion vectors texture from a previous frame and apply it to the current one? Gotta figure out now how to save a texture between frames…

EDIT 4:
Yeah, I’m pretty sure that what I’m seeing is that the CameraMotionVectorTexture does not get updated when the game is paused, so an old motion vector texture is being used on a new overall image. I really have no idea what I’m doing, but I think to achieve the effect that I want, I’d want to try only updating the that motion vector texture intermittently, essentially using an older motion vector texture until I choose to update it. But I haven’t figured out how to do that yet, because I’d need to store the old texture between frames. This is all made harder because the documentation is pretty limited for post processing, and in some cases seems to be inaccurate (for example, the BlitFullscreenTriangle method uses a number of arguments that seems to jive with Graphics.Blit and not the CommandBuffer.BlitFullscreenTriangle). Any idea how I could save this motion vector texture between frames, essentially creating maybe like a 50 frame delay with the texture?

EDIT 5:
Haha, not that’s not it either. I figured out how to visualize the Camera Motion Vectors Texture and I can see that it IS in fact being updated while the game is paused. So although my understanding is advanced a long ways, I’m actually back at square one in terms of figuring out WHY that artifacting happens while it’s paused. I will keep experimenting but would LOVE some pointers to help me figure out what’s going on here.