A while ago I saw some posts on reddit popping up with different takes on gas giants, for example this one or Gaseous Giganticus (from some time ago). The second one even has some code on github, go check it out! I wanted to do a quick take on my own, making sure the planet is animated (meaning the gases “move”) and is a real sphere (pre-created flat textures often come with the problem of generating ugly seams on the backside).
There are some really impressive resources online for various ways of creating planets like that and out of interest I decided to stick to fBm (fractal Brownian motion). I won’t cover the mathematical details this time, since that’s not the main purpose of this post, but I’ll recommend to read through these two incredible resources if you are interested:
The planets are being colored using three (really it’s five, but three of those are being combined into a single one) colors depending on the result of the fBm going from dark to light areas. As you can see in the above image, adjusting these colors can produce really different results. So it’s not only about gas giants, stuff with huge oceans or even something resembling a desert-only planet can be created:
How does this look in real-time?
If you want to take a look at the code (a simple fragment shader on shadertoy), or want to try out different color combinations take a look at this shader. For a quick preview (without the simple sharpening effect) I’ve embedded an iframe (if you can display that) below:
Reading / additional resources
This is just a small reading list, with useful links or interesting stuff. In no particular order:
- The used noise functions: https://www.shadertoy.com/view/4dS3Wd
- More stuff on domain warping: http://www.iquilezles.org/www/articles/warp/warp.htm
- More complex lighting for planets: https://www.shadertoy.com/view/lsGGDd
- (Shape-) Domain warping for spheres: https://www.shadertoy.com/view/lttBDH
- Creating seamless textures: http://www.techmonkeybusiness.com/creating-seamless-spherical-textures.html
- Curl-Noise for Procedural Fluid Flow ( https://www.cs.ubc.ca/~rbridson/docs/bridson-siggraph2007-curlnoise.pdf) and an implementation: https://www.junkship.net/