- Home /
How to use OnRenderImage and Graphics.Blit with HDRP/LWRP?
I'm trying to save the rendered screen image to disk for every frame, but the performance is extreamly poor (1 fps).
I found this example project using AsyncGPUReadbackRequest and traying it out gave me 30-40 fps. https://github.com/keijiro/AsyncCaptureTest
However, it is useing the old render pipeline in Unity and is calling
void OnRenderImage(RenderTexture source, RenderTexture destination)
{
if (_requests.Count < 8)
_requests.Enqueue(AsyncGPUReadback.Request(source));
else
Debug.Log("Too many requests.");
Graphics.Blit(source, destination);
}
But the OnRenderImage() is not being called when using the new Scriptable Render Pipeline (HDRP in this case).
So how do I get around this, how do I call Graphics.Blit after the frame has been rendered when those callbacks aren't available anymore? You can see the full code for this, what happens after the OnRenderImage() for instance, following this link: https://github.com/keijiro/AsyncCaptureTest/blob/master/Assets/AsyncCapture.cs
Did you ever find a solution? I have the same issue but my project is using LWRP.
I found a solution, though it may have been a solution to a different problem. I'm not entirely sure what OP was actually using OnRenderImage for. See my question on stack exchange: https://gamedev.stackexchange.com/questions/169294/high-performance-screenshots-in-lwrp
I ended up using an FF$$anonymous$$peg library to record a video of the screen and save it to disk. FF$$anonymous$$peg can be multithreaded so the performance was great.
Your answer
Follow this Question
Related Questions
Weird problem with RenderTexture and HDRP Custom Pass 0 Answers
Copy result of pass to another pass of the same shader 1 Answer
Unity not properly rendering mesh faces 1 Answer
Terrain Handling For Performance Improvement in 2D Game 0 Answers
When building and running, textures are black or invisible. 2 Answers