Hey there,
so I need some of the objects in my scene to clip at a specific distance to the camera, while others could basically reach much closer to the camera.
(A) First thing I found was to Frustum culling
and preventing it by setting
GetComponent<MeshFilter>().sharedMesh.bounds = // something large
but this isn’t really what I need, my object is not being culled completely, it just has parts that reach inside the nearClipping plane of the camera.
(B) the objects that should clip at nearClipping = 1 are more at the lower edge of the screen. The objects that should not be clipped are more higher up. So I thought about setting my “camera.nearClipPlane = 0” and have a kind of occlusion cube at the bottom of the camera, that occluded objects that are closer than 1 from the camera. The problem here is that all depth buffer based occlusion shaders I know, occlude everything that is behind the object from the camera perspective. What I would need is to only occlude what is nearer to the camera.
(C) third approach I found was to create two layers for the objects, with two camera at exactly the same position, but different camera.nearClipPlane
values. But my scene already has a bunch of layers used for other things and that would make everything more complex. Also I’m afraid that rendering on two camera would have a performance impact.
How would you approach this? Is there any obvious trick I am missing?