|
1 | 1 | #define_import_path bevy_pbr::light_probe |
2 | 2 |
|
| 3 | +#import bevy_pbr::mesh_view_bindings::light_probes |
3 | 4 | #import bevy_pbr::mesh_view_types::LightProbe |
4 | 5 |
|
5 | 6 | // The result of searching for a light probe. |
@@ -28,20 +29,28 @@ fn transpose_affine_matrix(matrix: mat3x4<f32>) -> mat4x4<f32> { |
28 | 29 | // |
29 | 30 | // TODO: Interpolate between multiple light probes. |
30 | 31 | fn query_light_probe( |
31 | | - in_light_probes: array<LightProbe, 8u>, |
32 | | - light_probe_count: i32, |
33 | 32 | world_position: vec3<f32>, |
| 33 | + is_irradiance_volume: bool, |
34 | 34 | ) -> LightProbeQueryResult { |
35 | | - // This is needed to index into the array with a non-constant expression. |
36 | | - var light_probes = in_light_probes; |
37 | | - |
38 | 35 | var result: LightProbeQueryResult; |
39 | 36 | result.texture_index = -1; |
40 | 37 |
|
| 38 | + var light_probe_count: i32; |
| 39 | + if is_irradiance_volume { |
| 40 | + light_probe_count = light_probes.irradiance_volume_count; |
| 41 | + } else { |
| 42 | + light_probe_count = light_probes.reflection_probe_count; |
| 43 | + } |
| 44 | + |
41 | 45 | for (var light_probe_index: i32 = 0; |
42 | 46 | light_probe_index < light_probe_count && result.texture_index < 0; |
43 | 47 | light_probe_index += 1) { |
44 | | - let light_probe = light_probes[light_probe_index]; |
| 48 | + var light_probe: LightProbe; |
| 49 | + if is_irradiance_volume { |
| 50 | + light_probe = light_probes.irradiance_volumes[light_probe_index]; |
| 51 | + } else { |
| 52 | + light_probe = light_probes.reflection_probes[light_probe_index]; |
| 53 | + } |
45 | 54 |
|
46 | 55 | // Unpack the inverse transform. |
47 | 56 | let inverse_transform = |
|
0 commit comments