Rendering something behind the horizon.

How can I render an object behind the horizon line? So it’s still visible in front of the skybox but behind the horizon line, like a sun setting over the ocean.

I’ve been wrestling with the render queues and custom shaders, but it looks like the skybox cube sides are all rendered in the same layer. Any ideas?

You will need a custom shader that takes the object position into consideration and make it fade away when below the horizon threshold. This is something I made in Amplify Shader, it fades my stars when they reach near the horizon. See if you can get something of it. I don’t believe my shader is the perfect solution, but it works :slight_smile:


I’ll clarify. The skybox is rendered as a tesselated cube and I want to render something behind the lower half of the +z -z +x -x and behind -y, but in front of the upper half of those and +y sides of the skybox. I guess I could mask all those things in the skybox texture somehow, but I still can’t figure out how to apply that to the one object I want to disappear behind the horizon.

Maybe Unity can’t do this and I’ll have to resort to a procedural skybox with a moving celestial body, but isn’t the ‘horizon’ defined somewhere in Unity? I don’t mean the camera’s clipping plane but the y plane from the current viewpoint.