I have a secondary camera that renders to a render texture. This works fine. I also want to blur this texture before using the results. To do so I applied the blur image effect found in the standard assets. However for some strange reason this causes the render texture to lag behind the main scene, causing serious issues whenever anything moves.
It seems as if this image effect causes the render texture to update a frame too late, while toggling this effect off immediately fixes the issue. Looking at the source for the effect I do not understand what could cause this delay.
Does anyone know why this delay happens or how I can prevent it from happening while still blurring my render texture?
In the below image-effect script, the stencilAsRedTexture is correctly passed and used in the fogMaterial render call. However, it’s contents are always one frame behind the current one!
In other words, if I move to the right quickly, the first frame with the new rotation has the fogMaterial effect applied correctly, i.e. without delay, and the fog matches with the rotated visuals; but the stencilAsRedTexture that’s displayed doesn’t change, still having the contents it had before the rotation (for that first frame after the rotation–and likewise, for each frame after, it’s contents are always lagged one frame behind).
I’ve been able to work around this issue by merging the ConvertStencilValueXToColorY and Fog shaders into one (with two passes), and calling Graphics.Blit with both passes rendering.
But it’d be nice to not have to do this, as it wouldn’t work in every case.