- Home /
Using a Moon with a Skybox, Queue Problem (Pics)
Hi,
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!
I'm willing to do the work I just don't understand why the above is happening. Even if someone could just point me in the right direction it would be very helpful.
Okay update, I read somewhere that you can have 2 cameras to render different things. Could I not have a separate camera that renders the moon. Example the moon shader will ignore fog and the camera rendering the moon will have solid colors turned on. I did this with one camera and it worked. Could I not keep my skyboxes but do what I explained above using 2 cameras?
If so, how do you go about having 2 separate cameras rendering different things?
Is this skybox the camera background? And what is the moon? A plane?
Answer by aldonaletto · May 14, 2012 at 01:29 AM
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:
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.
Thank you for this, it didn't work in my case, but I'm sure it would have if you were using a regular non-blended skybox. You did however make me see a mistake I made allowing me to fix the problem. I changed the queue rendering process through script before hand for another reason which I fixed and I had forgot the script was still attached. I'm sure this will help other though, thank you for the help.
Your answer
Follow this Question
Related Questions
(HELP) Volume Ray Marching rendered always on top of the other objects 2 Answers
Why shadows disappear with HDRI skybox, even directional light is on ? 0 Answers
Having trouble getting objects to render in the background 0 Answers
Strange hang on load with skybox. 2 Answers
Transparency shader that also writes to Camera Depth Texture 0 Answers