Some textures are a function of position: a sunset behind the dominoes, food that a slime mould smells, a slider’s distance field, the shadows props cast on a floor. Computing such a function in every shader that reads it costs too much, so you bake it into a texture when its inputs change. baker.create takes the function and the texture, and writes every in your .
A baker's function runs at the centre of each texel
Try Tap a texel, or use the arrow keys, to see the uv its function receives. It lands on the texel's centre, so no texel reads an edge.
Allocates memory on the GPU, allows passing data between host and shader.
Read-only on the GPU, optimized for small data. For a general-purpose buffer,
use
TgpuRoot.createBuffer
.
@param ― typeSchema The type of data that this buffer will hold.
@param ― initial Either initial value of the buffer, or an initializer to execute on the mapped buffer. (optional)
Records the texels. A texture with storage usage fills in a compute pass, the pass given or
one of its own on the encoder. Another fills in a render pass per array layer on the encoder.
record(
frame:frames.Frame
frame.
Frame.encoder: TgpuCommandEncoder
Records commands for submission after the recorder returns. submit() replaces this encoder.
Read it at each call instead of keeping it, and let the frame submit it.
encoder);// after `sun` moves
});
texel receives uv from 0 to 1 across the texture from its top-left corner, at the centre of the texel it returns, and the array layer.
It can read buffers, uniforms and textures, and with pipe, as the jelly world’s floor reads its props: tgpu.fn(cast).pipe(world.inject()).
record writes the first mip level. Record mipmaps after it for the smaller ones.
A texture with storage usage fills in a compute pass, the one you give or one of its own on the encoder. A texture without it, such as an rgba8unorm-srgb one that no can write, fills in a render pass per array layer, so record takes the encoder.
The texture is a single-sampled 2D colour texture that holds floats, and texel returns a vec4f; a format with fewer channels keeps the first ones. create throws on another, naming the property.
texelA texel is one cell of a texture, as a pixel is one cell of the screen.Words →
frameA frame is one turn of the loop, and the object your function gets for it, which holds the encoder, the time and the time since the last frame.You own the frame →