Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1#define_import_path bevy_pbr::mesh_view_types
3struct ClusterableObject {
4 // For point lights: the lower-right 2x2 values of the projection matrix [2][2] [2][3] [3][2] [3][3]
5 // For spot lights: the direction (x,z), spot_scale and spot_offset
6 light_custom_data: vec4<f32>,
7 color_inverse_square_range: vec4<f32>,
8 position_radius: vec4<f32>,
9 // 'flags' is a bit field indicating various options. u32 is 32 bits so we have up to 32 options.
10 flags: u32,
11 shadow_depth_bias: f32,
12 shadow_normal_bias: f32,
13 spot_light_tan_angle: f32,
14 soft_shadow_size: f32,
15 shadow_map_near_z: f32,
16 texture_index: u32,
17 pad: f32,
18};
20const POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT: u32 = 1u;
21const POINT_LIGHT_FLAGS_SPOT_LIGHT_Y_NEGATIVE: u32 = 2u;
22const POINT_LIGHT_FLAGS_VOLUMETRIC_BIT: u32 = 4u;
23const POINT_LIGHT_FLAGS_AFFECTS_LIGHTMAPPED_MESH_DIFFUSE_BIT: u32 = 8u;
25struct DirectionalCascade {
26 clip_from_world: mat4x4<f32>,
27 texel_size: f32,
28 far_bound: f32,
31struct DirectionalLight {
32 cascades: array<DirectionalCascade, #{MAX_CASCADES_PER_LIGHT}>,
33 color: vec4<f32>,
34 direction_to_light: vec3<f32>,
35 // 'flags' is a bit field indicating various options. u32 is 32 bits so we have up to 32 options.
36 flags: u32,
37 soft_shadow_size: f32,
38 shadow_depth_bias: f32,
39 shadow_normal_bias: f32,
40 num_cascades: u32,
41 cascades_overlap_proportion: f32,
42 depth_texture_base_index: u32,
43 skip: u32,
44};
46const DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT: u32 = 1u;
47const DIRECTIONAL_LIGHT_FLAGS_VOLUMETRIC_BIT: u32 = 2u;
48const DIRECTIONAL_LIGHT_FLAGS_AFFECTS_LIGHTMAPPED_MESH_DIFFUSE_BIT: u32 = 4u;
50struct Lights {
51 // NOTE: this array size must be kept in sync with the constants defined in bevy_pbr/src/render/light.rs
52 directional_lights: array<DirectionalLight, #{MAX_DIRECTIONAL_LIGHTS}u>,
53 ambient_color: vec4<f32>,
54 // x/y/z dimensions and n_clusters in w
55 cluster_dimensions: vec4<u32>,
56 // xy are vec2<f32>(cluster_dimensions.xy) / vec2<f32>(view.width, view.height)
57 //
58 // For perspective projections:
59 // z is cluster_dimensions.z / log(far / near)
60 // w is cluster_dimensions.z * log(near) / log(far / near)
61 //
62 // For orthographic projections:
63 // NOTE: near and far are +ve but -z is infront of the camera
64 // z is -near
65 // w is cluster_dimensions.z / (-far - -near)
66 cluster_factors: vec4<f32>,
67 n_directional_lights: u32,
68 spot_light_shadowmap_offset: i32,
69 environment_map_smallest_specular_mip_level: u32,
70 environment_map_intensity: f32,
71};
73struct Fog {
74 base_color: vec4<f32>,
75 directional_light_color: vec4<f32>,
76 // `be` and `bi` are allocated differently depending on the fog mode
77 //
78 // For Linear Fog:
79 // be.x = start, be.y = end
80 // For Exponential and ExponentialSquared Fog:
81 // be.x = density
82 // For Atmospheric Fog:
83 // be = per-channel extinction density
84 // bi = per-channel inscattering density
85 be: vec3<f32>,
86 directional_light_exponent: f32,
87 bi: vec3<f32>,
88 mode: u32,
91// Important: These must be kept in sync with `fog.rs`
92const FOG_MODE_OFF: u32 = 0u;
93const FOG_MODE_LINEAR: u32 = 1u;
94const FOG_MODE_EXPONENTIAL: u32 = 2u;
95const FOG_MODE_EXPONENTIAL_SQUARED: u32 = 3u;
96const FOG_MODE_ATMOSPHERIC: u32 = 4u;
98#if AVAILABLE_STORAGE_BUFFER_BINDINGS >= 3
99struct ClusterableObjects {
100 data: array<ClusterableObject>,
101};
102struct ClusterLightIndexLists {
103 data: array<u32>,
104};
105struct ClusterOffsetsAndCounts {
106 data: array<array<vec4<u32>, 2>>,
107};
108#else
109struct ClusterableObjects {
110 data: array<ClusterableObject, 204u>,
111};
112struct ClusterLightIndexLists {
113 // each u32 contains 4 u8 indices into the ClusterableObjects array
114 data: array<vec4<u32>, 1024u>,
115};
116struct ClusterOffsetsAndCounts {
117 // each u32 contains a 24-bit index into ClusterLightIndexLists in the high 24 bits
118 // and an 8-bit count of the number of lights in the low 8 bits
119 data: array<vec4<u32>, 1024u>,
120};
121#endif
123struct LightProbe {
124 // This is stored as the transpose in order to save space in this structure.
125 // It'll be transposed in the `environment_map_light` function.
126 light_from_world_transposed: mat3x4<f32>,
127 cubemap_index: i32,
128 intensity: f32,
129 // Whether this light probe contributes diffuse light to lightmapped meshes.
130 affects_lightmapped_mesh_diffuse: u32,
131};
133struct LightProbes {
134 // This must match `MAX_VIEW_REFLECTION_PROBES` on the Rust side.
135 reflection_probes: array<LightProbe, 8u>,
136 irradiance_volumes: array<LightProbe, 8u>,
137 reflection_probe_count: i32,
138 irradiance_volume_count: i32,
139 // The index of the view environment map cubemap binding, or -1 if there's
140 // no such cubemap.
141 view_cubemap_index: i32,
142 // The smallest valid mipmap level for the specular environment cubemap
143 // associated with the view.
144 smallest_specular_mip_level_for_view: u32,
145 // The intensity of the environment map associated with the view.
146 intensity_for_view: f32,
147 // Whether the environment map attached to the view affects the diffuse
148 // lighting for lightmapped meshes.
149 view_environment_map_affects_lightmapped_mesh_diffuse: u32,
150};
152// Settings for screen space reflections.
153//
154// For more information on these settings, see the documentation for
155// `bevy_pbr::ssr::ScreenSpaceReflections`.
156struct ScreenSpaceReflectionsSettings {
157 perceptual_roughness_threshold: f32,
158 thickness: f32,
159 linear_steps: u32,
160 linear_march_exponent: f32,
161 bisection_steps: u32,
162 use_secant: u32,
163};
165struct EnvironmentMapUniform {
166 // Transformation matrix for the environment cubemaps in world space.
167 transform: mat4x4<f32>,
168};
170// Shader version of the order independent transparency settings component.
171struct OrderIndependentTransparencySettings {
172 layers_count: i32,
173 alpha_threshold: f32,
174};
176struct ClusteredDecal {
177 local_from_world: mat4x4<f32>,
178 image_index: i32,
179 tag: u32,
180 pad_a: u32,
181 pad_b: u32,
184struct ClusteredDecals {
185 decals: array<ClusteredDecal>,
Contents