1import bevy_pbr::render::forward_io::VertexOutput; 2import bevy_pbr::light_probe::irradiance_volume; 3import bevy_pbr::render::mesh_view_bindings; 4import bevy_pbr::render::clustered_forward; 6struct VoxelVisualizationIrradianceVolumeInfo { 7 world_from_voxel: mat4x4<f32>, 8 voxel_from_world: mat4x4<f32>, 15@group(constants::MATERIAL_BIND_GROUP) @binding(100) 16var<uniform> irradiance_volume_info: VoxelVisualizationIrradianceVolumeInfo; 19fn fragment(mesh: VertexOutput) -> @location(0) vec4<f32> { 22 var unit_pos = (irradiance_volume_info.voxel_from_world * 23 vec4(mesh.world_position.xyz, 1.0f)).xyz; 24 let resolution = vec3<f32>(irradiance_volume_info.resolution); 25 let stp = clamp((unit_pos + 0.5) * resolution, vec3(0.5f), resolution - vec3(0.5f)); 26 let stp_rounded = round(stp - 0.5f) + 0.5f; 27 let rounded_world_pos = (irradiance_volume_info.world_from_voxel * vec4(stp_rounded, 1.0f)).xyz; 30 let view_z = dot(vec4<f32>( 31 mesh_view_bindings::view.view_from_world[0].z, 32 mesh_view_bindings::view.view_from_world[1].z, 33 mesh_view_bindings::view.view_from_world[2].z, 34 mesh_view_bindings::view.view_from_world[3].z 35 ), mesh.world_position); 36 let cluster_index = clustered_forward::view_fragment_cluster_index(mesh.position.xy, view_z, false); 37 var clusterable_object_index_ranges = 38 clustered_forward::unpack_clusterable_object_index_ranges(cluster_index); 42 let rgb = irradiance_volume::irradiance_volume_light( 43 mesh.world_position.xyz, 45 &clusterable_object_index_ranges, 46 ) / irradiance_volume_info.intensity; 48 return vec4<f32>(rgb, 1.0f);