Friday, October 14, 2022
HomeGame Developmentunity - Why cannot I write to depth buffer if I specify...

unity – Why cannot I write to depth buffer if I specify the render goal to one thing totally different than the default digital camera body buffer?


Utilizing Unity’s URP I have been making an attempt to setup a scriptable render characteristic which can add a cross which pulls objects on a sure layer to a number of render targets. Sadly, I’m not in a position to get it to attract to the digital camera’s depth buffer it doesn’t matter what I do. Based on the docs there’s a option to specify a depth attachment together with colour attachments. Wanting on the supply code, it appears that evidently Unity will default to utilizing BuiltinRenderTextureType.CameraTarget if no depth attachment is specified. Sadly, I believe the precise utilization is closed supply so I do not know the way Unity handles it.

One factor I seen is that it appears it is going to solely draw to the right depth buffer if I set the render goal to cameraColorTarget:

var rt = new RenderTargetIdentifier(renderingData.cameraData.renderer.cameraColorTarget, 0, CubemapFace.Unknown, -1);

ConfigureTarget(rt, m_CameraDepthTarget);
// Or additionally works:
ConfigureTarget(rt);

and setting it to the rest does not work. I am drawing within the Exceute methodology utilizing context.DrawRenderers.

What I am questioning is that if there may be a way I can draw colour to a distinct render goal than digital camera’s framebuffer, however nonetheless draw/take a look at depth utilizing default depth buffer? With out a lot assets and documentation on URP facet of issues I am a bit misplaced on if/how it may be carried out on the level. Is it one thing that may be carried out typically? Or are depth buffers someway tied to a render texture underneath the hood or one thing so it’s not attainable? But when that’s the case, then it ought to nonetheless be attainable utilizing a number of render targets (MRT) since I can render to cameraColorTarget in addition to my customized render goal in a single cross (however sadly I’ve tried and does not appear to work for no matter motive).

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments