simvx.graphics.assets.cubemap_loader¶
Load cubemap textures from 6 face images or equirectangular HDR.
Module Contents¶
Functions¶
Decode a Radiance RGBE / .hdr image to a float32 |
|
Synthesize 6 cube faces with a vertical gradient from |
|
Project an equirectangular |
|
Load a cubemap from 6 face images, an equirect HDR, or a solid colour. |
Data¶
API¶
- simvx.graphics.assets.cubemap_loader.__all__¶
[‘load_cubemap’, ‘decode_rgbe’, ‘equirect_to_cubemap’, ‘gradient_cubemap_faces’]
- simvx.graphics.assets.cubemap_loader.log¶
‘getLogger(…)’
- simvx.graphics.assets.cubemap_loader.decode_rgbe(data: bytes) numpy.ndarray[source]¶
Decode a Radiance RGBE / .hdr image to a float32
(H, W, 3)array.Supports both uncompressed (FORMAT=32-bit_rle_rgbe) headers and the standard run-length-encoded scanline form (the only forms produced by every common HDR exporter: Lightroom, Substance, sIBL Archive). No Pillow / imageio / OpenEXR dependency.
Raises
ValueErrorifdatais not a recognisable RGBE stream.
- simvx.graphics.assets.cubemap_loader.gradient_cubemap_faces(top_rgb: tuple[float, float, float], bottom_rgb: tuple[float, float, float], size: int = 64) list[numpy.ndarray][source]¶
Synthesize 6 cube faces with a vertical gradient from
toptobottom.Returns 6
(size, size, 4)float32 RGBA arrays in Vulkan order[+X, -X, +Y, -Y, +Z, -Z], values in[0, 1]. The gradient is sampled by each texel’s world-space direction (itsycomponent) so the horizon ring is continuous across all faces: texel-row gradients kink at the seams.Math mirrors the web
_gradient_cubemap_faces(web/renderer/web.py) exactly so both backends produce an identical gradient sky / IBL ambient. The two are kept as parallel impls because the web renderer runs in Pyodide and cannot import this module (cubemap_loaderimportsvulkan); a future single-source would move the pure-NumPy core intosimvx.core.
- simvx.graphics.assets.cubemap_loader.equirect_to_cubemap(equirect: numpy.ndarray, face_size: int = 256) list[numpy.ndarray][source]¶
Project an equirectangular
(H, W, 3)HDR image onto 6 cube faces.Returns a list of 6
(face_size, face_size, 4)float32 RGBA arrays in Vulkan cubemap order[+X, -X, +Y, -Y, +Z, -Z]. Sampling is bilinear in the source image; corner pixels stay numerically stable because the direction vectors are normalised before projection. Pure-numpy: vectorised over every pixel of every face for sub-second turnaround at 256² faces.
- simvx.graphics.assets.cubemap_loader.load_cubemap(device: Any, physical_device: Any, queue: Any, cmd_pool: Any, face_paths: list[str] | None = None, hdr_path: str | None = None, colour: tuple[float, float, float] | None = None, face_size: int = 256, faces: list[numpy.ndarray] | None = None) tuple[Any, Any, Any, Any][source]¶
Load a cubemap from 6 face images, an equirect HDR, or a solid colour.
Args: face_paths: List of 6 image paths [+X, -X, +Y, -Y, +Z, -Z]. hdr_path: Single equirectangular .hdr file (Radiance RGBE). Projected onto a 6-face cubemap on the CPU;
face_sizecontrols the per-face resolution (default 256). colour: Solid colour (r, g, b) in 0-1 range (fallback if no paths). face_size: Resolution of each cube face when projecting from an HDR equirect. Ignored for explicitface_paths.Returns: (image_view, sampler, image, memory) tuple for the cubemap.