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 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,29}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};45const DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT: u32 = 1u;46const DIRECTIONAL_LIGHT_FLAGS_VOLUMETRIC_BIT: u32 = 2u;47const DIRECTIONAL_LIGHT_FLAGS_AFFECTS_LIGHTMAPPED_MESH_DIFFUSE_BIT: u32 = 4u;49struct Lights {50 // NOTE: this array size must be kept in sync with the constants defined in bevy_pbr/src/render/light.rs51 directional_lights: array<DirectionalLight, #{MAX_DIRECTIONAL_LIGHTS}u>,52 ambient_color: vec4<f32>,53 // x/y/z dimensions and n_clusters in w54 cluster_dimensions: vec4<u32>,55 // xy are vec2<f32>(cluster_dimensions.xy) / vec2<f32>(view.width, view.height)56 //57 // For perspective projections:58 // z is cluster_dimensions.z / log(far / near)59 // w is cluster_dimensions.z * log(near) / log(far / near)60 //61 // For orthographic projections:62 // NOTE: near and far are +ve but -z is infront of the camera63 // z is -near64 // w is cluster_dimensions.z / (-far - -near)65 cluster_factors: vec4<f32>,66 n_directional_lights: u32,67 spot_light_shadowmap_offset: i32,68 environment_map_smallest_specular_mip_level: u32,69 environment_map_intensity: f32,70};72struct Fog {73 base_color: vec4<f32>,74 directional_light_color: vec4<f32>,75 // `be` and `bi` are allocated differently depending on the fog mode76 //77 // For Linear Fog:78 // be.x = start, be.y = end79 // For Exponential and ExponentialSquared Fog:80 // be.x = density81 // For Atmospheric Fog:82 // be = per-channel extinction density83 // bi = per-channel inscattering density84 be: vec3<f32>,85 directional_light_exponent: f32,86 bi: vec3<f32>,87 mode: u32,88}90// Important: These must be kept in sync with `fog.rs`91const FOG_MODE_OFF: u32 = 0u;92const FOG_MODE_LINEAR: u32 = 1u;93const FOG_MODE_EXPONENTIAL: u32 = 2u;94const FOG_MODE_EXPONENTIAL_SQUARED: u32 = 3u;95const FOG_MODE_ATMOSPHERIC: u32 = 4u;97#if AVAILABLE_STORAGE_BUFFER_BINDINGS >= 398struct ClusterableObjects {99 data: array<ClusterableObject>,100};101struct ClusterLightIndexLists {102 data: array<u32>,103};104struct ClusterOffsetsAndCounts {105 data: array<array<vec4<u32>, 2>>,106};107#else108struct ClusterableObjects {109 data: array<ClusterableObject, 204u>,110};111struct ClusterLightIndexLists {112 // each u32 contains 4 u8 indices into the ClusterableObjects array113 data: array<vec4<u32>, 1024u>,114};115struct ClusterOffsetsAndCounts {116 // each u32 contains a 24-bit index into ClusterLightIndexLists in the high 24 bits117 // and an 8-bit count of the number of lights in the low 8 bits118 data: array<vec4<u32>, 1024u>,119};120#endif122struct LightProbe {123 // This is stored as the transpose in order to save space in this structure.124 // It'll be transposed in the `environment_map_light` function.125 light_from_world_transposed: mat3x4<f32>,126 cubemap_index: i32,127 intensity: f32,128 // Whether this light probe contributes diffuse light to lightmapped meshes.129 affects_lightmapped_mesh_diffuse: u32,130};132struct LightProbes {133 // This must match `MAX_VIEW_REFLECTION_PROBES` on the Rust side.134 reflection_probes: array<LightProbe, 8u>,135 irradiance_volumes: array<LightProbe, 8u>,136 reflection_probe_count: i32,137 irradiance_volume_count: i32,138 // The index of the view environment map cubemap binding, or -1 if there's139 // no such cubemap.140 view_cubemap_index: i32,141 // The smallest valid mipmap level for the specular environment cubemap142 // associated with the view.143 smallest_specular_mip_level_for_view: u32,144 // The intensity of the environment map associated with the view.145 intensity_for_view: f32,146 // Whether the environment map attached to the view affects the diffuse147 // lighting for lightmapped meshes.148 view_environment_map_affects_lightmapped_mesh_diffuse: u32,149};151// Settings for screen space reflections.152//153// For more information on these settings, see the documentation for154// `bevy_pbr::ssr::ScreenSpaceReflections`.155struct ScreenSpaceReflectionsSettings {156 perceptual_roughness_threshold: f32,157 thickness: f32,158 linear_steps: u32,159 linear_march_exponent: f32,160 bisection_steps: u32,161 use_secant: u32,162};164struct EnvironmentMapUniform {165 // Transformation matrix for the environment cubemaps in world space.166 transform: mat4x4<f32>,167};169// Shader version of the order independent transparency settings component.170struct OrderIndependentTransparencySettings {171 layers_count: i32,172 alpha_threshold: f32,173};175struct ClusteredDecal {176 local_from_world: mat4x4<f32>,177 image_index: i32,178 tag: u32,179 pad_a: u32,180 pad_b: u32,181}183struct ClusteredDecals {184 decals: array<ClusteredDecal>,185}