URP Procedural Planet Generation & Rendering
A project to implement efficient procedural planet generation & rendering in the Universal Render Pipeline with a focus on being fast enough to display in VR. The planet shader samples a variety of cubemaps to make terrain generation relatively simple to implement while avoiding distortion at the poles.
Terrain generation is done by randomly scattering a configurable number of artist-authored mountain heightmap images around the surface of a spherical planet, followed by a configurable number of crater images. Both passes are optional, planets can be all mountains, all craters, or both. A number of shader passes are used afterwards to generate normal maps & splatmaps.
Clouds are generated by sampling layered simplex noise on the surface of a sphere, using another layer of noise to offset the sample position to introduce cloud swirling.
Atmosphere rendering adapts Sean O'Neil's algorithm for mie & rayleigh scattering. An inverted shell around the planet performs the algorithm per-fragment, while the planet itself (and potentially any other object within the atmosphere) performs the algorithm per-vertex to implement atmospheric fogging. Both work regardless of whether the camera is placed outside of or inside of the atmosphere shell.
Additionally, lighting lookup ramps are generated for skylight-ambient and local direct light colors. The ambient ramp is used to tint local ambient contribution given a position on the planet's surface and the angle of the sunlight, and the local direct light ramp is used similarly to tint the direct sunlight color. This is used for realistic sunset & sunrise transitions on the planet's surface, while also incorporating a height lookup for seamless surface-to-orbit transitions for any other participating objects.
Alan Stagner