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 decal_index: u32,17 pad: 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;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 decal_index: u32,44 sun_disk_angular_size: f32,45 sun_disk_intensity: f32,46};48const DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT: u32 = 1u << 0u;49const DIRECTIONAL_LIGHT_FLAGS_VOLUMETRIC_BIT: u32 = 1u << 1u;50const DIRECTIONAL_LIGHT_FLAGS_AFFECTS_LIGHTMAPPED_MESH_DIFFUSE_BIT: u32 = 1u << 2u;52struct Lights {53 // NOTE: this array size must be kept in sync with the constants defined in bevy_pbr/src/render/light.rs54 directional_lights: array<DirectionalLight, #{MAX_DIRECTIONAL_LIGHTS}u>,55 ambient_color: vec4<f32>,56 // x/y/z dimensions and n_clusters in w57 cluster_dimensions: vec4<u32>,58 // xy are vec2<f32>(cluster_dimensions.xy) / vec2<f32>(view.width, view.height)59 //60 // For perspective projections:61 // z is cluster_dimensions.z / log(far / near)62 // w is cluster_dimensions.z * log(near) / log(far / near)63 //64 // For orthographic projections:65 // NOTE: near and far are +ve but -z is infront of the camera66 // z is -near67 // w is cluster_dimensions.z / (-far - -near)68 cluster_factors: vec4<f32>,69 n_directional_lights: u32,70 spot_light_shadowmap_offset: i32,71 ambient_light_affects_lightmapped_meshes: u3272};74struct Fog {75 base_color: vec4<f32>,76 directional_light_color: vec4<f32>,77 // `be` and `bi` are allocated differently depending on the fog mode78 //79 // For Linear Fog:80 // be.x = start, be.y = end81 // For Exponential and ExponentialSquared Fog:82 // be.x = density83 // For Atmospheric Fog:84 // be = per-channel extinction density85 // bi = per-channel inscattering density86 be: vec3<f32>,87 directional_light_exponent: f32,88 bi: vec3<f32>,89 mode: u32,90}92// Important: These must be kept in sync with `fog.rs`93const FOG_MODE_OFF: u32 = 0u;94const FOG_MODE_LINEAR: u32 = 1u;95const FOG_MODE_EXPONENTIAL: u32 = 2u;96const FOG_MODE_EXPONENTIAL_SQUARED: u32 = 3u;97const FOG_MODE_ATMOSPHERIC: u32 = 4u;99#if AVAILABLE_STORAGE_BUFFER_BINDINGS >= 3100struct ClusterableObjects {101 data: array<ClusterableObject>,102};103struct ClusterLightIndexLists {104 data: array<u32>,105};106struct ClusterOffsetsAndCounts {107 data: array<array<vec4<u32>, 2>>,108};109#else110struct ClusterableObjects {111 data: array<ClusterableObject, 204u>,112};113struct ClusterLightIndexLists {114 // each u32 contains 4 u8 indices into the ClusterableObjects array115 data: array<vec4<u32>, 1024u>,116};117struct ClusterOffsetsAndCounts {118 // each u32 contains a 24-bit index into ClusterLightIndexLists in the high 24 bits119 // and an 8-bit count of the number of lights in the low 8 bits120 data: array<vec4<u32>, 1024u>,121};122#endif124struct LightProbe {125 // This is stored as the transpose in order to save space in this structure.126 // It'll be transposed in the `environment_map_light` function.127 light_from_world_transposed: mat3x4<f32>,128 cubemap_index: i32,129 intensity: f32,130 // Whether this light probe contributes diffuse light to lightmapped meshes.131 affects_lightmapped_mesh_diffuse: u32,132};134struct LightProbes {135 // This must match `MAX_VIEW_REFLECTION_PROBES` on the Rust side.136 reflection_probes: array<LightProbe, 8u>,137 irradiance_volumes: array<LightProbe, 8u>,138 reflection_probe_count: i32,139 irradiance_volume_count: i32,140 // The index of the view environment map cubemap binding, or -1 if there's141 // no such cubemap.142 view_cubemap_index: i32,143 // The smallest valid mipmap level for the specular environment cubemap144 // associated with the view.145 smallest_specular_mip_level_for_view: u32,146 // The intensity of the environment map associated with the view.147 intensity_for_view: f32,148 // Whether the environment map attached to the view affects the diffuse149 // lighting for lightmapped meshes.150 view_environment_map_affects_lightmapped_mesh_diffuse: u32,151};153// Settings for screen space reflections.154//155// For more information on these settings, see the documentation for156// `bevy_pbr::ssr::ScreenSpaceReflections`.157struct ScreenSpaceReflectionsSettings {158 perceptual_roughness_threshold: f32,159 thickness: f32,160 linear_steps: u32,161 linear_march_exponent: f32,162 bisection_steps: u32,163 use_secant: u32,164};166struct EnvironmentMapUniform {167 // Transformation matrix for the environment cubemaps in world space.168 transform: mat4x4<f32>,169};171// Shader version of the order independent transparency settings component.172struct OrderIndependentTransparencySettings {173 layers_count: i32,174 alpha_threshold: f32,175};177struct ClusteredDecal {178 local_from_world: mat4x4<f32>,179 image_index: i32,180 tag: u32,181 pad_a: u32,182 pad_b: u32,183}185struct ClusteredDecals {186 decals: array<ClusteredDecal>,187}