Skybox stops drawing at certain angles

I have a very simple skybox material. I am using Render Settings to set the skybox for my scene, and I am using a single camera in the scene. The camera is set to the Skybox Clear Flags option.

Sometimes the skybox draws, and sometimes it doesn’t depending on where I am in the scene and where I am looking with the camera. I have tried extending the culling plane but that doesn’t help at all. This seems counter to what a skybox is supposed to do, draw at all times.

When it is suddenly not drawing, it defaults to the background color set in the camera. I can’t find a reason for this in any of the Unity documentation.

Thanks

Well, Unity’s skybox is fillrate-friendly. That means it avoids overdraw where possible. What unity does is:

  • Clear the framebuffer with a solid color.
  • draw opaque geometry
  • draw the skybox
  • draw transparent geometry

Now if you create a shader that is transparent (it uses a blend function) but is drawn in the opaque step, no skybox will be visible behind the geometry.

Your description of your problem is not very detailed. How does it disappear? Suddenly or do you see a clipping edge? Does it vanish completely or only behind certain things?

In our student project we had a similar problem when we used the depthmask shader to clip parts of the terrain. Where we used the depthmask shader the skybox wasn’t visible anymore. This is because the depthmask shader draws into the depth buffer and the skybox shader just ignores that parts as well since it should be all opaque geometry at this point.

Our solution was to create a manual skybox geometry that we’ve drawn with a second camera before everything else.