- Home /
Day / Night Planetary Shader
I'm trying to work out how to create a shader that shows a planet with day and night. The basic idea is to have one texture that is 'daytime' and shows the normal planetary features, and another texture for the nighttime lights. The night side of the planet should also be more blue and desaturated than the day side.
Answer by Julien-Lynge · Nov 21, 2011 at 06:30 PM
After much searching, I ended up using a tutorial by Clamps and the Strumpy Shader Editor:
I'm still working on fixing the nighttime lighting - figuring out how to take the amount of light on the surface and use it to adjust the emission for the nighttime lights, so they only appear on the dark side of the Earth (and then going a step further and blending in some blue/purple on the dark side for added realism). If anyone knows how to do that, please let me know, otherwise I'll post back when I've figured it out.
I was able to get nighttime lighting working (finally had enough time to get back to this). Features:
Lights appear on the dark side and fade in during 'dusk'.
Lights are tinted slightly yellow.
The dark side of the earth is desaturated (made greyer) and given a bluish tint. Both of these effects are very subtle, but can be adjusted.
I posted the complete shader with instructions to the Wiki: http://unifycommunity.com/wiki/index.php?title=Earth/Planet
A final note: you could probably set this up in Strumpy Shader Editor too, as there is a lighting graph, but I couldn't find any documentation on it, so I just took the output of the Strumpy graph above and modified the code directly.
Answer by thundax · Mar 18, 2012 at 06:22 AM
You can just make a texture composed of dots for lights that goes over the whole planet. Then write a glow/emmisive shader that uses a dot product or normalize based on light direction and the texture as a glow/emmissive map. Just make sure that is made negative so that it occurs on the unlighted side.
Your answer
Follow this Question
Related Questions
Shader Fusion (Detail-map, how to) 1 Answer
Custom Shader not working on Android Device 0 Answers
Where can we find the Specular/Base shader pass script ? 1 Answer
How to write Diffuse shader with Pass{} instead of surface? 1 Answer
toonLighted shader to work with deferred rendered shadows 2 Answers