simvx.graphics.renderer.billboard2d_data

Billboard2D data layout + row builders (vulkan-free, shared desktop + web).

The BILLBOARD_DTYPE SSBO row layout and the pure NumPy row builders for the depth-tested 2D-in-3D billboards (Sprite3D images + Text3D MSDF glyphs, design §5.2). Kept free of any vulkan import so the web export can bundle it: the GPU pass (:mod:.billboard2d_pass) re-exports these for the desktop Vulkan path, and :class:simvx.web.renderer.web.WebRenderer builds the identical rows for the WebGPU backend, so a scene billboards byte-identically on both backends.

Module Contents

Functions

build_sprite3d_row

Build one BILLBOARD_DTYPE Sprite3D row (shared desktop + web).

build_text3d_rows

Build the BILLBOARD_DTYPE MSDF glyph rows for a Text3D run (shared).

Data

API

simvx.graphics.renderer.billboard2d_data.__all__

[‘BILLBOARD_DTYPE’, ‘FLAG_IS_MSDF’, ‘build_sprite3d_row’, ‘build_text3d_rows’]

simvx.graphics.renderer.billboard2d_data.BILLBOARD_DTYPE

‘dtype(…)’

simvx.graphics.renderer.billboard2d_data.FLAG_IS_MSDF

1

simvx.graphics.renderer.billboard2d_data.build_sprite3d_row(*, texture_id: int, position: Any, width: float, height: float, uv: tuple[float, float, float, float], colour: Any = (1.0, 1.0, 1.0, 1.0), centered: bool = True, offset: tuple[float, float] = (0.0, 0.0)) numpy.ndarray | None[source]

Build one BILLBOARD_DTYPE Sprite3D row (shared desktop + web).

The quad is anchored at position and sized width x height in world units on the camera-facing plane; centered keeps it on the anchor, otherwise its top-left corner sits on the anchor. Returns None when the texture is unresolved so callers can skip. The camera basis is applied by the per-backend billboard shader.

simvx.graphics.renderer.billboard2d_data.build_text3d_rows(*, text: str, position: Any, resolve_atlas_slot: Any, font_scale: float = 1.0, pixel_size: float = 0.01, colour: Any = (1.0, 1.0, 1.0, 1.0), alignment: str = 'centre', offset: tuple[float, float] = (0.0, 0.0)) numpy.ndarray | None[source]

Build the BILLBOARD_DTYPE MSDF glyph rows for a Text3D run (shared).

Reuses the unified glyph layout (:func:layout_glyph_run) so kerning / size match every other text node, maps the pixel-space glyph quads into world units (pixel_size) on the camera-facing plane centred about the anchor, and emits one is_msdf row per glyph. Returns None for empty text / unlaid runs / an unresolved atlas.

resolve_atlas_slot is a zero-arg callable returning the backend’s MSDF atlas texture slot. It is invoked AFTER layout_glyph_run so this run’s glyphs are already in the shared atlas before the backend (re)uploads it, keeping first-frame text correct on both backends.