#useOverlayfunctionhooknacatamalon
useOverlay(on: boolean) => void
Draws what is created here over the screen effects (usePostProcess, a project's post, a
style's), untouched by them: a HUD that a bloom does not make glow, a menu that the blur behind it
does not blur. It covers everything this part of the scene creates and everything created under
it, however deep; called in the body of a scene, the whole scene.
When, not where. useScreenSpace says where a thing is placed; this says when it is drawn. A
HUD can be pinned without being an overlay, and then it goes through the effects as ever (a
palette, a CRT), and a thing of the world can be an overlay.
Over which effects. All of them, unless the chain has an { overlay: true } entry: then the
effects before it run under the overlay and the ones after it run over it too, so a HUD skips the
bloom and still goes through the CRT (post: [bloom, { overlay: true }, crt]).
Nothing changes its order on screen. Only what is in front of everything that is not an overlay
is drawn over the effects: a thing with something in front of it (a glass, a sprite of the world,
the world of a scene started after) stays where it is, under them, and is said once; so does one
inside the filter or soft mask of something that is not an overlay, which draws what it holds as
one picture. A model drawn over the effects is still hidden by the models in front of it. A HUD
scene goes over a level when it is started after it (useReady(() => scenes.launch('Hud')));
launched from the level's body it starts first, under it.
While a scene changes it is drawn with everything else, under the effects and the cover, and is
back over them once the change is over: the cover stays first in the chain, where a crossing keeps
its picture of the scene going out. The same while the engine's splash fades out over the game.
Parámetros
onbooleanfalse undoes it. Default true.
Ejemplo
const Level = () => {
// Started once the level is up, so the HUD goes over it.
const scenes = useScene();
useReady(() => scenes.launch('Hud'));
return createScene();
};
const Hud = () => {
useScreenSpace();
useOverlay();
createText({ text: 'POINTING AT 17', transform: { x: 8, y: 8 } });
return createScene();
};
// The world, its bloom, the HUD, then a CRT over all of it.
createGame('#app', { post: [{ builtin: 'bloom' }, { overlay: true }, { builtin: 'crt' }] })({ Level, Hud });
Ver el código · hooks/post/use_overlay.ts:58nacatamalon/effects
#asciifunctionnacatamalon/effects
ascii(options: { size, ownColor, ink, background, brightness, glyphs }) => TBuiltinPostEffect<{ size, ownColor, ink, background, brightness }>
Draws the frame in letters: it is cut into cells, and each cell becomes a letter as dense as the
picture is bright there, a space in the dark and @ in the light, in the picture's own colour.
The letters are chosen after everything is drawn, so lights, gradients and reflections come
through on their own. They are 5 × 5 pictures carried in the shader, so nothing has to be loaded.
A bloom() after it makes them glow.
glyphs says which letters, from the darkest to the brightest: ' .oO0@', ' ░▒▓█', or as many
as wanted. Any printable ASCII character, ' ' to '~', and the blocks ░ ▒ ▓ █; one it cannot
draw is left out with a warning. They are written into the shader when the effect is made, so
they are an option and not a uniform: other letters are another ascii().
Parámetros
options{ size, ownColor, ink, background, brightness, glyphs }size is the side of a cell in game pixels, rounded to a multiple of 6 so every
pixel of a letter is the same size (6 is the smallest, 12 letters twice as big); ownColor from
0 (every letter in ink, a terminal) to 1 (the picture's own colour); ink is any colour,
'#4dff73', a TColor or [r, g, b]; background how much of the picture shows behind the
letters, 0 none; brightness how bright the letters are against the colour they were read from;
glyphs the letters, darkest first, ' .:-=+*#W@' when left out.
Ejemplo
usePostProcess(ascii({ size: 6 }));
usePostProcess(ascii({ glyphs: ' ░▒▓█', ownColor: 0, ink: '#ffb000' }));
usePostProcess(bloom({ threshold: 0.45, intensity: 0.8 }));
Ver el código · post/builtin/ascii.ts:64#bloomfunctionnacatamalon/effects
bloom(options: { threshold, intensity, radius }) => TBuiltinPostEffect<{ threshold, intensity, radius }>
Makes bright parts of the picture glow into what is around them, the soft light of the last
consoles of the era.
Only what is brighter than threshold glows. That part is taken at half the game's size, blurred
at a quarter, and added back over the sharp picture, so the glow is wide and cheap.
Parámetros
options{ threshold, intensity, radius }threshold from 0 (everything glows) to 1 (nothing does); intensity how
strong the glow is; radius about how far it reaches, in game pixels.
Ejemplo
usePostProcess(bloom({ threshold: 0.7, intensity: 0.8 }));
Ver el código · post/builtin/bloom.ts:24#blurfunctionnacatamalon/effects
blur(options: { radius, amount }) => TBuiltinPostEffect<{ radius, amount }>
Blurs the whole picture: a pause menu over the game, being out of focus, being underwater.
It is worked out at half the game's size, across and then down, and blown back up smoothly, so
a wide blur costs about what a narrow one does.
Parámetros
options{ radius, amount }radius is about how far a pixel spreads, in game pixels; amount mixes it with
the sharp picture, 1 being all blur.
Ejemplo
const out = usePostProcess(blur({ radius: 6, amount: 0 }));
// when the menu opens: out.uniforms.amount = 1;
Ver el código · post/builtin/blur.ts:24#colorAdjustfunctionnacatamalon/effects
colorAdjust(options: { brightness, contrast, saturation, gamma, hue, tint }) => TBuiltinPostEffect<{ brightness, contrast, saturation, gamma, hue, tint }>
Brightness, contrast, saturation, gamma, a turn of the hue and a tint, in one pass.
Every uniform starts where it changes nothing, so it is safe to put in a chain and drive one number
at a time: saturation: 0 is black and white, tint: [1, 0.8, 0.6] is an old photograph, a hue
of 180 swaps every colour for its opposite. They are applied in that order: gamma, contrast,
brightness, saturation, hue, tint.
Parámetros
options{ brightness, contrast, saturation, gamma, hue, tint }hue is in degrees; the rest are multipliers, 1 being unchanged. tint is any
colour: '#ffd9b0', a TColor or [r, g, b].
Ejemplo
usePostProcess(colorAdjust({ saturation: 0.6, contrast: 1.1, tint: [1, 0.95, 0.85] }));
Ver el código · post/builtin/color_adjust.ts:27#crtfunctionnacatamalon/effects
crt(options: TCrtOptions) => TBuiltinPostEffect<TCrtUniforms>
Makes the frame look as if it were on a CRT television: lines, a phosphor mask, the bulge and the
glow of the glass, and the small faults of a real tube. Each part is a number, and a part at 0 is
not there at all. POST_EFFECTS.CRT_PRESETS has four tubes to start from.
One line per row of the game, not of the screen. The lines follow the game's own pixels, the
way a console's picture sat on the tube, so a game at 320 × 224 has 224 of them however large the
canvas is drawn. When a game row is only one real pixel tall (pixelRatio: 1, the pixel-art
default) a line cannot be drawn inside it, so alternate rows are darkened instead. At two or more
real pixels per row each line gets the shape of a beam, and a bright one widens into the gap.
The mask is the coloured grid of the tube itself and works on real pixels, so it only looks
like a mask at a pixelRatio of 3 or more; below that, maskScale makes it coarser, or leave it
off. That is why it starts switched off.
The glow is worked out at half the game's size, so it costs a little whatever size the canvas
is. noise, flicker and interlace move every frame and start off, so a still scene stays still.
It belongs last in a chain: a palette or a dither decides which colours exist, and the tube
is what those colours are shown on.
It already holds a glow, noise, a vignette, a flicker and a colour split of its own: laid over
bloom, grain, oldFilm or rgbSplit, that part is done twice (see POST_BUILTINS).
Parámetros
optionsTCrtOptionsHow strong each part is; see TCrtOptions.
Ejemplo
usePostProcess(crt());
usePostProcess(crt(POST_EFFECTS.CRT_PRESETS.pvm));
usePostProcess(crt({ ...POST_EFFECTS.CRT_PRESETS.consumer, noise: 0, curvature: 0 }));
// The corners the bulge leaves in the page's own colour instead of black
usePostProcess(crt({ curvature: 0.08, bezel: '#0b0710' }));
Ver el código · post/builtin/crt.ts:411#distortfunctionnacatamalon/effects
distort(options: { center, radius, bulge, twist }) => TBuiltinPostEffect<{ center, radius, bulge, twist }>
Bulges, pinches or twists a round patch of the picture: a lens, a black hole, a whirlpool.
Outside radius nothing moves, and the edge of the patch always meets the picture around it, so
the effect can be dropped anywhere without a seam.
Parámetros
options{ center, radius, bulge, twist }center from { x: 0, y: 0 } (top left) to { x: 1, y: 1 }; radius in game pixels; bulge
from -1 (pinch) to 1 (bulge); twist is how far the middle turns, in radians.
Ejemplo
usePostProcess(distort({ center: { x: 0.5, y: 0.5 }, radius: 60, twist: 2 }));
Ver el código · post/builtin/distort.ts:24#ditherfunctionnacatamalon/effects
dither(options: { levels, amount }) => TBuiltinPostEffect<{ levels, amount }>
Cuts each channel down to a few steps, hiding the bands with an ordered pattern.
This is what the machines of the era did, and doing it here rather than in the artwork means it
applies to everything at once: the sprites, the lighting, the gradients a shader made up.
It works in the frame's own colours, with no trip through linear light and back. That is
deliberate: the hardware it imitates had no notion of linear light, and a physically tidy version
of this bands in the wrong places.
Parámetros
options{ levels, amount }levels is steps per channel, amount how much of the pattern to mix in.
Ejemplo
usePostProcess({ ...dither({ levels: POST_EFFECTS.COLOR_LEVELS.genesis }) });
Ver el código · post/builtin/dither.ts:27#glitchfunctionnacatamalon/effects
glitch(options: { slices, offset, split, amount, rate, seed }) => TBuiltinPostEffect<{ slices, offset, split, amount, rate, seed }>
Tears the picture into horizontal bands and throws some of them sideways, with the colours coming
apart where they land: a signal failing, a save file corrupting, a boss arriving.
The bands are chosen again rate times a second, so it jumps rather than slides, which is what
a broken signal does. amount is the share of bands that move; at 0 it is gone.
Its split is a colour split of its own: over rgbSplit the colours come apart twice (see
POST_BUILTINS).
Parámetros
options{ slices, offset, split, amount, rate, seed }slices is how many bands; offset and split are in game pixels; seed gives a
different pattern of tears.
Ejemplo
const hit = usePostProcess(glitch({ amount: 0 }));
// on a hit: hit.uniforms.amount = 0.6, then ease it back to 0.
Ver el código · post/builtin/glitch.ts:28#godraysfunctionnacatamalon/effects
godrays(options: { center, threshold, density, decay, intensity }) => TBuiltinPostEffect<{ center, threshold, density, decay, intensity }>
Shafts of light streaming out from a point past whatever stands in front of it: sun through
trees, a window in a dark hall, a holy relic.
The bright parts are taken at half the game's size, smeared outwards from center in a second
pass at the same size, and added back over the sharp picture. Only what is brighter than
threshold casts rays, so a dark silhouette in front of a bright sky is what makes them.
Parámetros
options{ center, threshold, density, decay, intensity }center from { x: 0, y: 0 } (top left) to { x: 1, y: 1 }, and it may lie off screen; density
how far the rays reach, from 0 to 1; decay how fast they fade along the way; intensity how
strong they are.
Ejemplo
usePostProcess(godrays({ center: { x: 0.8, y: 0.1 }, threshold: 0.75 }));
Ver el código · post/builtin/godrays.ts:27#grainfunctionnacatamalon/effects
grain(options: { amount, size, animated }) => TBuiltinPostEffect<{ amount, size, animated }>
Sprinkles the picture with grain, new every frame unless told to hold still.
size is in game pixels, so the grain is as chunky as the art around it rather than finer than
anything else on screen.
Parámetros
options{ amount, size, animated }amount is how strong; size how big a grain is; animated false to freeze it.
Ejemplo
usePostProcess(grain({ amount: 0.06 }));
Ver el código · post/builtin/grain.ts:22#halftonefunctionnacatamalon/effects
halftone(options: { size, rotation, mode, ownColor }) => TBuiltinPostEffect<{ size, rotation, mode, ownColor }>
Prints the picture the way a comic or a newspaper did: dots that grow where it is dark
(mode: 'dots', the default), or lines laid over each other as it darkens (mode: 'lines').
The ink is black, or the picture's own colour as ownColor goes to 1. The paper is white.
Parámetros
options{ size, rotation, mode, ownColor }size is one dot, or the gap between lines, in game pixels; rotation
turns the dot grid, in radians (Math.PI / 4, the default, is 45°).
Ejemplo
usePostProcess(halftone({ size: 4, ownColor: 1 }));
Ver el código · post/builtin/halftone.ts:22#lcdfunctionnacatamalon/effects
lcd(options: { grid, ghosting, tint }) => TBuiltinPostEffect<{ grid, ghosting, tint }>
The screen of a handheld: a grid between the pixels, a tint the panel could not help, and pixels
that were slow to change, so anything moving left a ghost behind it.
The grid is one real pixel wide around each game pixel, so it needs a pixelRatio of 2 or more
to have somewhere to go; at 1 there is no gap to draw and it is left out, and at 2 only the
corner of each pixel is darkened, so the picture keeps most of its light. The ghost reads what
the effect showed last frame, which costs two pictures the size of the canvas while it runs.
Its ghosting is a trail of its own: with phosphor too, a thing moving leaves two (see
POST_BUILTINS).
Parámetros
options{ grid, ghosting, tint }grid and ghosting from 0 to 1; tint multiplies every colour, and is any
colour: '#9bbc0f', a TColor or [r, g, b].
Ejemplo
usePostProcess(lcd({ tint: [0.61, 0.73, 0.06], ghosting: 0.5 }));
Ver el código · post/builtin/lcd.ts:31#lutGradefunctionnacatamalon/effects
lutGrade(options: { amount }) => TBuiltinPostEffect<{ amount }>
Looks every colour up in a grading table and mixes towards what it says.
This is grading, not limiting. A table moves colours about (warmer, colder, more contrast, a
green night); a palette or a dither take colours away. They compose, and in one order only:
grade first, limit last. The other way round grades colours the machine could not show and
then picks a neighbour for them, which throws away the whole point of the grade.
Parámetros
options{ amount }amount is how far to go, from the frame untouched at 0 to the table's word at 1.
Ver el código · post/builtin/lut_grade.ts:18#mosaicfunctionnacatamalon/effects
mosaic(options: { size }) => TBuiltinPostEffect<{ size }>
Turns the picture into big square blocks, each the colour at its middle.
The consoles of the era had this in hardware, set from one register, and it was how a game
dissolved into a room or out of a hit. size is in game pixels and is meant to be animated: from
1, which is nothing, up to whatever is coarse enough and back.
Parámetros
options{ size }size is how many game pixels wide one block is.
Ejemplo
const blocks = usePostProcess(mosaic({ size: 1 }));
useUpdate((dt) => { blocks.uniforms.size = Math.min(16, blocks.uniforms.size + dt * 20); });
Ver el código · post/builtin/mosaic.ts:23#motionBlurfunctionnacatamalon/effects
motionBlur(options: { velocity, samples }) => TBuiltinPostEffect<{ velocity, samples }>
Smears the whole picture along one direction, as if it moved during the exposure.
Parámetros
options{ velocity, samples }velocity is the length and direction of the smear in game pixels, as { x, y };
samples how many reads make it up, at most 32.
Ejemplo
const blur = usePostProcess(motionBlur({ velocity: { x: 0, y: 0 } }));
// while dashing: blur.uniforms.velocity = [12, 0];
Ver el código · post/builtin/motion_blur.ts:23#ntscfunctionnacatamalon/effects
ntsc(options: { bleed, crawl, artifacts }) => TBuiltinPostEffect<{ bleed, crawl, artifacts }>
The picture as it came down a composite cable: colour smeared sideways, a crawl of dots along
edges, and rainbows where fine detail confused the set.
Brightness and colour travelled mixed in one signal, and the television could only part them
roughly. So brightness stays sharp and colour bleeds over several pixels (bleed), the colour
that leaks back into brightness crawls with each frame (crawl), and sharp edges in brightness
are taken for colour (artifacts). Artists of the era drew for it: dithered stripes that a cable
blended into a solid colour, which is why some old art only looks right through this.
Parámetros
options{ bleed, crawl, artifacts }Each from 0 (a clean cable) to about 1.
Ejemplo
usePostProcess(ntsc({ bleed: 0.8 }));
usePostProcess(crt(POST_EFFECTS.CRT_PRESETS.composite));
Ver el código · post/builtin/ntsc.ts:26#oldFilmfunctionnacatamalon/effects
oldFilm(options: { sepia, grain, scratches, flicker, vignette }) => TBuiltinPostEffect<{ sepia, grain, scratches, flicker, vignette }>
An old film reel: sepia, grain, a scratch that comes and goes, a flicker and dark edges, all
stepping at twenty-four frames a second whatever the game runs at.
It already holds a grain, a vignette and a flicker of its own: over grain that part is done
twice (see POST_BUILTINS).
Parámetros
options{ sepia, grain, scratches, flicker, vignette }Each part from 0 (absent) to about 1.
Ejemplo
usePostProcess(oldFilm({ sepia: 0.8, scratches: 0.5 }));
Ver el código · post/builtin/old_film.ts:23#paletteMatchfunctionnacatamalon/effects
paletteMatch(options: { dither }) => TBuiltinPostEffect<{ dither }>
Replaces every colour with the nearest one a palette actually holds.
This is the effect that makes a frame look like a particular machine rather than merely like an
old one: a NES palette is fifty-four specific colours, and no amount of cutting channels into
steps will land on them.
A small dither shakes each pixel by less than the gap between neighbours before the search, so a
slow gradient breaks into a mix of two palette entries instead of a hard edge.
With no palette, or one of a single colour, it gives back what it was handed. A palette that
has not arrived yet must cost you the palette and not the picture.
Its dither is a dither of its own: after dither the picture is shaken twice (see
POST_BUILTINS).
Parámetros
options{ dither }dither is how much to shake before matching. Zero matches exactly.
Ejemplo
const nes = useLoadPalette({ src: '/palettes/nes.palette' });
usePostProcess({ ...paletteMatch(), palette: nes });
Ver el código · post/builtin/palette_match.ts:33#phosphorfunctionnacatamalon/effects
phosphor(options: { persistence }) => TBuiltinPostEffect<{ persistence }>
A tube's phosphor, which kept glowing a moment after the beam had gone: bright things moving fast
leave a short trail.
It reads what it showed last frame and keeps whichever is brighter, the new picture or the old
one dimmed by persistence. That costs two pictures the size of the canvas while it runs. Put it
before crt, so the trail is of the picture and not of the lines and the mask.
A trail of its own: with lcd's ghosting too, a thing moving leaves two (see POST_BUILTINS).
Parámetros
options{ persistence }persistence from 0 (none) to just under 1 (a long trail).
Ejemplo
usePostProcess(phosphor({ persistence: 0.5 }));
usePostProcess(crt());
Ver el código · post/builtin/phosphor.ts:26#posterizefunctionnacatamalon/effects
posterize(options: { levels }) => TBuiltinPostEffect<{ levels }>
The same cut as dither, with nothing to hide the seams.
It exists as the other half of the pair rather than as a lesser version: hard bands are a look,
and it is the one that shows what the dithering is actually doing when you put the two side by
side.
The same as dither with amount: 0: one or the other, not both (see POST_BUILTINS).
Parámetros
options{ levels }levels is steps per channel.
Ver el código · post/builtin/posterize.ts:20#rgbSplitfunctionnacatamalon/effects
rgbSplit(options: { red, green, blue }) => TBuiltinPostEffect<{ red, green, blue }>
Reads the red, green and blue of each pixel from three slightly different places.
Each offset is in game pixels, so a split of one pixel stays one pixel wide however large the
canvas is. Small and still, it is a cheap lens; large and shaken, it is a hit.
Parámetros
options{ red, green, blue }red, green and blue are where each channel is read from, as { x, y }.
Ejemplo
usePostProcess(rgbSplit({ red: { x: -2, y: 0 }, blue: { x: 2, y: 0 } }));
Ver el código · post/builtin/rgb_split.ts:24#shockwavefunctionnacatamalon/effects
shockwave(options: { center, radius, amplitude, wavelength, brightness }) => TBuiltinPostEffect<{ center, radius, amplitude, wavelength, brightness }>
A ring that pushes the picture outwards as it passes, from an explosion, a landing, a spell.
It does not grow on its own: radius is where the ring is now, and the game moves it. That keeps
one effect good for any number of blasts, at any speed, with any easing.
Parámetros
options{ center, radius, amplitude, wavelength, brightness }center is where it starts, from { x: 0, y: 0 } (top left) to { x: 1, y: 1 }; radius,
amplitude and wavelength are in game pixels; brightness lights the crest a little.
Ejemplo
const blast = usePostProcess(shockwave({ center: { x: 0.5, y: 0.5 } }));
useUpdate((dt) => { blast.uniforms.radius += dt * 240; });
Ver el código · post/builtin/shockwave.ts:26#tiltShiftfunctionnacatamalon/effects
tiltShift(options: { focus, band, feather, radius }) => TBuiltinPostEffect<{ focus, band, feather, radius }>
Keeps a band of the picture sharp and blurs above and below it, which makes a whole scene look
like a model on a table.
Parámetros
options{ focus, band, feather, radius }focus is where the sharp band sits, from 0 (top) to 1; band how far it
reaches either side, and feather how long the fade into blur is, both as a share of the height;
radius how blurred the rest is, in game pixels.
Ejemplo
usePostProcess(tiltShift({ focus: 0.6, band: 0.1 }));
Ver el código · post/builtin/tilt_shift.ts:22#usePostProcessfunctionhooknacatamalon/effects
usePostProcess(options: TPostProcessOptions<U>) => TPostEffect<U>
Adds a full-screen effect: a shader that reads the finished frame and gives back what to show.
A material changes one thing; this changes the picture. That is what a palette reduction or a
dither has to be, because "what colours may this frame use" is a question about the screen and not
about any sprite on it.
The chain belongs to the game; the entry belongs to the scene. Opening a pause menu over a
level does not change how the screen looks, so effects do not stack up as scenes do. But the scene
that installed one takes it away when it closes.
Order is the order you ask, and order is the picture: each effect reads what the one before it
produced. Grade first and limit last, or you will be grading colours the machine cannot show.
Everything but whether it is switched on is read every frame, so writing a number into the
uniforms of what this gives back animates the effect with nothing reinstalled.
Parámetros
optionsTPostProcessOptions<U>What the effect is, and what to set its uniforms to.
Ejemplo
const Level = () => {
const nes = useLoadPalette({ src: '/palettes/nes.palette' });
usePostProcess({ ...paletteMatch(), palette: nes });
return createScene();
};
Ver el código · hooks/post/use_post_process.ts:45#wavefunctionnacatamalon/effects
wave(options: { amplitude, frequency, speed, axis }) => TBuiltinPostEffect<{ amplitude, frequency, speed, axis }>
Slides each line of the picture sideways by a moving wave: heat over sand, a room under water,
a dream.
It moves whole lines, one game row at a time, which is how the consoles did it: by changing
the scroll of the next line while the screen was being drawn. A smooth version looks like a
modern shader; this one looks like the hardware. axis: 'columns' moves columns up and down instead.
Parámetros
options{ amplitude, frequency, speed, axis }amplitude is how far a line moves, in game pixels; frequency how many waves fit
on the screen; speed how fast they travel; axis 'rows' (the default) or 'columns'.
Ejemplo
usePostProcess(wave({ amplitude: 3, frequency: 6, speed: 4 }));
Ver el código · post/builtin/wave.ts:24#zoomBlurfunctionnacatamalon/effects
zoomBlur(options: { center, reach, samples }) => TBuiltinPostEffect<{ center, reach, samples }>
Smears the picture towards a point, as if the camera rushed at it: speed, a dash, an impact.
Parámetros
options{ center, reach, samples }center from { x: 0, y: 0 } (top left) to { x: 1, y: 1 }; reach is how much of the way
to the centre the smear goes; samples how many reads make it up, at most 32.
Ejemplo
usePostProcess(zoomBlur({ reach: 0.15 }));
Ver el código · post/builtin/zoom_blur.ts:22#TBuiltinPostEffecttypenacatamalon/effects
One of the engine's own effects, ready to be spread into usePostProcess.
Both halves are required here, unlike a game's own effect. These are the engine's, and an
engine effect that ran on one card and not the other would be a hole in the promise that the two
backends draw the same thing, rather than the honest degradation a hand-written WGSL file gets.
Propiedades
namestringfragmentstringfragmentGlslstringuniformsUpassesopcionaltypeOperatorIts steps before fragment, each in both languages, for the same reason the hook is.
historyopcionalbooleanWhether it reads what it showed last frame.
reachopcional
Ver el código · post/builtin/types/t_builtin.ts:17#TCrtOptionstypenacatamalon/effects
What crt() takes. Every part is a number, and a part at 0 is not there at all.
Propiedades
scanlinesopcionalnumberHow dark the gap between two lines of the picture is, from 0 to 1.
maskopcionalnumberHow strong the coloured grid of the tube is, from 0 to 1.
maskTypeopcional'aperture' | 'slot' | 'shadow''aperture' (vertical stripes), 'slot' (staggered cells, a common TV) or 'shadow' (dots in
triangles, an arcade monitor).
maskScaleopcionalnumberHow many real pixels one stripe of the mask is wide. 1 is the finest the screen can show.
curvatureopcionalnumberHow much the glass bulges.
vignetteopcionalnumberHow much darker the corners are.
sharpnessopcionalnumberHow sharply one game pixel turns into the next along a line: 0 is a soft blend, 1 hard steps.
beamopcionalnumberHow much a bright line widens into the gap around it, the way a stronger beam did.
brightnessopcionalnumberWhat the whole picture is multiplied by, to win back what the lines and the mask darken.
linearBlendopcionalbooleantrue (the default) works the lines and the glow out in light rather than in the stored
numbers, which is what a tube did; false works them out in the stored numbers. It changes how the lines blend, not how
bright the picture is: the frame goes into light and back out by the same curve.
halationopcionalnumberThe glow that bright parts throw across the glass.
convergenceopcionalnumberHow far the red and blue beams miss the green one, in game pixels.
noiseopcionalnumberMoving grain.
flickeropcionalnumberA faint flicker and a slow band rolling down the screen.
interlaceopcionalbooleantrue draws odd and even lines on alternate frames.
cornerRadiusopcionalnumberHow round the corners of the tube are, as a share of the screen.
bezelopcionalTColorOption | [number, number, number]The colour around the glass: what fills the corners the bulge leaves, the plastic of the set.
Any colour, '#0b0710', a TColor or [r, g, b]. Default black. The page's colour makes the
tube sit on the page.
Ver el código · post/builtin/crt.ts:14#TCrtUniformstypenacatamalon/effects
The uniforms of the effect crt() returns, as effect.uniforms holds them: the same names as
TCrtOptions, each a plain number. maskType is 0 aperture, 1 slot, 2 shadow;
linearBlend and interlace are 1 for true and 0 for false.
Propiedades
scanlinesnumbermasknumbermaskTypenumbermaskScalenumbercurvaturenumbervignettenumbersharpnessnumberbeamnumberbrightnessnumberlinearBlendnumberhalationnumberconvergencenumbernoisenumberflickernumberinterlacenumbercornerRadiusnumber
Ver el código · post/builtin/crt.ts:99#TEffectFieldtypenacatamalon/effects
One setting of an effect or a look, declared so a form can be made of it: what it is called, what
kind of value it takes and between what, and what it starts at.
Propiedades
keystringIts name: the uniform's (a key of the effect's uniforms), or, for one marked rebuild, the option
the effect is made with.
labelopcionalstringWhat a form calls it. The key, in words, when left out.
descriptionopcionalstringA line about what it does, for a form to show on hover.
type'number' | 'boolean' | 'string' | 'select' | 'color' | 'vec2'How the value is written: 'color' is [r, g, b] from 0 to 1, 'vec2' is [x, y]. A
'select' saves the value of what was chosen.
defaultnumber | string | boolean | number[]What it is when nobody has set it: exactly what the effect starts at.
minopcionalnumbermaxopcionalnumberstepopcionalnumberoptionsopcionaltypeOperator'select' only: what may be chosen.
suggestionsopcionaltypeOperator'string' only: values worth offering, which may still be typed over.
angleopcionaltrue'number' only: a turn, kept in radians like every one in the engine, which a form may show
and take in degrees.
rebuildopcionaltrueWritten into the effect when it is made, not a uniform: changing it makes the effect again, so it
cannot be tweened. A project file keeps it in the entry's options, not its uniforms.
Ver el código · post/builtin/types/t_builtin.ts:46#TPostChaintypenacatamalon/effects
TPostChain: TPostChainEntry[]
The whole chain, in order.
An array rather than a bag of named things, for the reason the input map shares: order is the
meaning here. Each effect reads what the one before it produced, so grading before limiting and
limiting before grading are two different pictures, not two spellings of one.
Ver el código · post/types/t_post_chain.ts:76#TPostChainEntrytypenacatamalon/effects
One effect as a project writes it down.
An entry names its effect one of two ways, and that split is the whole design:
builtin is a key the engine already knows. There is no file to fetch and no path that can
point at nothing, so a project that only reduces its colours needs no shaders/ folder at all.
effect is a path to a .shader (or .wgsl) file, the code of an effect of the game's own: the
same word a material and usePostProcess use for it. A project written before says shader,
and is read the same.
The arithmetic the engine knows is a key; the look you invented is a file.
Propiedades
effectopcionalstringWhere the effect is written. Left out, or empty, when builtin names one instead.
builtinopcionalstringA key from POST_BUILTINS, the engine's own effects. Wins over effect if somebody wrote both.
uniformsopcionalTUniformNumbersValues laid over whatever the file or the built-in starts its uniforms at.
optionsopcionalRecord<string, string | number | boolean>A built-in's settings that are written into it when it is made, rather than uniforms (its fields
marked rebuild, such as ascii's glyphs). Left out when there are none.
paletteopcionalstringA .palette file whose colours this effect matches against.
lutopcionalstringA grading table: a .cube, or a strip image. Never both this and palette.
enabledopcionalbooleanfalse keeps the entry in the chain, in its place, without running it. Default true.
nameopcionalstringWhat the editor calls it in its list. Defaults to the file's own name.
overlayopcionalbooleantrue makes the entry no effect but a place: where what is drawn over the effects
(useOverlay) goes. The effects before it run under it, the ones after it over it too:
[{ builtin: 'bloom' }, { overlay: true }, { builtin: 'crt' }] is a HUD that does not glow on a
curved screen. Without one, it goes after every effect. Written alone: { overlay: true }, and
enabled: false keeps it without using it. One a chain: a project's comes before a style's,
which is then not used. A filter's effects take none.
Ver el código · post/types/t_post_chain.ts:20#TPostEffecttypenacatamalon/effects
An effect the game has installed: a shader that reads the finished frame and gives back what
should be shown instead.
This record is what crosses into the backend, by reference and never copied into something
new. The compiled shader is cached against this object's identity, so building a fresh one each
frame would mean compiling each frame and never once finding the cache.
Everything except enabled is read every frame, so changing a number in uniforms animates the
effect with nothing reinstalled: the same rule a material's uniforms follow.
It holds the palette or the table as the asset, not as an uploaded picture, because a file
lands after the effect was installed. Keeping the picture here would mean keeping the null it
was at the moment the effect was made.
Propiedades
type'post'idstringnamestring | nullWhat a warning about it will call it, and what the editor lists. Never an identity.
fragmentstring | nullfn effect(color: vec4<f32>, uv: vec2<f32>) -> vec4<f32>, and anything it calls.
fragmentGlslstring | nullThe same hook in GLSL, without which the effect is WebGPU only and degrades to nothing.
uniformsUThe uniforms. Read every frame, so writing into this is how a game drives an effect.
uniformSigTUniformSignatureWhat kind each one is. Fixed when the effect is made: the block's layout depends on it.
passesopcionaltypeOperatorThe steps run before fragment, in order, for an effect that needs more than one read of the
frame. Absent for nearly all of them, and absent costs nothing.
historyopcionalbooleanWhether it reads what it showed last frame, through sampleHistory. It costs two pictures the
size of the canvas for as long as the effect runs, which is why it has to be asked for.
paletteTPalette | nullThe colours this effect matches against, for one that reduces to a palette.
A palette and a table are read at opposite ends of a chain and no shader is both, so an
effect carries at most one of the two.
lutTLut | nullThe grading table this effect looks colours up in.
maskopcionalTTextureThe picture a transition reads through sampleMask. Only a transition carries one, and it
has neither a palette nor a table, so the three never meet.
outgoingopcional'take' | 'taken' | 'keep'For a transition that crosses, what to do with the picture of the scene going out, which its
hook reads through sampleOutgoing. Absent for every other effect.
'take' while that scene is still on screen and the picture has not been drawn yet, so it
is taken each frame and is its last one when the swap comes.
'taken' once a frame has been drawn with it and with the hook itself. A card that is
still compiling the hook draws the frame unchanged meanwhile. Set by the card, and the swap
waits for it: one called between two frames, or two steps of the clock in one picture, would
otherwise swap before any picture was taken, and the crossing would be a cut.
'keep' from the swap on.
sourceTPostSourcereachopcionalenabledbooleanWhether it runs. A switched-off effect stays in the chain where it is, so turning it back
on does not move it out from between the two it sat between.
effectTShader | nullThe file it came from, so it can be filled in when that lands.
Ver el código · post/types/t_post_effect.ts:81#TPostPasstypenacatamalon/effects
One step an effect takes before its own hook, for an effect that cannot be done in one read of
the frame: a blur, a glow, a halo.
A pass is written exactly like an effect, fn effect(color, uv), and shares the effect's uniforms.
What changes is what it reads and where it writes: sampleTexture gives the pass before it (the
first one gets the effect's input), and it writes a picture of its own at scale times the
game's size. The effect's own hook runs last, at full size, and reads the last pass the same way,
with sampleInput still giving it the frame the effect was handed.
scale is measured against the game and not the canvas on purpose: a halo at half of a 320 × 224
game costs the same whatever size the canvas is shown at, and looks the same too.
Propiedades
fragmentstringThe pass's hook, in WGSL: fn effect(color: vec4<f32>, uv: vec2<f32>) -> vec4<f32>.
fragmentGlslstring | nullThe same in GLSL. An effect with a pass that lacks it is WebGPU only, as a whole.
scaleopcionalnumberThe size of the picture it writes, against the game's. Default 1.
Ver el código · post/types/t_post_effect.ts:43#TPostProcessOptionstypenacatamalon/effects
What usePostProcess is asked for.
There are three ways to say what the effect is, and they are the same three a material has: write
it here, name a file, or spread one of the engine's own.
Propiedades
nameopcionalstringA name, which is what a warning about this effect will call it, and what an editor lists.
fragmentopcionalstringThe hook, in WGSL: fn effect(color: vec4<f32>, uv: vec2<f32>) -> vec4<f32>.
fragmentGlslopcionalstringThe same hook in GLSL, without which the effect is WebGPU only.
effectopcionalTShader | stringA file from useLoadShader, or the name one was loaded under. Wins over fragment.
uniformsopcionalUThe uniforms, and what they start at. Laid over whatever a file or a built-in says.
uniformSigopcionalTUniformSignatureWhat kind each uniform is, when it is already known.
Left out, it is worked out from the values, which is what a hand-written effect wants. The
engine's own effects pass it because they already know, and because spreading one of them in is
meant to be a whole effect rather than a starting point.
passesopcionaltypeOperatorSteps run before fragment, for an effect that needs more than one read of the frame. Ignored
when effect names a file: a file holds one hook.
historyopcionalbooleanWhether the effect reads what it showed last frame, through sampleHistory. Default false.
paletteopcionalTPalette | nullThe colours to match against, from useLoadPalette.
lutopcionalTLut | nullThe grading table, from useLoadLut. Never set alongside palette.
reachopcionalenabledopcionalbooleanWhether it runs at all. Default true.
Ejemplo
declare const CRT_WGSL: string;
declare const CRT_GLSL: string;
usePostProcess({ fragment: CRT_WGSL, fragmentGlsl: CRT_GLSL, uniforms: { curve: 0.3 } });
usePostProcess({ effect: useLoadShader({ src: '/shaders/crt.wgsl' }) });
usePostProcess({ ...dither({ levels: POST_EFFECTS.COLOR_LEVELS.genesis }) });
Ver el código · post/types/t_post_options.ts:30