I’m trying to render the depth texture of a camera and apply anti aliasing, but I can’t seem to get it to anti-alias. I always end up with jagged aliased edges. My code is below, any ideas where I’m going wrong?
What antiAliasing does on a render texture is set the msaa you are applying to what is rendered into that texture. For this to work you need a depth buffer, and you need to be rendering things INTO that depth buffer. In this case neither of those things are happening.
What do you mean when you say you want antialiasing on the depth buffer? That doesn’t really make a lot of sense because you can’t USE that buffer for anything really…
If you want the buffer to have AA because you are drawing it to the screen and don’t like the edges you can run a screen space AA pass on it. Check out the MSAA and FXAA in the image effects package.
I’m new to image effects and shaders, can you provide some reference examples for how to do this? I’m guessing I need to set a camera render texture target somewhere along the way?
The depth texture is not anti-aliased in itself in my setup. Rather when the anti-aliased forward pass is done I test multiple points in the depth texture to find the pixel in the depth that’s the closest match.
Thanks for the clarification,
I stopped reading your code where you tap, assuming it’s for blur purposes, now I see it indeed does more.
To the op: Once you get the depth texture inside your shader, you can tap it to perform a blur.
we are using _CameraDepthTexture to determine alpha value in uberPost.shader(for example, eliminate camera backgrounds color), that’s very convenient. and also we want the _CameraDepthTexture have handled by SMAA, the the final output have smooth edges.