@@ -81,7 +81,7 @@ pub mod graph {
81
81
}
82
82
}
83
83
84
- /// Z offsets of "extracted nodes" for a given entity. These exist to allow rendering multiple "extracted nodes"
84
+ /// Local Z offsets of "extracted nodes" for a given entity. These exist to allow rendering multiple "extracted nodes"
85
85
/// for a given source entity (ex: render both a background color _and_ a custom material for a given node).
86
86
///
87
87
/// When possible these offsets should be defined in _this_ module to ensure z-index coordination across contexts.
@@ -97,10 +97,13 @@ pub mod graph {
97
97
/// a positive offset on a node below.
98
98
pub mod stack_z_offsets {
99
99
pub const BOX_SHADOW : f32 = -0.1 ;
100
- pub const TEXTURE_SLICE : f32 = 0.0 ;
101
- pub const NODE : f32 = 0.0 ;
102
- pub const GRADIENT : f32 = 0.1 ;
103
- pub const MATERIAL : f32 = 0.18267 ;
100
+ pub const BACKGROUND_COLOR : f32 = 0.0 ;
101
+ pub const BORDER : f32 = 0.01 ;
102
+ pub const GRADIENT : f32 = 0.02 ;
103
+ pub const BORDER_GRADIENT : f32 = 0.03 ;
104
+ pub const IMAGE : f32 = 0.04 ;
105
+ pub const MATERIAL : f32 = 0.05 ;
106
+ pub const TEXT : f32 = 0.06 ;
104
107
}
105
108
106
109
#[ derive( Debug , Hash , PartialEq , Eq , Clone , SystemSet ) ]
@@ -213,7 +216,7 @@ fn get_ui_graph(render_app: &mut SubApp) -> RenderGraph {
213
216
}
214
217
215
218
pub struct ExtractedUiNode {
216
- pub stack_index : u32 ,
219
+ pub z_order : f32 ,
217
220
pub color : LinearRgba ,
218
221
pub rect : Rect ,
219
222
pub image : AssetId < Image > ,
@@ -374,7 +377,7 @@ pub fn extract_uinode_background_colors(
374
377
375
378
extracted_uinodes. uinodes . push ( ExtractedUiNode {
376
379
render_entity : commands. spawn ( TemporaryRenderEntity ) . id ( ) ,
377
- stack_index : uinode. stack_index ,
380
+ z_order : uinode. stack_index as f32 + stack_z_offsets :: BACKGROUND_COLOR ,
378
381
color : background_color. 0 . into ( ) ,
379
382
rect : Rect {
380
383
min : Vec2 :: ZERO ,
@@ -460,8 +463,8 @@ pub fn extract_uinode_images(
460
463
} ;
461
464
462
465
extracted_uinodes. uinodes . push ( ExtractedUiNode {
466
+ z_order : uinode. stack_index as f32 + stack_z_offsets:: IMAGE ,
463
467
render_entity : commands. spawn ( TemporaryRenderEntity ) . id ( ) ,
464
- stack_index : uinode. stack_index ,
465
468
color : image. color . into ( ) ,
466
469
rect,
467
470
clip : clip. map ( |clip| clip. clip ) ,
@@ -558,7 +561,7 @@ pub fn extract_uinode_borders(
558
561
completed_flags |= border_flags;
559
562
560
563
extracted_uinodes. uinodes . push ( ExtractedUiNode {
561
- stack_index : computed_node. stack_index ,
564
+ z_order : computed_node. stack_index as f32 + stack_z_offsets :: BORDER ,
562
565
color,
563
566
rect : Rect {
564
567
max : computed_node. size ( ) ,
@@ -591,8 +594,8 @@ pub fn extract_uinode_borders(
591
594
{
592
595
let outline_size = computed_node. outlined_node_size ( ) ;
593
596
extracted_uinodes. uinodes . push ( ExtractedUiNode {
597
+ z_order : computed_node. stack_index as f32 + stack_z_offsets:: BORDER ,
594
598
render_entity : commands. spawn ( TemporaryRenderEntity ) . id ( ) ,
595
- stack_index : computed_node. stack_index ,
596
599
color : outline. color . into ( ) ,
597
600
rect : Rect {
598
601
max : outline_size,
@@ -782,8 +785,8 @@ pub fn extract_viewport_nodes(
782
785
} ;
783
786
784
787
extracted_uinodes. uinodes . push ( ExtractedUiNode {
788
+ z_order : uinode. stack_index as f32 + stack_z_offsets:: IMAGE ,
785
789
render_entity : commands. spawn ( TemporaryRenderEntity ) . id ( ) ,
786
- stack_index : uinode. stack_index ,
787
790
color : LinearRgba :: WHITE ,
788
791
rect : Rect {
789
792
min : Vec2 :: ZERO ,
@@ -885,8 +888,8 @@ pub fn extract_text_sections(
885
888
. map ( |text_color| LinearRgba :: from ( text_color. 0 ) )
886
889
. unwrap_or_default ( ) ;
887
890
extracted_uinodes. uinodes . push ( ExtractedUiNode {
891
+ z_order : uinode. stack_index as f32 + stack_z_offsets:: TEXT ,
888
892
render_entity : commands. spawn ( TemporaryRenderEntity ) . id ( ) ,
889
- stack_index : uinode. stack_index ,
890
893
color,
891
894
image : atlas_info. texture . id ( ) ,
892
895
clip : clip. map ( |clip| clip. clip ) ,
@@ -966,8 +969,8 @@ pub fn extract_text_shadows(
966
969
info. span_index != * span_index || info. atlas_info . texture != atlas_info. texture
967
970
} ) {
968
971
extracted_uinodes. uinodes . push ( ExtractedUiNode {
972
+ z_order : uinode. stack_index as f32 + stack_z_offsets:: TEXT ,
969
973
render_entity : commands. spawn ( TemporaryRenderEntity ) . id ( ) ,
970
- stack_index : uinode. stack_index ,
971
974
color : shadow. color . into ( ) ,
972
975
image : atlas_info. texture . id ( ) ,
973
976
clip : clip. map ( |clip| clip. clip ) ,
@@ -1023,8 +1026,8 @@ pub fn extract_text_background_colors(
1023
1026
} ;
1024
1027
1025
1028
extracted_uinodes. uinodes . push ( ExtractedUiNode {
1029
+ z_order : uinode. stack_index as f32 + stack_z_offsets:: TEXT ,
1026
1030
render_entity : commands. spawn ( TemporaryRenderEntity ) . id ( ) ,
1027
- stack_index : uinode. stack_index ,
1028
1031
color : text_background_color. 0 . to_linear ( ) ,
1029
1032
rect : Rect {
1030
1033
min : Vec2 :: ZERO ,
@@ -1167,7 +1170,7 @@ pub fn queue_uinodes(
1167
1170
draw_function,
1168
1171
pipeline,
1169
1172
entity : ( extracted_uinode. render_entity , extracted_uinode. main_entity ) ,
1170
- sort_key : FloatOrd ( extracted_uinode. stack_index as f32 + stack_z_offsets :: NODE ) ,
1173
+ sort_key : FloatOrd ( extracted_uinode. z_order ) ,
1171
1174
index,
1172
1175
// batch_range will be calculated in prepare_uinodes
1173
1176
batch_range : 0 ..0 ,
0 commit comments