1#define_import_path bevy_pbr::mesh_view_types3struct 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_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 pad_a: f32,17 pad_b: 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;24struct DirectionalCascade {25 clip_from_world: mat4x4<f32>,26 texel_size: f32,27 far_bound: f32,28}30struct DirectionalLight {31 cascades: array<DirectionalCascade, #{MAX_CASCADES_PER_LIGHT}>,32 color: vec4<f32>,33 direction_to_light: vec3<f32>,34 // 'flags' is a bit field indicating various options. u32 is 32 bits so we have up to 32 options.35 flags: u32,36 soft_shadow_size: f32,37 shadow_depth_bias: f32,38 shadow_normal_bias: f32,39 num_cascades: u32,40 cascades_overlap_proportion: f32,41 depth_texture_base_index: u32,42 skip: u32,43};45const DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT: u32 = 1u;46const DIRECTIONAL_LIGHT_FLAGS_VOLUMETRIC_BIT: u32 = 2u;48struct Lights {49 // NOTE: this array size must be kept in sync with the constants defined in bevy_pbr/src/render/light.rs50 directional_lights: array<DirectionalLight, #{MAX_DIRECTIONAL_LIGHTS}u>,51 ambient_color: vec4<f32>,52 // x/y/z dimensions and n_clusters in w53 cluster_dimensions: vec4<u32>,54 // xy are vec2<f32>(cluster_dimensions.xy) / vec2<f32>(view.width, view.height)55 //56 // For perspective projections:57 // z is cluster_dimensions.z / log(far / near)58 // w is cluster_dimensions.z * log(near) / log(far / near)59 //60 // For orthographic projections:61 // NOTE: near and far are +ve but -z is infront of the camera62 // z is -near63 // w is cluster_dimensions.z / (-far - -near)64 cluster_factors: vec4<f32>,65 n_directional_lights: u32,66 spot_light_shadowmap_offset: i32,67 environment_map_smallest_specular_mip_level: u32,68 environment_map_intensity: f32,69};71struct Fog {72 base_color: vec4<f32>,73 directional_light_color: vec4<f32>,74 // `be` and `bi` are allocated differently depending on the fog mode75 //76 // For Linear Fog:77 // be.x = start, be.y = end78 // For Exponential and ExponentialSquared Fog:79 // be.x = density80 // For Atmospheric Fog:81 // be = per-channel extinction density82 // bi = per-channel inscattering density83 be: vec3<f32>,84 directional_light_exponent: f32,85 bi: vec3<f32>,86 mode: u32,87}89// Important: These must be kept in sync with `fog.rs`90const FOG_MODE_OFF: u32 = 0u;91const FOG_MODE_LINEAR: u32 = 1u;92const FOG_MODE_EXPONENTIAL: u32 = 2u;93const FOG_MODE_EXPONENTIAL_SQUARED: u32 = 3u;94const FOG_MODE_ATMOSPHERIC: u32 = 4u;96#if AVAILABLE_STORAGE_BUFFER_BINDINGS >= 397struct ClusterableObjects {98 data: array<ClusterableObject>,99};100struct ClusterLightIndexLists {101 data: array<u32>,102};103struct ClusterOffsetsAndCounts {104 data: array<vec4<u32>>,105};106#else107struct ClusterableObjects {108 data: array<ClusterableObject, 204u>,109};110struct ClusterLightIndexLists {111 // each u32 contains 4 u8 indices into the ClusterableObjects array112 data: array<vec4<u32>, 1024u>,113};114struct ClusterOffsetsAndCounts {115 // each u32 contains a 24-bit index into ClusterLightIndexLists in the high 24 bits116 // and an 8-bit count of the number of lights in the low 8 bits117 data: array<vec4<u32>, 1024u>,118};119#endif121struct LightProbe {122 // This is stored as the transpose in order to save space in this structure.123 // It'll be transposed in the `environment_map_light` function.124 light_from_world_transposed: mat3x4<f32>,125 cubemap_index: i32,126 intensity: f32,127};129struct LightProbes {130 // This must match `MAX_VIEW_REFLECTION_PROBES` on the Rust side.131 reflection_probes: array<LightProbe, 8u>,132 irradiance_volumes: array<LightProbe, 8u>,133 reflection_probe_count: i32,134 irradiance_volume_count: i32,135 // The index of the view environment map cubemap binding, or -1 if there's136 // no such cubemap.137 view_cubemap_index: i32,138 // The smallest valid mipmap level for the specular environment cubemap139 // associated with the view.140 smallest_specular_mip_level_for_view: u32,141 // The intensity of the environment map associated with the view.142 intensity_for_view: f32,143};145// Settings for screen space reflections.146//147// For more information on these settings, see the documentation for148// `bevy_pbr::ssr::ScreenSpaceReflections`.149struct ScreenSpaceReflectionsSettings {150 perceptual_roughness_threshold: f32,151 thickness: f32,152 linear_steps: u32,153 linear_march_exponent: f32,154 bisection_steps: u32,155 use_secant: u32,156};158struct EnvironmentMapUniform {159 // Transformation matrix for the environment cubemaps in world space.160 transform: mat4x4<f32>,161};163// Shader version of the order independent transparency settings component.164struct OrderIndependentTransparencySettings {165 layers_count: i32,166 alpha_threshold: f32,167};