1#define_import_path bevy_pbr::mesh_view_types3struct ClusteredLight {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_offset6 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 decal_index: u32,17 range: f32,18};20const POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT: u32 = 1u << 0u;21const POINT_LIGHT_FLAGS_SPOT_LIGHT_Y_NEGATIVE: u32 = 1u << 1u;22const POINT_LIGHT_FLAGS_VOLUMETRIC_BIT: u32 = 1u << 2u;23const POINT_LIGHT_FLAGS_AFFECTS_LIGHTMAPPED_MESH_DIFFUSE_BIT: u32 = 1u << 3u;24const POINT_LIGHT_FLAGS_CONTACT_SHADOWS_ENABLED_BIT: u32 = 1u << 4u;25const POINT_LIGHT_FLAGS_SPOT_LIGHT_BIT: u32 = 1u << 5u;27struct DirectionalCascade {28 clip_from_world: mat4x4<f32>,29 texel_size: f32,30 far_bound: f32,31}33struct DirectionalLight {34 cascades: array<DirectionalCascade, #{MAX_CASCADES_PER_LIGHT}>,35 color: vec4<f32>,36 direction_to_light: vec3<f32>,37 // 'flags' is a bit field indicating various options. u32 is 32 bits so we have up to 32 options.38 flags: u32,39 soft_shadow_size: f32,40 shadow_depth_bias: f32,41 shadow_normal_bias: f32,42 num_cascades: u32,43 cascades_overlap_proportion: f32,44 depth_texture_base_index: u32,45 decal_index: u32,46 sun_disk_angular_size: f32,47 sun_disk_intensity: f32,48};50const DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT: u32 = 1u << 0u;51const DIRECTIONAL_LIGHT_FLAGS_VOLUMETRIC_BIT: u32 = 1u << 1u;52const DIRECTIONAL_LIGHT_FLAGS_AFFECTS_LIGHTMAPPED_MESH_DIFFUSE_BIT: u32 = 1u << 2u;53const DIRECTIONAL_LIGHT_FLAGS_CONTACT_SHADOWS_ENABLED_BIT: u32 = 1u << 3u;55struct RectLight {56 color: vec4<f32>,57 position: vec3<f32>,58 width: f32,59 right: vec3<f32>,60 height: f32,61 up: vec3<f32>,62 range: f32,63};65struct Lights {66 // NOTE: this array size must be kept in sync with the constants defined in bevy_pbr/src/render/light.rs67 directional_lights: array<DirectionalLight, #{MAX_DIRECTIONAL_LIGHTS}u>,68 ambient_color: vec4<f32>,69 // x/y/z dimensions and n_clusters in w70 cluster_dimensions: vec4<u32>,71 // xy are vec2<f32>(cluster_dimensions.xy) / vec2<f32>(view.width, view.height)72 //73 // For perspective projections:74 // z is (cluster_dimensions.z - 1) / log(far / near)75 // w is (cluster_dimensions.z - 1) * log(near) / log(far / near)76 //77 // For orthographic projections:78 // NOTE: near and far are +ve but -z is infront of the camera79 // z is -near80 // w is cluster_dimensions.z / (-far - -near)81 cluster_factors: vec4<f32>,82 n_directional_lights: u32,83 spot_light_shadowmap_offset: i32,84 ambient_light_affects_lightmapped_meshes: u32,85 n_rect_lights: u32,86 rect_lights: array<RectLight, #{MAX_RECT_LIGHTS}u>,87};89struct Fog {90 base_color: vec4<f32>,91 directional_light_color: vec4<f32>,92 // `be` and `bi` are allocated differently depending on the fog mode93 //94 // For Linear Fog:95 // be.x = start, be.y = end96 // For Exponential and ExponentialSquared Fog:97 // be.x = density98 // For Atmospheric Fog:99 // be = per-channel extinction density100 // bi = per-channel inscattering density101 be: vec3<f32>,102 directional_light_exponent: f32,103 bi: vec3<f32>,104 mode: u32,105}107// Important: These must be kept in sync with `fog.rs`108const FOG_MODE_OFF: u32 = 0u;109const FOG_MODE_LINEAR: u32 = 1u;110const FOG_MODE_EXPONENTIAL: u32 = 2u;111const FOG_MODE_EXPONENTIAL_SQUARED: u32 = 3u;112const FOG_MODE_ATMOSPHERIC: u32 = 4u;114#if AVAILABLE_STORAGE_BUFFER_BINDINGS >= 3115struct ClusteredLights {116 data: array<ClusteredLight>,117};118struct ClusterableObjectIndexLists {119 data: array<u32>,120};121struct ClusterOffsetsAndCounts {122 data: array<array<vec4<u32>, 2>>,123};124#else125struct ClusteredLights {126 data: array<ClusteredLight, 204u>,127};128struct ClusterableObjectIndexLists {129 // each u32 contains 4 u8 indices into the ClusterableObjects array130 data: array<vec4<u32>, 1024u>,131};132struct ClusterOffsetsAndCounts {133 // each u32 contains a 24-bit index into ClusterableObjectIndexLists in the high 24 bits134 // and an 8-bit count of the number of lights in the low 8 bits135 data: array<vec4<u32>, 1024u>,136};137#endif139// Whether this light probe contributes diffuse light to lightmapped meshes.140const LIGHT_PROBE_FLAG_AFFECTS_LIGHTMAPPED_MESH_DIFFUSE: u32 = 1;141// Whether this light probe has parallax correction enabled.142const LIGHT_PROBE_FLAG_PARALLAX_CORRECT: u32 = 2;144struct LightProbe {145 // This is stored as the transpose in order to save space in this structure.146 // It'll be transposed in the `environment_map_light` function.147 light_from_world_transposed: mat3x4<f32>,148 // The falloff region, specified as a fraction of the light probe's149 // bounding box.150 falloff: vec3<f32>,151 bounding_sphere_radius: f32,152 // The boundaries of the simulated space used for parallax correction,153 // specified as *half* extents in light probe space.154 parallax_correction_bounds: vec3<f32>,155 intensity: f32,156 world_position: vec3<f32>,157 cubemap_index: i32,158 // Various flags that apply to this light probe.159 flags: u32,160};162struct LightProbes {163 // This must match `MAX_VIEW_LIGHT_PROBES` on the Rust side.164 reflection_probes: array<LightProbe, 8u>,165 irradiance_volumes: array<LightProbe, 8u>,166 reflection_probe_count: i32,167 irradiance_volume_count: i32,168 // The index of the view environment map cubemap binding, or -1 if there's169 // no such cubemap.170 view_cubemap_index: i32,171 // The smallest valid mipmap level for the specular environment cubemap172 // associated with the view.173 smallest_specular_mip_level_for_view: u32,174 view_rotation: vec4<f32>,175 // The intensity of the environment map associated with the view.176 intensity_for_view: f32,177 // Whether the environment map attached to the view affects the diffuse178 // lighting for lightmapped meshes.179 view_environment_map_affects_lightmapped_mesh_diffuse: u32,180};182// Settings for screen space reflections.183//184// For more information on these settings, see the documentation for185// `bevy_pbr::ssr::ScreenSpaceReflections`.186struct ScreenSpaceReflectionsSettings {187 min_perceptual_roughness: f32,188 min_perceptual_roughness_fully_active: f32,189 max_perceptual_roughness_starts_to_fade: f32,190 max_perceptual_roughness: f32,191 edge_fadeout_fully_active: f32,192 edge_fadeout_no_longer_active: f32,193 thickness: f32,194 linear_steps: u32,195 linear_march_exponent: f32,196 bisection_steps: u32,197 use_secant: u32,198};200// See the `ContactShadows` rust struct.201struct ContactShadowsSettings {202 linear_steps: u32,203 thickness: f32,204 length: f32,205#ifdef SIXTEEN_BYTE_ALIGNMENT206 _padding: f32,207#endif208};210struct EnvironmentMapUniform {211 // Transformation matrix for the environment cubemaps in world space.212 transform: mat4x4<f32>,213};215// Shader version of the order independent transparency settings component.216struct OrderIndependentTransparencySettings {217 sorted_fragment_max_count: u32,218 fragments_per_pixel_average: f32,219 alpha_threshold: f32,220};222struct OitFragmentNode {223 color: u32,224 depth_alpha: u32,225 next: u32,226};228struct ClusteredDecal {229 local_from_world: mat4x4<f32>,230 base_color_texture_index: i32,231 normal_map_texture_index: i32,232 metallic_roughness_texture_index: i32,233 emissive_texture_index: i32,234 world_position: vec3<f32>,235 bounding_sphere_radius: f32,236 tag: u32,237 pad_a: u32,238 pad_b: u32,239 pad_c: u32,240}242struct ClusteredDecals {243 decals: array<ClusteredDecal>,244}