bevy/examples/3d
robtfm 132950cd55 Spotlights (#4715)
# Objective

add spotlight support

## Solution / Changelog

- add spotlight angles (inner, outer) to ``PointLight`` struct. emitted light is linearly attenuated from 100% to 0% as angle tends from inner to outer. Direction is taken from the existing transform rotation.
- add spotlight direction (vec3) and angles (f32,f32) to ``GpuPointLight`` struct (60 bytes -> 80 bytes) in ``pbr/render/lights.rs`` and ``mesh_view_bind_group.wgsl``
- reduce no-buffer-support max point light count to 204 due to above
- use spotlight data to attenuate light in ``pbr.wgsl``
- do additional cluster culling on spotlights to minimise cost in ``assign_lights_to_clusters``
- changed one of the lights in the lighting demo to a spotlight
- also added a ``spotlight`` demo - probably not justified but so reviewers can see it more easily

## notes

increasing the size of the GpuPointLight struct on my machine reduces the FPS of ``many_lights -- sphere`` from ~150fps to 140fps. 

i thought this was a reasonable tradeoff, and felt better than handling spotlights separately which is possible but would mean introducing a new bind group, refactoring light-assignment code and adding new spotlight-specific code in pbr.wgsl. the FPS impact for smaller numbers of lights should be very small.

the cluster culling strategy reintroduces the cluster aabb code which was recently removed... sorry. the aabb is used to get a cluster bounding sphere, which can then be tested fairly efficiently using the strategy described at the end of https://bartwronski.com/2017/04/13/cull-that-cone/. this works well with roughly cubic clusters (where the cluster z size is close to the same as x/y size), less well for other cases like single Z slice / tiled forward rendering. In the worst case we will end up just keeping the culling of the equivalent point light.

Co-authored-by: François <mockersf@gmail.com>
2022-07-08 19:57:43 +00:00
..
3d_scene.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
lighting.rs Spotlights (#4715) 2022-07-08 19:57:43 +00:00
load_gltf.rs add a SceneBundle to spawn a scene (#2424) 2022-06-09 20:34:09 +00:00
msaa.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
orthographic.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
parenting.rs Add helper methods for rotating Transforms (#5151) 2022-07-01 03:58:54 +00:00
pbr.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
render_to_texture.rs Add helper methods for rotating Transforms (#5151) 2022-07-01 03:58:54 +00:00
shadow_biases.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
shadow_caster_receiver.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
shapes.rs Add helper methods for rotating Transforms (#5151) 2022-07-01 03:58:54 +00:00
spherical_area_lights.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
split_screen.rs add a SceneBundle to spawn a scene (#2424) 2022-06-09 20:34:09 +00:00
spotlight.rs Spotlights (#4715) 2022-07-08 19:57:43 +00:00
texture.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
transparency_3d.rs transparency_3d example tweaks (#4968) 2022-06-23 18:36:07 +00:00
two_passes.rs Add "depth_load_op" configuration to 3d Cameras (#4904) 2022-06-07 22:22:10 +00:00
update_gltf_scene.rs add a SceneBundle to spawn a scene (#2424) 2022-06-09 20:34:09 +00:00
vertex_colors.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
wireframe.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00