mirror of
https://github.com/bevyengine/bevy
synced 2024-12-29 22:43:14 +00:00
b7bcd313ca
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> |
||
---|---|---|
.. | ||
animate_shader.wgsl | ||
array_texture.wgsl | ||
bindless_material.wgsl | ||
cubemap_unlit.wgsl | ||
custom_gltf_2d.wgsl | ||
custom_material.frag | ||
custom_material.vert | ||
custom_material.wgsl | ||
custom_material_2d.wgsl | ||
custom_material_import.wgsl | ||
custom_material_screenspace_texture.wgsl | ||
custom_phase_item.wgsl | ||
custom_ui_material.wgsl | ||
custom_vertex_attribute.wgsl | ||
extended_material.wgsl | ||
fallback_image_test.wgsl | ||
game_of_life.wgsl | ||
gpu_readback.wgsl | ||
instancing.wgsl | ||
irradiance_volume_voxel_visualization.wgsl | ||
line_material.wgsl | ||
post_processing.wgsl | ||
shader_defs.wgsl | ||
show_prepass.wgsl | ||
specialized_mesh_pipeline.wgsl | ||
storage_buffer.wgsl | ||
texture_binding_array.wgsl | ||
tonemapping_test_patterns.wgsl | ||
water_material.wgsl |