The problem is that Graphics.SetRenderTarget() is expecting a RenderBuffer for the depth buffer, and RenderBuffer is a struct, so it is not possible to pass in null. I don’t want to specify a depth buffer because it doesn’t make sense for what I’m doing (2D-like rendering) and I don’t want to waste the memory on a dummy depth buffer.
Assuming they have some Z separation and you’re not using alpha blended sprites for everything. If not, it’s useless (though you potentially might want to consider changing your setup to use it for the benefits @Peter77 mentioned).
What happens if you try to use renderTexture1.depthBuffer? Presumably those are render textures you’ve created w/o a depth buffer, but I’m not sure if accessing .depthBuffer returns an error in that case, or if SetRenderTarget will still complain if passed the blank RenderBuffer that a render texture with out a depth buffer presumably returns from .depthBuffer.
@Peter77 What I’m doing is a lot more complicated than that. It’s actually more of a decal system where I have predefined layers. Because of this, I already know the order that the layers will be drawn and have no use of a depth buffer.
@bgolus That’s a good idea! I’ll give it a go and see what happens.
Yes I can confirm that this works! Using the depth buffer from render texture (even if it doesn’t have a depth buffer) still seems to work without any errors. Thanks @bgolus !