Skip to main content

ClusterParams

Struct ClusterParams 

Source
#[repr(C)]
pub struct ClusterParams {
Show 13 fields pub inv_view_proj: [[f32; 4]; 4], pub cam_pos: [f32; 3], pub z_near: f32, pub view_forward: [f32; 3], pub z_far: f32, pub grid_x: u32, pub grid_y: u32, pub grid_z: u32, pub num_lights: u32, pub screen_w: f32, pub screen_h: f32, pub use_clusters: u32, pub _pad: u32,
}
Expand description

Per-frame uniform for the clustered light-binning compute pass and the forward pass that reads the per-cluster lists. The compute kernel unprojects each cluster’s screen tile through inv_view_proj and walks camera rays to the slice’s near/far depth to build a world-space AABB (same convention as the fog froxel kernel), then tests each GpuLight sphere against it. The forward pass reads the grid dims + depth range + screen size to map a fragment to its cluster. 128 bytes; packed_float3 keeps cam_pos / view_forward inside their 16-byte lanes. Must match the ClusterParams struct in the light-cull and forward shaders.

Fields§

§inv_view_proj: [[f32; 4]; 4]

Inverse view-projection; unprojects a clip-space corner to world space.

§cam_pos: [f32; 3]

Camera world position; ray origin for the cluster-AABB build.

§z_near: f32

Camera near plane in view units (positive distance).

§view_forward: [f32; 3]

Camera forward axis (world space, unit); projects a ray onto view depth.

§z_far: f32

Far bound of the clustered range in view units (positive distance).

§grid_x: u32

Cluster tiles across the screen.

§grid_y: u32

Cluster tiles down the screen.

§grid_z: u32

Exponential depth slices per cluster column.

§num_lights: u32

Number of valid GpuLight entries the kernel bins.

§screen_w: f32

Render-target size in pixels; maps a fragment’s position.xy to a tile.

§screen_h: f32

Render-target height in pixels.

§use_clusters: u32

1 = the forward pass reads the per-cluster list (main camera); 0 = it falls back to iterating all num_lights lights (planar / probe re-renders, whose viewpoint differs from the grid the main camera binned).

§_pad: u32

Padding so the field layout matches the shader-side struct.

Implementations§

Source§

impl ClusterParams

Source

pub const ZERO: ClusterParams

Neutral params for context construction before the first per-frame update. use_clusters = 0 so the forward pass falls back to brute-force iteration until a real frame’s camera fills the grid.

Trait Implementations§

Source§

impl Clone for ClusterParams

Source§

fn clone(&self) -> ClusterParams

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 Copy for ClusterParams

Source§

impl Debug for ClusterParams

Source§

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

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

impl NoUninit for ClusterParams

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more