Procedural planet shader on a plane

The flat earthers were right all along, earth is a plane! Here’s my proof:

Okay so jokes aside, what’s going on here?
This is a WIP shader for projecting planets onto 2D surfaces and shade them (with some stylistic freedom). Why? Because this is quite useful when you transfer it to the world background shader; the plane is just for easier prototyping and jokes. I already created a hacky version of this shader a while ago which I used in this project, but I decided to rebuild it from scratch and actually figure out the math for projecting a sphere onto a plane.

This is how it works:

  1. Converting the UV space into something resembling a projected normal map of a sphere:
  2. Using a simple phong shader that takes this normal map, a 3D light direction vector and creates diffuse “shading”:
  3. The environment texture node allows equirectangular textures to be mapped by using the normal map as input (as opposed to UV coordinates that the image texture would require)
  4. A bit of math that uses the distance from the center as input to create the atmosphere (and by using the Phong shader’s falloff function to create a bit of Rayleigh scattering)

I’m going to transfer this shader to the world shader, add a bunch of bells and whistles, make it parametric, add a few modular procedural terrain and cloud textures from another project, and then I got myself a fully interactive planet HDRI with proper perspective (yay).

4 Likes

I transfered the node graph to the world shader, added clouds with bump mapping and shadows, as well an approximation of what a close-up could look like (reducing the extend of the texture and the planet’s surface curvature).

2 Likes

That’s nice transform of the UV coordinates… :slight_smile:
Keep it going :wink:

1 Like