Planet Shaders · Reference
Planet shader glossary
The vocabulary this course uses, defined once and used consistently.
Terms are added here once a lesson has actually used them. Where a term also exists in the GPU programming glossary, the definition here is the rendering-side one — several words mean different things on the compute side.
The pipeline
Rendering shader — a shader that runs as part of drawing something. Unlike a compute shader, you do not dispatch it: the renderer runs it for you, once per vertex and then once per covered pixel, as a consequence of a mesh being on screen.
Spatial shader — Godot’s shader type for 3D surfaces, declared shader_type spatial;.
It is the most featureful of Godot’s shader types, and the only one this course uses.
(Godot: Spatial shaders)
Vertex stage / vertex() — runs once per mesh vertex. Its job is to place the vertex
and to hand values down to the fragment stage.
Fragment stage / fragment() — runs once per fragment: a candidate pixel covered by
the triangle being drawn. This is where a planet’s colour is decided.
Fragment — one covered pixel-sized sample of a triangle. Not quite a pixel, because several fragments can compete for the same pixel before depth testing resolves which wins.
Rasterizer — the fixed-function hardware that turns a triangle into the set of fragments it covers, and interpolates the vertex stage’s outputs across them. It, not you, decides how many fragment invocations run.
Varying — a value written in vertex() and read in fragment(), linearly interpolated
across the triangle in between. Declared at global scope with the varying keyword.
(Godot: Shading language)
Spaces
Model space — coordinates in the mesh’s own frame, before any rotation, scale, or placement in the world. A unit sphere’s model-space positions are its surface directions. This is the space every planet in this course is authored in, so that moving or spinning the planet never changes its markings.
World space — coordinates after the model’s transform is applied. Shared by everything in the scene.
View space — coordinates relative to the camera. Notably, Godot’s VERTEX built-in is in
model space inside vertex() but in view space inside fragment() — which is exactly
why this course carries model position down through a varying rather than reading VERTEX in
the fragment stage.
Surface outputs
ALBEDO — the base colour a spatial shader writes. It is fed into Godot’s lighting, so
what reaches the screen is albedo times incoming light, not the raw value.
ROUGHNESS / SPECULAR — how the surface responds to light. ROUGHNESS = 1.0 and
SPECULAR = 0.0 give a matte, chalky surface, which is the right default for a planet seen
from space and the right starting point for a stylized look.
EMISSION — colour added after lighting, unaffected by it. The tool for city lights on
a night side, and for lava.
Mapping a sphere
Equirectangular UV — the default way a SphereMesh maps a rectangular texture onto a
ball: U runs around the equator, V runs from pole to pole. It is the mapping behind world
maps, and it has two defects that matter enormously here.
Pole pinch — the top and bottom rows of an equirectangular map compress an entire circle
of latitude into a single point. Any detail sampled through UV smears into a spiral at both
poles.
Seam — the line where U wraps from 1.0 back to 0.0. Values on either side are unrelated,
so a visible discontinuity runs down the planet from pole to pole.
Direction — the unit vector from the planet’s centre to the point being shaded. It has no
seam and no pole, because it is just a point on a sphere. Every planet function in this course
takes one: vec3 planet_color(vec3 dir).
Latitude — asin(dir.y), in radians, running from -π/2 at the south pole through 0 at
the equator to +π/2 at the north pole. Note that dir.y on its own is the sine of
latitude, not latitude — bands built from it bunch up near the equator.
Lighting from space
Terminator — the line dividing a planet’s lit day side from its unlit night side. Its softness is one of the strongest stylistic levers a planet shader has.
Limb — the outer edge of the planet’s disc against space. Where atmosphere reads as a bright rim.
Back to Lesson 1.