Source code for simvx.graphics.renderer.tile_types
"""Tilemap GPU instance layout: shared between Vulkan and WebGPU backends."""
import numpy as np
__all__ = ["TILE_INSTANCE_DTYPE", "TILE_COLOUR_DTYPE"]
# Must match TileInstance in tilemap.vert (Vulkan) and tilemap.wgsl (WebGPU).
TILE_INSTANCE_DTYPE = np.dtype(
[
("position", np.float32, 2), # world position (x, y)
("tile_uv_offset", np.float32, 2), # UV offset into tileset atlas
("tile_uv_size", np.float32, 2), # UV size of one tile in atlas
("flip_h", np.uint32), # horizontal flip flag
("flip_v", np.uint32), # vertical flip flag
]
)
# Optional per-tile tint, in a SEPARATE buffer indexed parallel to
# TILE_INSTANCE_DTYPE (same tile_id). Kept out of the instance record so the
# common untinted path stays byte-identical and pays zero per-tile colour bytes:
# a layer with no tint sets has_colour=0 and the shader substitutes white. The
# frag does texel * colour and samples white when the tile has no atlas, so a
# tinted-but-textureless tile renders as a solid filled cell. RGBA float32.
TILE_COLOUR_DTYPE = np.dtype((np.float32, 4))