A shader so far worked only on its own wearer. Effects over the whole
game picture, such as a vignette, grey, scanlines or a red flash on a
hit, had no place to live. A camera now wears one, drawn the way a
field shader of a particle source is (#170).
- The camera gets a Shader row and, while one is picked, a Shader
resolution row. The shader's properties follow as camera rows. They
load, animate and appear in a Properties node under Type Camera.
- Every view keeps masks and objects in one container. CameraShade
renders it into the camera's picture, cleared to the background,
and draws the shader over the frame. Game tab and play.html take
the container off the stage while the picture stands in for it.
- Screen pixels gives the picture as many pixels as it covers on
screen. Camera pixels uses View width x View height and scales up
without smoothing.
- A pixel counts as a camera pixel in both (the user's choice). The
uniform uPixelScale makes Texture size read View width x View
height, so a Blur keeps its reach at any game scale.
- Each camera wears its own shader, overlay cameras included. A red
flash on the game camera leaves the HUD of an overlay camera alone.
- The scene view's eye has a Shader switch on the Camera row, off by
default. With it on, the main camera's shader lies over its frame,
below symbols and gizmos, and the world around it stays drawn.
- New tool tools/perf-camera-shader.mjs measures the cost.
Measured on stein2 (HD 630, Game tab at Fit 1310x679): a camera
shader that hands the picture through stays inside the scene's own
spread of 3 to 5 fps between runs. A Blur of 4 cost 4 to 8 fps.
Tests:
- Gate on melektaus-atx: 227 files, 3497 tests (3487 + 10).
- e2e 63 alone: 11 checks (6 + 5), e2e sum 1725 counted.
- 63e-63i: pass-through is byte-equal and upright at 100%, flat red
reaches the corners while the overlay keeps its green, Texture
size reads 640 x 360 in both resolutions at Fit, no shader draws
as before, and the scene view shows it only with the switch on.
- Counter-checks: a camera left out of the shader wearers fails 1
unit test. Counting screen pixels fails 63g with #ab6000.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A camera could only show the whole scene, so a HUD drawn in the world
would run through a camera shader (#299) with everything else. Render
layers say which cameras see an object, and overlay cameras draw their
own picture over the main one.
- The project has a list of up to 16 render layers, edited in Project
settings next to the collision layers. It is a list of its own, read
by the same rules (`layerNamesOf`).
- Sprites, texts, tilemaps, particle sources and containers carry a row
`Render layer` under their switches. Its default `Inherit` takes the
parent's layer, at the top the first one.
- A camera has `Sees` (all layers by default) and `Overlay`. The main
camera is the first one switched on without Overlay, so two plain
cameras still draw through the first one only.
- Every view through a camera keeps only what that camera sees and lays
one see-through view per overlay camera over itself. That view is a
`WorldViewport` of its own, handed its view and frame from below.
- An overlay is fitted into the main camera's whole picture without
distortion. One of the same size and zoom covers it exactly.
- `z` sorts within one camera only. The pictures lie on top of each
other as a whole, which is what a shader per camera (#299) needs.
- The Game tab's preview now collects the scene once per redraw. Before
it collected it twice, with the cameras it would have been five times.
- `SetCollisionLayersCommand` became `SetLayerNamesCommand`, which
takes the list it sets.
Follow-ups: #304 (the mouse through a chosen camera) and #305 (change
the render layer at run time).
Tests:
- Gate: 226 files, 3487 tests (3480 + 7)
- e2e 63 (new): 4 checks. A green overlay sprite at z -10 covers a
red main sprite at z 1000, in the preview and in the running game.
A `UI` sprite in front of the main camera and a `Default` one in
front of the overlay stay away. Without Overlay the second camera
draws nothing. The settings dialog adds a render layer at the end.
- Counter-checks: inheriting from parents switched off fails 1 unit
test. Overlays never drawn fails the two overlay checks in e2e 63.
- e2e total 1720 (1716 + 4), computed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>