unity-game-enginehlslpixel-shader

Cull off parts above the mesh


So, I want to make scene same to this Sphere Scene

enter image description here

Now I have mesh with random generation as a ground and a sphere. But I dont't know how to cull off spheres geometry above mesh. Tried to use Stencil, and hightmap. Stencil rendered ground in front, but sphere above ground is still rendered. Using heightmap, to get know if it needs to render (I compared height map and worldPos) is problematic, because the texture is superimposed over the all sphere, and not projected onto it. Can you help. Is there any shader function to cull off all above mesh.


Solution

  • As I realised, there's no standard way to cull it without artifacts. The only way it can be done is using raymarching rendering.