simvx.graphics.renderer.shadow_pass

Cascaded Shadow Map (CSM) rendering pass.

Module Contents

Classes

ShadowPass

Renders depth from directional light’s POV into a cascaded shadow map atlas.

Data

API

simvx.graphics.renderer.shadow_pass.__all__

[‘ShadowPass’]

simvx.graphics.renderer.shadow_pass.log

‘getLogger(…)’

simvx.graphics.renderer.shadow_pass.MAX_CASCADE_COUNT

None

simvx.graphics.renderer.shadow_pass.DEFAULT_CASCADE_COUNT

None

simvx.graphics.renderer.shadow_pass.SHADOW_MAP_SIZE

2048

simvx.graphics.renderer.shadow_pass.DEPTH_FORMAT

None

class simvx.graphics.renderer.shadow_pass.ShadowPass(engine: Any)[source]

Renders depth from directional light’s POV into a cascaded shadow map atlas.

Atlas layout: MAX_CASCADE_COUNT images side-by-side horizontally. Total size: SHADOW_MAP_SIZE * MAX_CASCADE_COUNT × SHADOW_MAP_SIZE. The fragment shader’s loop iterates active_cascade_count slices so 1–4 cascades can be selected at runtime via WorldEnvironment.shadow_cascade_count without recompiling shaders.

Initialization

setup(ssbo_layout: Any) None[source]

Initialize shadow map resources.

property shadow_texture_index: int[source]

Bindless index of the shadow map atlas texture.

compute_cascades(view: numpy.ndarray, proj: numpy.ndarray, light_dir: numpy.ndarray, near: float = 0.0, far: float = 0.0) None[source]

Compute cascade split distances and light-space VP matrices.

Delegates to shadow_math.compute_cascades for self.cascade_count slices and transposes to GLSL column-major for the SSBO upload. Slots beyond self.cascade_count are zeroed so the shader’s active_cascade_count clamp leaves them untouched.

render(cmd: Any, instances: list, ssbo_set: Any, mesh_registry: Any, multimesh_draws: list | None = None, materials: numpy.ndarray | None = None) None[source]

Record shadow depth rendering commands for per-instance and MultiMesh draws.

multimesh_draws entries are 9-tuples: (mesh_handle, base, count, vp_id, double_sided, centres, radii, union_min, union_max). Each block is drawn as ONE instanced shadow command (first_instance=base, instance_count=count) per cascade – coarse, no per-instance cull.

materials is the renderer’s material SSBO array; per-instance casters whose material is alpha-tested (blend="cutoff") are routed through the cutout pipeline, which discards holed fragments so the shadow shows the cutout. With no cutout caster present the cutout list is empty and the opaque draw set is byte-identical to the plain opaque pass.

cleanup() None[source]

Release all GPU resources.