Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
dependencies ▾

Modern-Apps.git / library / map / src / main / rust / shaders / moon.vert

moon.vert31 lines · 1.2 KiBRaw
1#version 450
2
3// Moon vertex: the shared unit quad, scaled to the globe disc.
4//
5// The record path pushes a matrix that maps the quad's -1..1 to the disc's
6// bounding square (radius in clip units, centred on the viewport). Everything
7// spherical — the limb cut, the hemisphere z, the normal, the depth — is done
8// per fragment in `moon.frag`: the quad has only four corners, all outside the
9// unit disc, so a per-vertex disc test would discard the whole moon.
10//
11// Push layout (the stock `Push` block):
12// `tileToClip` the disc matrix described above.
13// `color.xy` the camera centre lon/lat (degrees), read by the fragment stage.
14// `line` the DEM packing + ring radii, `misc.xy` the bearing/pitch and
15// `misc.z` the DEM relief strength, read by the fragment stage.
16layout(location = 0) in vec3 inLocal;
17layout(location = 0) out vec2 outDisc;
18layout(push_constant) uniform Push {
19 mat4 tileToClip;
20 vec4 color;
21 vec4 line;
22 vec4 misc;
23 vec4 morph;
24} push;
25
26void main() {
27 // morph.y: quad extent in planetary radii (>1 only for ringed bodies,
28 // whose annulus spills past the disc's bounding square).
29 outDisc = inLocal.xy * push.morph.y;
30 gl_Position = push.tileToClip * vec4(inLocal.xy, 0.0, 1.0);
31}