- Home /
Weird problem with RenderTexture and HDRP Custom Pass
Hey!
I'm trying to fix this issue and for now i cant find anything related to it. The problem is that i have custom pass that is rendering RenderTexture to the screen:
protected override void Execute(CustomPassContext ctx)
{
if (BackgroundTarget == null) { return; }
if (fullscreenPassMaterial != null)
{
ctx.cmd.Blit(BackgroundTarget, ctx.cameraColorBuffer, fullscreenPassMaterial);
}
else
{
ctx.cmd.Blit(BackgroundTarget, ctx.cameraColorBuffer);
}
}
And i'm also rendering Camera to RenderTexture manuallly in different script as a custom Screenshoot solution. And here i have big problem, for some reason when i render to RenderTexture manually (making custom screenshot), ctx.cameraColorBuffer seems to "keep" biggest resolution rendered here as it's size.
So this is how it's working right now:
I start game for example in 1920x1080 resolution
Custom pass is correctly Blitting 1920x1080 texture to ctx.cameraColorBuffer
When i will make manual render to Rendertexture in higher res (for example 2560x1440), then Custom Pass will start working wrong. Even if RenderTexture in custom pass still have 1920x1080 and viewport is still 1920x1080 it looks like ctx.cameraColorBuffer has size of 2560x1440 so when blitting my texture will be cut.
How it should work in my opinion? When i will make single render to RenderTexture with my main camera with higher resolution than my viewport after that when i will reset camera render texture to null. Custom pass should blit to my viewport resolution instead of the biggest rendered texture size.
One more thing that i saw. It looks like when i will render to very big resolution, like 4k or more then it works correctly, after single frame with 4k or more buffer is going back to proper size. But it's not working for everything smaller than 4k.
I'm trying to figure it out but i'm currently out of any ideas. Unity version: 2021.1.25f1, Windows, HDRP.
Thank you for reading this, if you guys have any ideas please let me know!
Your answer
Follow this Question
Related Questions
How would you efficiently access the last N rendered frames every frame? 2 Answers
Using Render Texture with Screen Overlay 1 Answer
Can someone explain RenderTexture.SupportsStencil 0 Answers
How to read cubemap from realtime reflection probe 1 Answer
Copy result of pass to another pass of the same shader 1 Answer