Expand description
The lit scene: Lambert shading under every kind of built-in light.
One large surface faces the camera, and each of the four light types lays a shape on it, so a frame that drops a light, packs one wrong or clusters one out of its cells changes the pixels rather than only the brightness:
- the two directional lights are constant over the whole scene and own no shape of their own: one rakes the floor from above and one faces the wall, so together they give every surface a gradient without competing with the bounded lights’ patches;
- the point lights are the three small, saturated sources floating where their distance to the wall equals their height above the floor, so each pool runs up the wall and across the floor at the same reach, and the three pools overlap just enough to read as one band of mixed colour;
- the spot light stands at the far left, level with the floor, pointing at the wall: its cone cuts a half disc on the wall with the straight edge on the floor, and a cone packed with the wrong outer angle would light far more of the wall than a half disc;
- the quad lights are the two area sources: a violet rectangle standing upright right where it meets the floor, and a teal triangle standing on its base just above the floor to its left. They are the lights whose shading is not a point term, so a form factor that is zero, negative or far too bright shows up as a missing or blown-out patch – and the pane’s outline lands on the wall as a triangle, which a form factor that integrates the wrong corners cannot match.
Each light owns its own corner of the frame, so the patches stay apart and every shape reads on its own.
Every light has a colour no other has – gold and blue suns, red/green/blue points, an amber spot, a violet quad – so a light that is packed, clustered or shaded wrongly changes a hue rather than only a brightness.
The wall is a relief rather than a plane, displaced out of its own plane by a vertex snippet the scene splices into the built-in lit stage — the same hook a caller uses to shape its own geometry. Being displaced, it is drawn from a mesh with no normal channel, so its fragments take the normal the displaced surface actually has from the world positions across the primitive; the floor in front of it is a plain plane and keeps its own flat normals, so one frame draws both normal sources.
Re-exports§
use super::LitSurface;🔒use super::PlacedLight;🔒use super::SceneControl;🔒use super::SceneDef;🔒use super::SceneOptions;🔒use super::allocate_surface;🔒use super::camera_looking_at;🔒use super::grid;🔒use unlit_ecs::bundle;🔒use unlit_wgpu::pipeline::LitShader;🔒use unlit3d::prelude::*;🔒
Constants§
- AMBIENT 🔒
- The light every fragment gets whether any light reaches it, tinted cold so the parts no light reaches read as shaded rather than as black.
- CAMERA_
EYE 🔒 - How far above the floor, and how far back, the camera sits.
- CAMERA_
TARGET 🔒 - The point the camera looks at: the middle of the floor, where the quad light hangs.
- FLOOR 🔒
- The floor: its depth along z, its width along x, and how far it reaches in front of the camera. The back edge is placed at the wall, so shortening the floor crops empty foreground rather than opening a gap at the wall.
- OVERHEAD_
SPOT 🔒 - The spot light that hangs in front of the wall: where it hangs, and its colour.
- OVERHEAD_
TARGET 🔒 - What that spot aims at: high on the wall, so the cone splashes across the wall and reaches down onto the floor in front of it. It hangs off to the right, clear of the standing pane’s patch.
- POINT_
DEPTH 🔒 - POINT_
HEIGHT 🔒 - How far above the floor the point lights float, and how far in front of the origin. They float near the back wall so each pool runs up it as well.
- POINT_
INTENSITY 🔒 - The intensity of each point light, in the units the shader’s falloff uses.
- POINT_
LIGHTS 🔒 - The three point lights, as x position and colour.
- POINT_
RANGE 🔒 - The reach of each point light: far enough to pool on the floor beneath it and to climb the wall behind it, short enough that the pools stay apart.
- QUAD_
COLOR 🔒 - QUAD_
DEPTH 🔒 - QUAD_
HEIGHT 🔒 - QUAD_
INTENSITY 🔒 - QUAD_
SIZE 🔒 - The flat pane over the front of the floor: its size, how far up it hangs, how far in front of the origin, and how bright it is.
- QUAD_X 🔒
- RELIEF 🔒
- The wall’s relief: how far the noise stands out of it, and how large one cell of its lattice is along x and along y. A noise octave has no direction of its own, so unlike a wave train it reads the same however the frame is cropped.
- SPOT_
INNER 🔒 - The cone’s inner and outer half-angles in degrees, and how bright the spot is.
- SPOT_
INTENSITY 🔒 - SPOT_
OUTER 🔒 - TRIANGLE_
COLOR 🔒 - A second polygon light, standing upright instead of lying flat, and shaped as a triangle: a polygon light is any convex outline, and three corners are enough to show it. The frame merges the fourth corner onto the third.
- TRIANGLE_
FOOT 🔒 - Where the pane’s base edge floats: a little in front of the wall and a little above the floor, so the outline it throws stays compact the way the flat pane’s does.
- TRIANGLE_
INTENSITY 🔒 - TRIANGLE_
TILT_ 🔒DEGREES - How far the standing pane tips back from upright.
- TRIANGLE_
VERTICES 🔒 - The triangle’s corners, in its own plane: a wide base and one apex, so the patch it throws reads as a triangle and not as a band.
- WALL 🔒
- The back wall: how wide, how tall, and how far behind the origin. It stands behind the floor so the key light has a second surface at a right angle to the floor, which is what shows a normal stream that is right for one face and wrong for the other.
- WALL_
SEGMENTS 🔒 - How many quads the wall is split into along x and along y. The relief is a vertex displacement, so this is the resolution it is sampled at.
Statics§
- SCENE
- The scene: one relief floor and one wall, lit by one light of every kind.
Functions§
- build 🔒
- Build the lit scene’s world content.
- wall_
relief 🔒 - The WESL the wall’s vertex stage runs, spliced at the built-in stage’s vertex hook.