Skip to main content

Selection

Struct Selection 

Source
pub struct Selection { /* private fields */ }
Expand description

Which lights hold the atlas’s light tiles, and its memory of last frame.

Topic 18’s 2026-08-13 rule, whole: eligible lights are ranked by projected screen influence, ties break by index so a frame’s answer does not depend on the order a caller happened to build the list in, they take slots and runs of tiles in that order until either budget runs out, and an incumbent keeps what it holds until a challenger clearly beats it.

A light that gets no tiles still lights. Nothing here removes a light from the frame; it decides which of them also occlude. A light can miss out two ways — no free slot, or no free run long enough — and the second is what a scene with three point lights hits: two cubes leave less than a cube behind them, so the third point light lights without occluding while a spot ranked below it still fits in the tiles left over.

Implementations§

Source§

impl Selection

Source

pub fn update(&mut self, lights: &[Light], camera: &Camera)

Re-runs the selection over lights for camera.

lights is the caller’s own list and the indices below are into it; a caller whose shader rows are offset from it — the sun is row 0 — maps them itself.

The whole camera rather than its eye, since the priority rung: what a light’s map covers on screen depends on the projection as well as on the distance, and coverage is the one number both the ranking and the tile size are decided by.

Source

pub const fn slots(&self) -> &[Option<Assignment>; 4]

What holds each slot, in slot order.

Source

pub fn atlas_rect(&self, slot: usize) -> TileRect

Where atlas slot slot’s map was rendered, in texels — the viewport the shadow pass sets over it.

TileRect::EMPTY for a slot no map was rendered into, and for a slot past TILES, which is the same answer for the same reason: nothing sampled a map there.

Source

pub fn atlas_rects(&self) -> [[f32; 4]; 16]

The same rectangles as the shader reads them, ready for FrameUniforms::shadow_atlas_rect: a scale into the atlas in xy and an offset in zw, one row per slot.

Source

pub fn base_of(&self, index: usize) -> Option<usize>

Where light index’s run of tiles starts, if it was given one.

The number a row carries: Light::row puts it in GpuLight::shadow_tile and the shader reads light_view_proj at it — plus the face, for a point light.

Trait Implementations§

Source§

impl Clone for Selection

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Selection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Selection

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Selection

Source§

impl PartialEq for Selection

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Selection

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HalThreadSafe for T
where T: Send + Sync,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.