I have a sphere on one layer and a bunch of objects on an other layer. I would like to only render the objects that are behind the sphere with respect to the camera. This would all be rendered to a texture for later use.
I assume the steps would have to be something like:
Render sphere layer with ZWrite on and ColorMask 0
Render objects layer using ZTest Greater or GEqual
I will also probably need to use Shader Replacement when rendering the objects layer.
I have tried a couple of things but I have failed to produce any desirable results.
Let me know if you need any more information.
Edit: After further thought I think the steps should rather be:
Render depth of sphere layer to depth texture
Render objects with a depth greater than that in the depth texture
This would involve setting depthTextureMode to Depth when rendering the sphere then using the generated _CameraDepthTexture when rendering the objects for depth testing. But I am not sure what the shader would look like that was using the _CameraDepthTexture.