I’m trying to create a fairly simple Image Effect that combines previous frames together to get a sort of “ghosting”. It is similar to motion blur, but instead of adding to a constant image, it would keep a list of the last x frames and combine them.
The issue I’m finding is that my resulting image each frame seems to be just the current frame and the last frame it draws in the loop.
Am I doing something stupid?
EDIT: OK, this works, but it seems inefficient because I need to create a new RenderTexture every frame.
var buffer = RenderTexture.GetTemporary(source.width, source.height, 0);
// Write this frame to buffer
Graphics.Blit(source, buffer);
// Write each previous frame
for (var f = _previousFrames.Count - 1; f > 0; f--)
{
var newBuffer = RenderTexture.GetTemporary(source.width, source.height, 0);
material.SetTexture("_MainTex2", _previousFrames[f]);
Graphics.Blit(buffer, newBuffer, material);
RenderTexture.ReleaseTemporary(buffer);
buffer = newBuffer;
}
Graphics.Blit(buffer, destination);
RenderTexture.ReleaseTemporary(buffer);
Thanks!