Using a Moon with a Skybox, Queue Problem (Pics)


We have ran into a little problem. We are developing a weather system and are done with everything. We have one problem though, we switched from a solid color background to a blended skybox We are having issues with the shader working properly with the skybox and fog.

What’s happening is that the when we don’t disable the fog through the shader the moon looks good, but renders over the clouds, resulting in an unrealistic effect. If we disable the fog through the shader it causes the moon texture to just be the plane shape of the moon rather than showing the texture of the moon itself, but it renders behind the clouds. Only problem is that it doesn’t look good and that’s where the problem is.

How can we have the texture look good without being washed out from the fog and have it render behind the clouds?

We have used many different queues and cannot find the source of the problem. I think it’s a combination of both using a skybox and using fog. How can we get this working? We had it working before we supported skyboxes and Unity’s fog.

We took some screens to give you guys a visual of what’s happening. Please if anyone can help us out it would be very much appreciated. Thanks!

The skybox background is actually the number one in the queue: the screen is cleared with it, thus everything else will be rendered over it. To draw something behind the clouds, the only solution is to use the skybox alpha channel to show the transparent areas - it’s 1 at open sky, and 0 at the clouds (the Eerie Sky in the Standard Assets/Skyboxes folder has this characteristic).

The simple shader below (moon material) uses the skybox alpha channel to control its own alpha, and gave this result:

alt text

Shader "RenderFX/Behind Clouds" {
   Properties {
        _MainTex ("MainTexture", 2D) = "black" {}
    SubShader {
        Tags { "Queue" = "Transparent" }
        Fog { Mode Off }
        Pass {
            Blend DstAlpha One
            SetTexture [_MainTex] { combine texture }

The moon became somewhat blueish, perhaps because the alpha values for the skybox were lower than 1.