55//! configured to render to a specific surface (either a window or an offscreen image).
66use bevy:: {
77 camera:: {
8- CameraMainTextureUsages , CameraOutputMode , CameraProjection , ClearColorConfig ,
8+ CameraMainTextureUsages , CameraOutputMode , CameraProjection , ClearColorConfig , Hdr ,
99 ImageRenderTarget , MsaaWriteback , Projection , RenderTarget , visibility:: RenderLayers ,
1010 } ,
1111 core_pipeline:: tonemapping:: Tonemapping ,
@@ -20,7 +20,7 @@ use bevy::{
2020 } ,
2121 renderer:: { RenderDevice , RenderQueue } ,
2222 sync_world:: MainEntity ,
23- view:: { Hdr , ViewTarget , prepare_view_targets} ,
23+ view:: { ViewTarget , prepare_view_targets} ,
2424 } ,
2525 window:: WindowRef ,
2626} ;
@@ -51,7 +51,7 @@ impl Plugin for GraphicsPlugin {
5151 . add_systems (
5252 Render ,
5353 send_view_targets
54- . in_set ( RenderSystems :: ManageViews )
54+ . in_set ( RenderSystems :: Specialize )
5555 . after ( prepare_view_targets) ,
5656 )
5757 . insert_resource ( GraphicsTargetSender ( tx) ) ;
@@ -293,6 +293,10 @@ pub fn mode_3d(
293293 let near = camera_z / 10.0 ;
294294 let far = camera_z * 10.0 ;
295295
296+ // TODO: Setting this as a default, but we need to think about API around
297+ // a user defined value
298+ let near_clip_plane = vec4 ( 0.0 , 0.0 , -1.0 , -near) ;
299+
296300 let mut projection = projections
297301 . get_mut ( entity)
298302 . map_err ( |_| ProcessingError :: GraphicsNotFound ) ?;
@@ -302,6 +306,7 @@ pub fn mode_3d(
302306 aspect_ratio : aspect,
303307 near,
304308 far,
309+ near_clip_plane,
305310 } ) ;
306311
307312 let mut transform = transforms
@@ -351,6 +356,7 @@ pub fn perspective(
351356 aspect_ratio,
352357 near,
353358 far,
359+ near_clip_plane,
354360 } ,
355361 ) ) : In < ( Entity , PerspectiveProjection ) > ,
356362 mut projections : Query < & mut Projection > ,
@@ -364,6 +370,7 @@ pub fn perspective(
364370 aspect_ratio,
365371 near,
366372 far,
373+ near_clip_plane,
367374 } ) ;
368375
369376 Ok ( ( ) )
@@ -526,7 +533,8 @@ pub fn readback(
526533 } ) ;
527534
528535 render_device
529- . poll ( PollType :: Wait )
536+ // TODO: should this have a timeout?
537+ . poll ( PollType :: wait_indefinitely ( ) )
530538 . expect ( "Failed to poll device for map async" ) ;
531539
532540 r. recv ( ) . expect ( "Failed to receive the map_async message" ) ;
0 commit comments