Texture sampling internals
Target API: 5 · Target build:
bbb6l5(2026-11-20, production and preprod) · Status: Analyzed (restored from the live generator, c56)
How bloxdTexel / bloxdTextureSize actually compile — the 3-variant texture codegen. The user side: Texture API.
The three variants
Variant 1 — texture pack inactive (stubs)
fn bloxdTextureSize(bloxdSpMipLevel: f32) -> vec2u {
return vec2u(1u);
}
fn bloxdTexel(bloxdSpTextureId: u32, bloxdSpUv: vec2f, bloxdSpMipLevel: f32) -> vec4f {
return vec4f(1.0);
}Code written for the real atlas still compiles and runs here — it just sees white texels and a 1×1 size.
Variant 2 — the atlas path (the game default)
bloxdTextureSize returns textureDimensions(textureAtlas0, u32(clamp(round(bloxdSpMipLevel), 0.0, f32(textureNumLevels(textureAtlas0) - 1u)))). bloxdTexel applies the face’s quarter-turn before the load — the rotation trap written as the generated bloxdSpTurned if-chain:
// Each quarter turn clockwise the face shows its texture at reads the unturned texture at (v, 1 - u)
var bloxdSpTurned = bloxdSpUv;
if (bloxdSpTextureRotation == 1u) {
bloxdSpTurned = vec2f(bloxdSpUv.y, 1.0 - bloxdSpUv.x);
} else if (bloxdSpTextureRotation == 2u) {
bloxdSpTurned = 1.0 - bloxdSpUv;
} else if (bloxdSpTextureRotation == 3u) {
bloxdSpTurned = vec2f(1.0 - bloxdSpUv.y, bloxdSpUv.x);
}(bloxdSpTextureRotation is the engine’s own storage of the input field textureRotation.)
Variant 3 — custom texture-pack textures
textureLoad(<atlas>, min(bloxdSpCellAt * bloxdSpSize + bloxdSpAt, <dims> - 1u), bloxdSpLevel) samples the layered atlas’s per-texture cell; the pack’s own texels go through the bloxdSpOwnTexel path.
The animation frame ladder
Animated textures (43 families) advance at fixed per-family intervals (200 / 250 / 300 ms — the interval column in the texture catalog). Passing an animation-family id to bloxdTexel samples the current frame.
Sampler settings
The block textures are a texture_2d_array; the terrain sampler is nearest + repeat.
Greedy meshing & UV
The mesher merges faces with matching material/AO/light into single rectangles (greedy meshing), so vertex UVs can exceed tile width on merged faces (0.0015 inset at edges). Hardware repeat addressing handles the tiling, so merged faces look seamless — but procedural detail keyed to uv can discontinuity across merge boundaries; key world-dependent effects to bloxdWorldPosition(position) instead.