GLSL: Fade the moon with the ambient color at the end of night

Hi! I try to make a night/day cycle with the cloudy skybox from Martinsh:

I added a sun and a moon. But I’m facing a problem at the end of night. I don’t know how I could have a good fade effect when the day appears and the moon disappears (I use a Timer called “mixFactor”. It begins at dawn. It is used to mix moonTexture with dayColor line 214 and it is also used to decrease moon radiance line 178). My file:

If you have any idea or suggestion (about my problem), it would be cool! Thanks!

EDIT: Could you tell me if it runs fine or not on your computer too?

The .blend provided in video description runs perfect, but this one shows me flat skybox with a lot of small, tiled and identic clouds on top and stripes on the sides of box. 2.72b(I don’t know why it is default for me).

@adriansnetlis: Weird… I’m using 2.75.1. Here is what you are supposed to see:

The thing is that I use a cube with generated texCoords (no uv map) for the cloudy skybox… Maybe this change with blender’s versions used.

IDK! I will try it later with 2.74.5 or when 2.75 gets official release.

Oh! And I use the new world API (released since 2.74.5) (Thanks HG1!). So with earlier versions it can’t work correctly. Furthermore I packed moon texture in 2.75 so the texture can’t be available in earlier versions.

The moon gets black, I see it. The sky changes faster than moon/sun appears. Also, no orange color during sunset(this is just for visual). Yeah, you may want to fit the timing.

Yes it’s just a beginning. The fast speed is for testing purposes. On my computer the moon doesn’t turn black. Thanks for your remarks. But I wanted suggestions about my problem. How I can apply a (better) fade effect to the moon at the end of the night. In GLSL.

Maybe move it outwards(into fog) and scale up so it looks like fading in fog?