bevy/assets/shaders
Patrick Walton b7bcd313ca
Cluster light probes using conservative spherical bounds. (#13746)
This commit allows the Bevy renderer to use the clustering
infrastructure for light probes (reflection probes and irradiance
volumes) on platforms where at least 3 storage buffers are available. On
such platforms (the vast majority), we stop performing brute-force
searches of light probes for each fragment and instead only search the
light probes with bounding spheres that intersect the current cluster.
This should dramatically improve scalability of irradiance volumes and
reflection probes.

The primary platform that doesn't support 3 storage buffers is WebGL 2,
and we continue using a brute-force search of light probes on that
platform, as the UBO that stores per-cluster indices is too small to fit
the light probe counts. Note, however, that that platform also doesn't
support bindless textures (indeed, it would be very odd for a platform
to support bindless textures but not SSBOs), so we only support one of
each type of light probe per drawcall there in the first place.
Consequently, this isn't a performance problem, as the search will only
have one light probe to consider. (In fact, clustering would probably
end up being a performance loss.)

Known potential improvements include:

1. We currently cull based on a conservative bounding sphere test and
not based on the oriented bounding box (OBB) of the light probe. This is
improvable, but in the interests of simplicity, I opted to keep the
bounding sphere test for now. The OBB improvement can be a follow-up.

2. This patch doesn't change the fact that each fragment only takes a
single light probe into account. Typical light probe implementations
detect the case in which multiple light probes cover the current
fragment and perform some sort of weighted blend between them. As the
light probe fetch function presently returns only a single light probe,
implementing that feature would require more code restructuring, so I
left it out for now. It can be added as a follow-up.

3. Light probe implementations typically have a falloff range. Although
this is a wanted feature in Bevy, this particular commit also doesn't
implement that feature, as it's out of scope.

4. This commit doesn't raise the maximum number of light probes past its
current value of 8 for each type. This should be addressed later, but
would possibly require more bindings on platforms with storage buffers,
which would increase this patch's complexity. Even without raising the
limit, this patch should constitute a significant performance
improvement for scenes that get anywhere close to this limit. In the
interest of keeping this patch small, I opted to leave raising the limit
to a follow-up.

## Changelog

### Changed

* Light probes (reflection probes and irradiance volumes) are now
clustered on most platforms, improving performance when many light
probes are present.

---------

Co-authored-by: Benjamin Brienen <Benjamin.Brienen@outlook.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2024-12-05 13:07:10 +00:00
..
animate_shader.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
array_texture.wgsl Remove unused mip_bias parameter from apply_normal_mapping (#13752) 2024-06-10 13:00:34 +00:00
bindless_material.wgsl Add a bindless mode to AsBindGroup. (#16368) 2024-12-03 18:00:34 +00:00
cubemap_unlit.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
custom_gltf_2d.wgsl Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
custom_material.frag Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
custom_material.vert examples(shaders/glsl): Update GLSL Shader Example Camera View uniform (#15865) 2024-10-19 01:08:55 +00:00
custom_material.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
custom_material_2d.wgsl Fix binding group in custom_material_2d.wgsl (#10841) 2023-12-02 22:21:53 +00:00
custom_material_import.wgsl fix custom shader imports (#10030) 2023-10-06 01:34:57 +00:00
custom_material_screenspace_texture.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
custom_phase_item.wgsl Allow phase items not associated with meshes to be binned. (#14029) 2024-06-27 16:13:03 +00:00
custom_ui_material.wgsl Add a border to the UI material example (#15120) 2024-09-09 16:34:24 +00:00
custom_vertex_attribute.wgsl Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
extended_material.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
fallback_image_test.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
game_of_life.wgsl Fix example game of life (#12897) 2024-04-08 17:19:07 +00:00
gpu_readback.wgsl Gpu readback (#15419) 2024-09-30 17:28:55 +00:00
instancing.wgsl Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
irradiance_volume_voxel_visualization.wgsl Cluster light probes using conservative spherical bounds. (#13746) 2024-12-05 13:07:10 +00:00
line_material.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
post_processing.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
shader_defs.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
show_prepass.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
specialized_mesh_pipeline.wgsl Add example showing how to use SpecializedMeshPipeline (#14370) 2024-07-31 18:24:58 +00:00
storage_buffer.wgsl Adds ShaderStorageBuffer asset (#14663) 2024-09-02 16:46:34 +00:00
texture_binding_array.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
tonemapping_test_patterns.wgsl move wgsl color operations from bevy_pbr to bevy_render (#13209) 2024-05-04 10:30:23 +00:00
water_material.wgsl Implement opt-in sharp screen-space reflections for the deferred renderer, with improved raymarching code. (#13418) 2024-05-27 13:43:40 +00:00