- Home /
Using depth textures
I am trying to achieve the following:
I want to render only certain objects, for example spheres, to a render texture. I can achieve this with camera's culling mask and layers. I will then overlay this render texture to another camera to achieve some nice effects.
My problem is the culling. I have no idea how to render the spheres in a way that they will not be rendered if they are behind something. But now the culling mask makes it so that it doesn't know about the other objects and the spheres are always on top of everything if I overlay the render texture.
I've tried using a depth texture from another camera but I have no idea how to use them. Do I have to write a custom shader? I have little knowledge of shaders so I don't know how to piece these things together.