Advanced search tips: use spaces to require multiple terms (AND), | for alternatives (OR), wrap phrases in quotes (="a b"), =term for exact match, 'term to include, !term to exclude, ^term to match prefix, !^term to exclude prefix, .ext$ to match suffix, and !.ext$ to exclude suffix.

cluster_raster.wgsl

Bindings

z_slices

#
@group(0)
@binding(0)
var<storage> z_slices: array<ClusterableObjectZSlice>

index_lists

#
@group(0)
@binding(1)
var<storage, read_write> index_lists: ClusterableObjectIndexLists

clustered_lights

#
@group(0)
@binding(2)
var<storage> clustered_lights: ClusteredLights

light_probes

#
@group(0)
@binding(3)
var<uniform> light_probes: LightProbes

clustered_decals

#
@group(0)
@binding(4)
var<storage> clustered_decals: ClusteredDecals

lights

#
@group(0)
@binding(5)
var<uniform> lights: Lights

view

#
@group(0)
@binding(6)
var<uniform> view: View

offsets_and_counts

#

Shader defs requirments:

🟢 POPULATE_PASS

@group(0)
@binding(7)
var<storage> offsets_and_counts: ClusterOffsetsAndCounts

scratchpad_offsets_and_counts

#

Shader defs requirments:

🟢 POPULATE_PASS

@group(0)
@binding(8)
var<storage, read_write> scratchpad_offsets_and_counts: ClusterOffsetsAndCountsAtomic

offsets_and_counts

#

Shader defs requirments:

šŸ”“ POPULATE_PASS

@group(0)
@binding(7)
var<storage, read_write> offsets_and_counts: ClusterOffsetsAndCountsAtomic

Structures

Vertex

#
struct Vertex {
@builtin(instance_index)
instance_id: u32 ,
@location(0)
position: vec2<f32> ,
}

Varyings

#

Data output from the vertex shader and input to the fragment shader.

struct Varyings {
@builtin(position)
position: vec4<f32> ,
@location(0)
@interpolate(flat)
instance_id: u32 ,
@location(1)
@interpolate(flat)
sphere_position: vec3<f32> ,
@location(2)
@interpolate(flat)
sphere_radius: f32 ,
}

ClusterOffsetsAndCountsAtomic

#

The same as the ClusterOffsetsAndCounts structure, but with atomic fields so that we can write to it.

struct ClusterOffsetsAndCountsAtomic { }

ClusterOffsetsAndCountsElementAtomic

#

The same as the ClusterOffsetsAndCountsElement structure, but with atomic fields so that we can write to it.

struct ClusterOffsetsAndCountsElementAtomic {
offset: atomic<u32> ,
point_lights: atomic<u32> ,
spot_lights: atomic<u32> ,
reflection_probes: atomic<u32> ,
irradiance_volumes: atomic<u32> ,
decals: atomic<u32> ,
pad_a: u32 ,
pad_b: u32 ,
}

Functions

vertex_main

#
@vertex
Processes each 3D point in a model before it's drawn

The vertex entry point.

fn vertex_main (
vertex: Vertex
) -> Varyings

calculate_vertex_position

#

Returns the position of the quad vertex necessary to enclose all the fragments that represent the cluster AABB. The cluster bounds are supplied as vec4(min X, min Y, max X, max Y).

fn calculate_vertex_position (
vertex: Vertex
cluster_bounds: vec4<u32>
) -> vec4<f32>

fragment_main

#
@fragment
Calculates the final color of each pixel on the screen

Performs a fine-grained test to ensure that the object intersects a single froxel and records the result.

fn fragment_main (
varyings: Varyings
) ->
@location(0)
vec4<f32>

sphere_intersects_aabb

#

Returns true if the given sphere intersects the AABB with the given boundaries.

fn sphere_intersects_aabb (
sphere_center: vec3<f32>
sphere_radius: f32
aabb_center: vec3<f32>
aabb_half_size: vec3<f32>
) -> bool

compute_aabb_for_cluster

#

See bevy_light::cluster::assign::compute_aabb_for_cluster.

fn compute_aabb_for_cluster (
z_near: f32
z_far: f32
tile_size: vec2<f32>
screen_size: vec2<f32>
view_from_clip: mat4x4<f32>
is_orthographic: bool
cluster_dimensions: vec3<u32>
) -> Aabb

screen_to_view

#

Converts a screen-space position to a view-space position. See bevy_light::cluster::assign::screen_to_view.

fn screen_to_view (
screen_size: vec2<f32>
view_from_clip: mat4x4<f32>
ndc_z: f32
) -> vec4<f32>

clip_to_view

#

Converts a clip-space position to a view-space position. See bevy_light::cluster::assign::clip_to_view.

fn clip_to_view (
view_from_clip: mat4x4<f32>
) -> vec4<f32>

line_intersection_to_z_plane

#

Calculate the intersection of a ray from the eye through the view space position to a z plane See bevy_light::cluster::assign::line_intersection_to_z_plane.

fn line_intersection_to_z_plane ( ) -> vec3<f32>

compute_z_near_and_z_far

#

Computes the near and far extents of the cluster grid.

fn compute_z_near_and_z_far (
is_orthographic: bool
) -> vec2<f32>

cull_spot_light

#

Returns true if a spot light should be culled. See assign_objects_to_clusters in bevy_light/src/cluster/assign.rs.

fn cull_spot_light (
object_index: u32
cluster_aabb_sphere_center: vec3<f32>
cluster_aabb_sphere_radius: f32
sphere_position: vec3<f32>
sphere_radius: f32
) -> bool

cos_atan

#
fn cos_atan (
tan_theta: f32
) -> f32

sin_atan

#
fn sin_atan (
tan_theta: f32
) -> f32

allocate_list_entry

#

Shader defs requirments:

🟢 POPULATE_PASS

Allocates space in the appropriate list and returns the global index that the object index should be written to.

fn allocate_list_entry (
cluster_index: u32
object_type: u32
) -> u32

increment_object_count

#

Shader defs requirments:

šŸ”“ POPULATE_PASS

Increments the count of objects of the given type for the given cluster.

fn increment_object_count (
cluster_index: u32
object_type: u32
)

get_object_bounding_sphere

#

Looks up and returns the world-space center and radius of the bounding sphere for the object with the given index and type. Returns a 4-vector with the fields vec4(center X, center Y, center Z, radius).

fn get_object_bounding_sphere (
object_index: u32
object_type: u32
) -> vec4<f32>