@@ -9,6 +9,7 @@ use crate::{
9
9
camera:: { ExtractedCamera , ManualTextureViews , MipBias , TemporalJitter } ,
10
10
extract_resource:: { ExtractResource , ExtractResourcePlugin } ,
11
11
prelude:: { Image , Shader } ,
12
+ primitives:: Frustum ,
12
13
render_asset:: RenderAssets ,
13
14
render_phase:: ViewRangefinder3d ,
14
15
render_resource:: { DynamicUniformBuffer , ShaderType , Texture , TextureView } ,
@@ -168,6 +169,7 @@ pub struct ViewUniform {
168
169
world_position : Vec3 ,
169
170
// viewport(x_origin, y_origin, width, height)
170
171
viewport : Vec4 ,
172
+ frustum : [ Vec4 ; 6 ] ,
171
173
color_grading : ColorGrading ,
172
174
mip_bias : f32 ,
173
175
}
@@ -352,6 +354,7 @@ pub fn prepare_view_uniforms(
352
354
views : Query < (
353
355
Entity ,
354
356
& ExtractedView ,
357
+ Option < & Frustum > ,
355
358
Option < & TemporalJitter > ,
356
359
Option < & MipBias > ,
357
360
) > ,
@@ -365,7 +368,7 @@ pub fn prepare_view_uniforms(
365
368
else {
366
369
return ;
367
370
} ;
368
- for ( entity, camera, temporal_jitter, mip_bias) in & views {
371
+ for ( entity, camera, frustum , temporal_jitter, mip_bias) in & views {
369
372
let viewport = camera. viewport . as_vec4 ( ) ;
370
373
let unjittered_projection = camera. projection ;
371
374
let mut projection = unjittered_projection;
@@ -386,6 +389,11 @@ pub fn prepare_view_uniforms(
386
389
. unwrap_or_else ( || projection * inverse_view)
387
390
} ;
388
391
392
+ // Map Frustum type to shader array<vec4<f32>, 6>
393
+ let frustum = frustum
394
+ . map ( |frustum| frustum. half_spaces . map ( |h| h. normal_d ( ) ) )
395
+ . unwrap_or ( [ Vec4 :: ZERO ; 6 ] ) ;
396
+
389
397
let view_uniforms = ViewUniformOffset {
390
398
offset : writer. write ( & ViewUniform {
391
399
view_proj,
@@ -397,6 +405,7 @@ pub fn prepare_view_uniforms(
397
405
inverse_projection,
398
406
world_position : camera. transform . translation ( ) ,
399
407
viewport,
408
+ frustum,
400
409
color_grading : camera. color_grading ,
401
410
mip_bias : mip_bias. unwrap_or ( & MipBias ( 0.0 ) ) . 0 ,
402
411
} ) ,
0 commit comments