Skip to main content

Grid

Struct Grid 

Source
pub struct Grid {
    pub x: u32,
    pub y: u32,
    pub slices: u32,
    pub tile_pixels: u32,
}
Expand description

The extent of one frame’s froxel grid.

Held together in one type because the four numbers are decided at once and are read by two shaders: writing three of them into the frame block and deriving the fourth somewhere else is how the clustering pass and the fragment stage would come to index different froxels.

Fields§

§x: u32

Froxels across the screen.

§y: u32

Froxels down the screen.

§slices: u32

Depth slices: CLUSTER_DEPTH_SLICES for a perspective camera, 1 for an orthographic one, and fewer than either where the grid would not fit.

§tile_pixels: u32

How many pixels wide and tall one tile is.

Implementations§

Source§

impl Grid

Source

pub fn for_frame(extent: (u32, u32), perspective: bool, froxels: u32) -> Self

The grid for a viewport, under a froxel budget.

perspective decides whether there is a depth split at all: an orthographic camera’s clip.w is 1 everywhere, so it has no view depth for a slice index to come from, and it runs with one slice per tile spanning its whole depth range. Coarser, correct, and stated — see light_cluster.slang’s orthographic branch, which builds that froxel a different way rather than pretending it is a perspective one.

Source

pub const fn froxels(&self) -> u32

How many froxels this grid has, which is the clustering dispatch’s extent and the number of records the pass writes.

Source

pub const fn to_frame_block(&self) -> [u32; 4]

The four numbers as FrameUniforms::cluster_grid.

Trait Implementations§

Source§

impl Clone for Grid

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

Source§

impl Debug for Grid

Source§

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

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

impl Eq for Grid

Source§

impl PartialEq for Grid

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 Grid

Auto Trait Implementations§

§

impl Freeze for Grid

§

impl RefUnwindSafe for Grid

§

impl Send for Grid

§

impl Sync for Grid

§

impl Unpin for Grid

§

impl UnsafeUnpin for Grid

§

impl UnwindSafe for Grid

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.