Skip to main content

Module outline

Module outline 

Source
Expand description

The outline scene: one picture drawn by both ways of drawing an outline.

Every body is one mesh drawn twice from one buffer — lit, and again spread along its own normals with its front faces culled — so the second draw shows only where it reaches past the first: a band around the silhouette. The band is a width in world units, so a body further from the camera wears a thinner one.

Beside them, screen-space strokes draw what a silhouette cannot: the orbit the bodies stand on, the ticks along it, and a pair of armillary rings circling the largest body. A stroke is a width in physical pixels, so it keeps its own width across the whole ring — the near side and the far side alike — where the band narrows with distance.

The strokes come in both of the source’s ink behaviours. The ticks are opaque: they cover what they draw over and write the depth that hides the strokes behind them. The orbit and the armillary rings are washes, blended over the frame instead of covering it, so a ring shows the body it passes in front of and two crossing rings deepen where they share a pixel. The rings circle a body whose far side they pass behind, so the same frame holds a wash in front of a body and one hidden by it.

Three short opaque strokes stand left of the orbit to pin the ways a stroke ends: flat-cut, round at one end, and a dot with both ends rounded. The rings are closed and the ticks are hidden among their neighbours, so without them no picture exercised the caps a stroke’s fragment shader draws its ends with.

The two are in one scene because the picture is the argument: a frame holding either alone would leave the other’s promise unpinned. The scene is declared twice — once for a single-sampled target and once for a multisampled one — because an opaque stroke’s antialiasing follows the target’s sample count: single-sampled it cuts at half coverage, and multisampled the cut yields to alpha-to-coverage, which spreads that same coverage over the samples and keeps the edge smooth.

The bodies carry vertex normals because the shell is pushed along them; a mesh without normals cannot be spread at all. One body in the frame carries none, and is drawn lit anyway: its normals come from the screen-space derivatives of its own surface, which is the fallback a lit draw takes when a mesh has no normal channel. The two paths are in one frame because the library has both, and a capture holding only the baked one would leave the fallback unverified.

Re-exports§

use super::SceneControl; 🔒
use super::SceneDef; 🔒
use super::SceneOptions; 🔒
use super::TEST_SIZE; 🔒
use super::camera_looking_at; 🔒
use unlit_ecs::Bundle; 🔒
use unlit_ecs::DynamicBundle; 🔒
use unlit_ecs::bundle; 🔒
use unlit_wgpu::pipeline::LitOptions; 🔒
use unlit3d::prelude::*; 🔒

Structs§

Outlined 🔒
A body: the mesh both of its draws read, and the two pipelines they use.

Constants§

AMBIENT 🔒
The ambient term every body receives before the sun is added.
ARMILLARY 🔒
The armillary rings circling the largest body: each is drawn around an axis the frame tilts differently, so the two cross twice and each passes in front of the body it circles on one side and behind it on the other.
ARMILLARY_CENTRE 🔒
The point both armillary rings are centred on: the largest body’s centre, so each ring hugs it — outside the band HULL_WIDTH draws, inside the orbit that encloses the whole group.
ARMILLARY_HALF_WIDTH 🔒
ARMILLARY_RADIUS 🔒
ARMILLARY_SEGMENTS 🔒
BODIES 🔒
The bodies with normals: where each stands, how big it is and what it is tinted.
CAMERA_EYE 🔒
Where the camera looks down from.
CAMERA_TARGET 🔒
What it looks at: a little above the orbit, so the ring is seen from above.
CAPS_HALF_WIDTH 🔒
The half width the cap strokes wear, wide enough for the ends to read.
CAPS_INK 🔒
The ink the cap strokes wear: dark enough to read against the paper and against the orbit they stand beside, opaque so the coverage is the shader’s own.
FACETED 🔒
The two bodies without normals: where each stands, how big it is and what it is tinted.
FACETS 🔒
How coarsely the one faceted body is split.
HULL_WIDTH 🔒
The band’s width, in world units.
INK 🔒
The colour the band is drawn in.
INK_STROKE 🔒
The ink the opaque ticks carry: the bytes the segment stream holds, which the fragment writes into a linear target before it is encoded.
INK_WASH 🔒
INK_STROKE washed by WASH_ALPHA: the blended orbit’s ink, the same colour at the alpha a wash blends with.
MSAA_SNAPSHOT 🔒
The snapshot the multisampled capture freezes its frame under.
ORBIT_HALF_WIDTH 🔒
ORBIT_HEIGHT 🔒
ORBIT_RADIUS 🔒
The orbit’s radius, and the height it is drawn at.
ORBIT_SEGMENTS 🔒
How many segments the orbit is drawn with, and its half width in physical pixels.
PAPER 🔒
The paper the whole scene is drawn on.
SLICES 🔒
How finely the smooth spheres are split — fine enough that a baked normal is what the gradient follows rather than the facets.
SNAPSHOT 🔒
The snapshot the single-sampled capture freezes its frame under.
STACKS 🔒
SUN 🔒
Where the one directional light hangs and what it aims at: from above and to the left, so each body is lit on one side and turned away on the other.
SUN_INTENSITY 🔒
How bright that light is.
TICKS 🔒
How many ticks stand on the orbit, how tall they are and how thick.
TICK_HALF_WIDTH 🔒
TICK_HEIGHT 🔒
WASH_ALPHA 🔒
The alpha the blended inks are washed to.

Statics§

MSAA_SCENE
The same scene on a multisampled target.
SCENE
The scene: outlined bodies standing on an orbit drawn with strokes, on a single-sampled target.

Functions§

armillary 🔒
The armillary rings, as the segments the stroke source draws.
build 🔒
Build the single-sampled scene’s world content.
build_msaa 🔒
Build the multisampled scene’s world content: the same world, frozen under the other snapshot’s name.
built 🔒
The core both builds share; snapshot is the name frame 0 freezes under.
caps_strokes 🔒
The three cap strokes standing left of the orbit, where nothing else draws: flat-cut, round at the head end, and a dot — both ends rounded, the ends coincident. The frame freezes them so a change in how a stroke ends cannot land unreviewed: the caps are a shader decision the rings and the ticks never exercise, closed rings having no ends at all. unreviewed: the caps are a shader decision the rings and the ticks never exercise, closed rings having no ends at all.
orbit 🔒
The orbit and its ticks, as the strokes the line source draws.
sphere 🔒
The unit sphere every body is scaled from, as (positions, normals, indices).
stroke 🔒
One opaque vertical cap stroke from foot up to head, with caps as the record’s end flags.
wash 🔒
The ink a wash carries: rgb washed to WASH_ALPHA.