Skip to main content

Module shadow

Module shadow 

Source
Expand description

Shadow rendering: mask → 2-pass Gaussian blur → composite onto main target.

For each ShadowDesc:

  1. Clear ping texture to transparent.
  2. Render white rect mask of the (offset-shifted) rect into ping using the solid pipeline.
  3. Horizontal blur ping → pong.
  4. Vertical blur pong → ping.
  5. Composite ping (tinted by shadow colour) onto the main target_view using LoadOp::Load (alpha blending — shadow renders under content because it is composited before the solid/gradient/textured passes).

When blur_radius <= 0.5 the blur passes are skipped and the white mask is composited directly, yielding a crisp (hard-edge) shadow.

Ping-pong textures are allocated once per render_shadows call and shared across all shadows in the draw list.

Structs§

ShadowDesc
A parsed, ready-to-render shadow.
ShadowGpuState
GPU device/queue state needed for shadow rendering.
ShadowPipelines
The three GPU pipelines needed for shadow rendering.
ShadowRenderStats
Render pass and draw call counts accumulated across all shadow descriptions submitted by a single render_shadows call.

Constants§

MAX_BLUR_RADIUS
Maximum Gaussian blur radius in pixels. Clamped to bound the tap-loop iteration count (2 * MAX_BLUR_RADIUS + 1 = 129 iterations worst-case).

Functions§

collect_shadows
Collect all DrawCommand::BoxShadow entries from list into ShadowDesc values, translating each rect by its offset.
render_shadows
Render all descs shadows, compositing each onto gpu.target_view.