Skip to content

Commit

Permalink
Merge branch 'main' into transmission
Browse files Browse the repository at this point in the history
  • Loading branch information
coreh committed Oct 31, 2023
2 parents 9d50dd1 + 3628e09 commit 5dc4387
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 53 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/deferred/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use bevy_utils::{nonmax::NonMaxU32, FloatOrd};

pub const DEFERRED_PREPASS_FORMAT: TextureFormat = TextureFormat::Rgba32Uint;
pub const DEFERRED_LIGHTING_PASS_ID_FORMAT: TextureFormat = TextureFormat::R8Uint;
pub const DEFERRED_LIGHTING_PASS_ID_DEPTH_FORMAT: TextureFormat = TextureFormat::Depth32Float;
pub const DEFERRED_LIGHTING_PASS_ID_DEPTH_FORMAT: TextureFormat = TextureFormat::Depth16Unorm;

/// Opaque phase of the 3D Deferred pass.
///
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_render/src/camera/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::{
camera::CameraProjection,
camera::{ManualTextureViewHandle, ManualTextureViews},
prelude::Image,
primitives::Frustum,
render_asset::RenderAssets,
render_resource::TextureView,
view::{ColorGrading, ExtractedView, ExtractedWindows, RenderLayers, VisibleEntities},
Expand Down Expand Up @@ -642,6 +643,7 @@ pub fn extract_cameras(
&CameraRenderGraph,
&GlobalTransform,
&VisibleEntities,
&Frustum,
Option<&ColorGrading>,
Option<&TemporalJitter>,
Option<&RenderLayers>,
Expand All @@ -657,6 +659,7 @@ pub fn extract_cameras(
camera_render_graph,
transform,
visible_entities,
frustum,
color_grading,
temporal_jitter,
render_layers,
Expand Down Expand Up @@ -714,6 +717,7 @@ pub fn extract_cameras(
color_grading,
},
visible_entities.clone(),
*frustum,
));

if let Some(temporal_jitter) = temporal_jitter {
Expand Down
11 changes: 10 additions & 1 deletion crates/bevy_render/src/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{
camera::{ExtractedCamera, ManualTextureViews, MipBias, TemporalJitter},
extract_resource::{ExtractResource, ExtractResourcePlugin},
prelude::{Image, Shader},
primitives::Frustum,
render_asset::RenderAssets,
render_phase::ViewRangefinder3d,
render_resource::{DynamicUniformBuffer, ShaderType, Texture, TextureView},
Expand Down Expand Up @@ -168,6 +169,7 @@ pub struct ViewUniform {
world_position: Vec3,
// viewport(x_origin, y_origin, width, height)
viewport: Vec4,
frustum: [Vec4; 6],
color_grading: ColorGrading,
mip_bias: f32,
}
Expand Down Expand Up @@ -352,6 +354,7 @@ pub fn prepare_view_uniforms(
views: Query<(
Entity,
&ExtractedView,
Option<&Frustum>,
Option<&TemporalJitter>,
Option<&MipBias>,
)>,
Expand All @@ -365,7 +368,7 @@ pub fn prepare_view_uniforms(
else {
return;
};
for (entity, camera, temporal_jitter, mip_bias) in &views {
for (entity, camera, frustum, temporal_jitter, mip_bias) in &views {
let viewport = camera.viewport.as_vec4();
let unjittered_projection = camera.projection;
let mut projection = unjittered_projection;
Expand All @@ -386,6 +389,11 @@ pub fn prepare_view_uniforms(
.unwrap_or_else(|| projection * inverse_view)
};

// Map Frustum type to shader array<vec4<f32>, 6>
let frustum = frustum
.map(|frustum| frustum.half_spaces.map(|h| h.normal_d()))
.unwrap_or([Vec4::ZERO; 6]);

let view_uniforms = ViewUniformOffset {
offset: writer.write(&ViewUniform {
view_proj,
Expand All @@ -397,6 +405,7 @@ pub fn prepare_view_uniforms(
inverse_projection,
world_position: camera.transform.translation(),
viewport,
frustum,
color_grading: camera.color_grading,
mip_bias: mip_bias.unwrap_or(&MipBias(0.0)).0,
}),
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_render/src/view/view.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct View {
world_position: vec3<f32>,
// viewport(x_origin, y_origin, width, height)
viewport: vec4<f32>,
frustum: array<vec4<f32>, 6>,
color_grading: ColorGrading,
mip_bias: f32,
};
1 change: 1 addition & 0 deletions crates/bevy_ui/src/layout/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ impl From<JustifyContent> for Option<taffy::style::JustifyContent> {
JustifyContent::FlexStart => taffy::style::JustifyContent::FlexStart.into(),
JustifyContent::FlexEnd => taffy::style::JustifyContent::FlexEnd.into(),
JustifyContent::Center => taffy::style::JustifyContent::Center.into(),
JustifyContent::Stretch => taffy::style::JustifyContent::Stretch.into(),
JustifyContent::SpaceBetween => taffy::style::JustifyContent::SpaceBetween.into(),
JustifyContent::SpaceAround => taffy::style::JustifyContent::SpaceAround.into(),
JustifyContent::SpaceEvenly => taffy::style::JustifyContent::SpaceEvenly.into(),
Expand Down
131 changes: 80 additions & 51 deletions crates/bevy_ui/src/ui_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,44 +216,50 @@ pub struct Style {
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio>
pub aspect_ratio: Option<f32>,

/// - For Flexbox containers, sets default cross-axis alignment of the child items.
/// Used to control how each individual item is aligned by default within the space they're given.
/// - For Flexbox containers, sets default cross axis alignment of the child items.
/// - For CSS Grid containers, controls block (vertical) axis alignment of children of this grid container within their grid areas.
///
/// This value is overridden if [`AlignSelf`] on the child node is set.
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/align-items>
pub align_items: AlignItems,

/// - For Flexbox containers, this property has no effect. See `justify_content` for main-axis alignment of flex items.
/// Used to control how each individual item is aligned by default within the space they're given.
/// - For Flexbox containers, this property has no effect. See `justify_content` for main axis alignment of flex items.
/// - For CSS Grid containers, sets default inline (horizontal) axis alignment of child items within their grid areas.
///
/// This value is overridden if [`JustifySelf`] on the child node is set.
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items>
pub justify_items: JustifyItems,

/// - For Flexbox items, controls cross-axis alignment of the item.
/// Used to control how the specified item is aligned within the space it's given.
/// - For Flexbox items, controls cross axis alignment of the item.
/// - For CSS Grid items, controls block (vertical) axis alignment of a grid item within its grid area.
///
/// If set to `Auto`, alignment is inherited from the value of [`AlignItems`] set on the parent node.
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/align-self>
pub align_self: AlignSelf,

/// - For Flexbox items, this property has no effect. See `justify_content` for main-axis alignment of flex items.
/// Used to control how the specified item is aligned within the space it's given.
/// - For Flexbox items, this property has no effect. See `justify_content` for main axis alignment of flex items.
/// - For CSS Grid items, controls inline (horizontal) axis alignment of a grid item within its grid area.
///
/// If set to `Auto`, alignment is inherited from the value of [`JustifyItems`] set on the parent node.
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self>
pub justify_self: JustifySelf,

/// - For Flexbox containers, controls alignment of lines if flex_wrap is set to [`FlexWrap::Wrap`] and there are multiple lines of items.
/// Used to control how items are distributed.
/// - For Flexbox containers, controls alignment of lines if `flex_wrap` is set to [`FlexWrap::Wrap`] and there are multiple lines of items.
/// - For CSS Grid containers, controls alignment of grid rows.
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/align-content>
pub align_content: AlignContent,

/// Used to control how items are distributed.
/// - For Flexbox containers, controls alignment of items in the main axis.
/// - For CSS Grid containers, controls alignment of grid columns.
///
Expand Down Expand Up @@ -443,27 +449,31 @@ impl Default for Style {
}
}

/// How items are aligned according to the cross axis
/// Used to control how each individual item is aligned by default within the space they're given.
/// - For Flexbox containers, sets default cross axis alignment of the child items.
/// - For CSS Grid containers, controls block (vertical) axis alignment of children of this grid container within their grid areas.
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/align-items>
#[derive(Copy, Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Reflect)]
#[reflect(PartialEq, Serialize, Deserialize)]
pub enum AlignItems {
/// The items are packed in their default position as if no alignment was applied.
Default,
/// Items are packed towards the start of the axis.
/// The items are packed towards the start of the axis.
Start,
/// Items are packed towards the end of the axis.
/// The items are packed towards the end of the axis.
End,
/// Items are packed towards the start of the axis, unless the flex direction is reversed;
/// The items are packed towards the start of the axis, unless the flex direction is reversed;
/// then they are packed towards the end of the axis.
FlexStart,
/// Items are packed towards the end of the axis, unless the flex direction is reversed;
/// The items are packed towards the end of the axis, unless the flex direction is reversed;
/// then they are packed towards the start of the axis.
FlexEnd,
/// Items are aligned at the center.
/// The items are packed along the center of the axis.
Center,
/// Items are aligned at the baseline.
/// The items are packed such that their baselines align.
Baseline,
/// Items are stretched across the whole cross axis.
/// The items are stretched to fill the space they're given.
Stretch,
}

Expand All @@ -477,21 +487,25 @@ impl Default for AlignItems {
}
}

/// How items are aligned according to the main axis
/// Used to control how each individual item is aligned by default within the space they're given.
/// - For Flexbox containers, this property has no effect. See `justify_content` for main axis alignment of flex items.
/// - For CSS Grid containers, sets default inline (horizontal) axis alignment of child items within their grid areas.
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items>
#[derive(Copy, Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Reflect)]
#[reflect(PartialEq, Serialize, Deserialize)]
pub enum JustifyItems {
/// The items are packed in their default position as if no alignment was applied.
Default,
/// Items are packed towards the start of the axis.
/// The items are packed towards the start of the axis.
Start,
/// Items are packed towards the end of the axis.
/// The items are packed towards the end of the axis.
End,
/// Items are aligned at the center.
/// The items are packed along the center of the axis
Center,
/// Items are aligned at the baseline.
/// The items are packed such that their baselines align.
Baseline,
/// Items are stretched across the whole main axis.
/// The items are stretched to fill the space they're given.
Stretch,
}

Expand All @@ -505,8 +519,11 @@ impl Default for JustifyItems {
}
}

/// How this item is aligned according to the cross axis.
/// Overrides [`AlignItems`].
/// Used to control how the specified item is aligned within the space it's given.
/// - For Flexbox items, controls cross axis alignment of the item.
/// - For CSS Grid items, controls block (vertical) axis alignment of a grid item within its grid area.
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/align-self>
#[derive(Copy, Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Reflect)]
#[reflect(PartialEq, Serialize, Deserialize)]
pub enum AlignSelf {
Expand All @@ -522,11 +539,11 @@ pub enum AlignSelf {
/// This item will be aligned with the end of the axis, unless the flex direction is reversed;
/// then it will be aligned with the start of the axis.
FlexEnd,
/// This item will be aligned at the center.
/// This item will be aligned along the center of the axis.
Center,
/// This item will be aligned at the baseline.
Baseline,
/// This item will be stretched across the whole cross axis.
/// This item will be stretched to fill the container.
Stretch,
}

Expand All @@ -540,8 +557,11 @@ impl Default for AlignSelf {
}
}

/// How this item is aligned according to the main axis.
/// Overrides [`JustifyItems`].
/// Used to control how the specified item is aligned within the space it's given.
/// - For Flexbox items, this property has no effect. See `justify_content` for main axis alignment of flex items.
/// - For CSS Grid items, controls inline (horizontal) axis alignment of a grid item within its grid area.
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self>
#[derive(Copy, Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Reflect)]
#[reflect(PartialEq, Serialize, Deserialize)]
pub enum JustifySelf {
Expand All @@ -551,11 +571,11 @@ pub enum JustifySelf {
Start,
/// This item will be aligned with the end of the axis.
End,
/// This item will be aligned at the center.
/// This item will be aligned along the center of the axis.
Center,
/// This item will be aligned at the baseline.
Baseline,
/// This item will be stretched across the whole main axis.
/// This item will be stretched to fill the space it's given.
Stretch,
}

Expand All @@ -569,34 +589,35 @@ impl Default for JustifySelf {
}
}

/// Defines how each line is aligned within the flexbox.
/// Used to control how items are distributed.
/// - For Flexbox containers, controls alignment of lines if `flex_wrap` is set to [`FlexWrap::Wrap`] and there are multiple lines of items.
/// - For CSS Grid containers, controls alignment of grid rows.
///
/// It only applies if [`FlexWrap::Wrap`] is present and if there are multiple lines of items.
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/align-content>
#[derive(Copy, Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Reflect)]
#[reflect(PartialEq, Serialize, Deserialize)]
pub enum AlignContent {
/// The items are packed in their default position as if no alignment was applied.
Default,
/// Each line moves towards the start of the cross axis.
/// The items are packed towards the start of the axis.
Start,
/// Each line moves towards the end of the cross axis.
/// The items are packed towards the end of the axis.
End,
/// Each line moves towards the start of the cross axis, unless the flex direction is reversed; then the line moves towards the end of the cross axis.
/// The items are packed towards the start of the axis, unless the flex direction is reversed;
/// then the items are packed towards the end of the axis.
FlexStart,
/// Each line moves towards the end of the cross axis, unless the flex direction is reversed; then the line moves towards the start of the cross axis.
/// The items are packed towards the end of the axis, unless the flex direction is reversed;
/// then the items are packed towards the start of the axis.
FlexEnd,
/// Each line moves towards the center of the cross axis.
/// The items are packed along the center of the axis.
Center,
/// Each line will stretch to fill the remaining space.
/// The items are stretched to fill the container along the axis.
Stretch,
/// Each line fills the space it needs, putting the remaining space, if any,
/// between the lines.
/// The items are distributed such that the gap between any two items is equal.
SpaceBetween,
/// The gap between the first and last items is exactly the same as the gap between items.
/// The gaps are distributed evenly.
/// The items are distributed such that the gap between and around any two items is equal.
SpaceEvenly,
/// Each line fills the space it needs, putting the remaining space, if any,
/// around the lines.
/// The items are distributed such that the gap between and around any two items is equal, with half-size gaps on either end.
SpaceAround,
}

Expand All @@ -610,28 +631,36 @@ impl Default for AlignContent {
}
}

/// Defines how items are aligned according to the main axis
/// Used to control how items are distributed.
/// - For Flexbox containers, controls alignment of items in the main axis.
/// - For CSS Grid containers, controls alignment of grid columns.
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content>
#[derive(Copy, Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Reflect)]
#[reflect(PartialEq, Serialize, Deserialize)]
pub enum JustifyContent {
/// The items are packed in their default position as if no alignment was applied.
Default,
/// Items are packed toward the start of the axis.
/// The items are packed towards the start of the axis.
Start,
/// Items are packed toward the end of the axis.
/// The items are packed towards the end of the axis.
End,
/// Pushed towards the start, unless the flex direction is reversed; then pushed towards the end.
/// The items are packed towards the start of the axis, unless the flex direction is reversed;
/// then the items are packed towards the end of the axis.
FlexStart,
/// Pushed towards the end, unless the flex direction is reversed; then pushed towards the start.
/// The items are packed towards the end of the axis, unless the flex direction is reversed;
/// then the items are packed towards the start of the axis.
FlexEnd,
/// Centered along the main axis.
/// The items are packed along the center of the axis.
Center,
/// Remaining space is distributed between the items.
/// The items are stretched to fill the container along the axis.
Stretch,
/// The items are distributed such that the gap between any two items is equal.
SpaceBetween,
/// Remaining space is distributed around the items.
SpaceAround,
/// Like [`JustifyContent::SpaceAround`] but with even spacing between items.
/// The items are distributed such that the gap between and around any two items is equal.
SpaceEvenly,
/// The items are distributed such that the gap between and around any two items is equal, with half-size gaps on either end.
SpaceAround,
}

impl JustifyContent {
Expand Down

0 comments on commit 5dc4387

Please sign in to comment.