Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify RenderLayers and TargetCamera (Part 1: RenderGroups) [ADOPT ME] #12502

Open
wants to merge 54 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
faba920
add RenderGroups (WIP)
UkoeHB Mar 15, 2024
756191b
typo
UkoeHB Mar 15, 2024
0d302b1
integration WIP
UkoeHB Mar 16, 2024
ac31198
propagation algorithm WIP
UkoeHB Mar 17, 2024
1b7c495
propagation algorithm WIP
UkoeHB Mar 17, 2024
bd468dc
propagation algorithm WIP
UkoeHB Mar 18, 2024
481a801
propagation algorithm early draft
UkoeHB Mar 18, 2024
7702347
render groups compiles
UkoeHB Mar 18, 2024
646c53b
propagate render groups compiles
UkoeHB Mar 18, 2024
f07b7a5
fmt
UkoeHB Mar 18, 2024
36d7aeb
integration (WIP) compiles
UkoeHB Mar 18, 2024
a4563ac
fixes for render groups usage
UkoeHB Mar 18, 2024
d622489
rearrange
UkoeHB Mar 18, 2024
4b4bed3
cleanup
UkoeHB Mar 18, 2024
829be8a
fmt
UkoeHB Mar 18, 2024
064d276
eliminate spurious allocations
UkoeHB Mar 18, 2024
a70bd8c
finish removing old RenderLayers
UkoeHB Mar 18, 2024
13994a3
cleanup
UkoeHB Mar 18, 2024
bc289e1
docs
UkoeHB Mar 18, 2024
7e8f073
fmt
UkoeHB Mar 18, 2024
ab44847
cleanup
UkoeHB Mar 19, 2024
1a7a4a2
clean up rendering pt.1
UkoeHB Mar 19, 2024
cc7ac69
add comment
UkoeHB Mar 19, 2024
dc8c7ba
refactor PBR lighting so light filtering occurs on the CPU
UkoeHB Mar 19, 2024
187b8c0
fmt
UkoeHB Mar 19, 2024
3a5ce6f
review comments
UkoeHB Mar 19, 2024
1b6e31b
lints
UkoeHB Mar 19, 2024
dab2d88
lints
UkoeHB Mar 19, 2024
a07d7dc
cleanup
UkoeHB Mar 20, 2024
98d6883
fix query access error
UkoeHB Mar 20, 2024
57a7702
add upper bounds on RenderLayer
UkoeHB Mar 20, 2024
6f90f28
add docs
UkoeHB Mar 20, 2024
4614a5d
rebase and fix debug_overlay
UkoeHB Mar 20, 2024
7ac9b04
CI fixes
UkoeHB Mar 20, 2024
d8a63c1
CI complaints
UkoeHB Mar 20, 2024
c82492b
more CI
UkoeHB Mar 20, 2024
35b8dca
CI again
UkoeHB Mar 20, 2024
75b3be2
don't use default RenderGroups when propagating
UkoeHB Mar 20, 2024
5c40a7f
API cleanup
UkoeHB Mar 20, 2024
64ce22e
fix directional lights not being applied properly
UkoeHB Mar 21, 2024
a646c14
Render groups example (#2)
viridia Mar 21, 2024
52870ee
update directional light intersections with entities so if a camera s…
UkoeHB Mar 21, 2024
6d9a32d
update examples template
UkoeHB Mar 21, 2024
b82a084
clippy
UkoeHB Mar 21, 2024
858b88f
add floor to example:
UkoeHB Mar 21, 2024
962d722
fix shadows appearing erroneously for point and spot lights when ligh…
UkoeHB Mar 22, 2024
266b048
cleanup example
UkoeHB Mar 22, 2024
62c04aa
fmt
UkoeHB Mar 22, 2024
6b4a2d3
add second camera to render groups example
UkoeHB Mar 23, 2024
19bacda
simplify: RenderGroups -> RenderLayers, CameraView -> CameraLayer, li…
UkoeHB Mar 26, 2024
48dc2ee
fix examples
UkoeHB Mar 26, 2024
fb9d417
try to fix render_to_texture example
UkoeHB Mar 26, 2024
9c826d8
fmt
UkoeHB Mar 26, 2024
6f3909c
remove unsafe blocker from bevy_pbr
UkoeHB Apr 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simplify: RenderGroups -> RenderLayers, CameraView -> CameraLayer, li…
…ghts now intersect entities again but warn if they have more than one RenderLayer
  • Loading branch information
UkoeHB committed Apr 1, 2024
commit 19bacda2a6c94a0c79d28741f5ae24c4c5778092
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1998,9 +1998,9 @@ name = "render_groups"
path = "examples/3d/render_groups.rs"
doc-scrape-examples = true

[package.metadata.example.render_groups]
name = "Render Groups"
description = "Spawning multiple copies of a scene from a GLTF file, each with a different render group"
[package.metadata.example.render_layers]
name = "Render Layers"
description = "Load a scene from a glTF file and render it with different render layers."
category = "3D Rendering"
wasm = true

2 changes: 1 addition & 1 deletion assets/shaders/custom_material.vert
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ layout(location = 2) in vec2 Vertex_Uv;

layout(location = 0) out vec2 v_Uv;

layout(set = 0, binding = 0) uniform CameraViewProj {
layout(set = 0, binding = 0) uniform CameraLayerProj {
mat4 ViewProj;
mat4 View;
mat4 InverseView;
6 changes: 3 additions & 3 deletions crates/bevy_dev_tools/src/ui_debug_overlay/mod.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ use bevy_math::{Vec2, Vec3Swizzles};
use bevy_render::{
camera::RenderTarget,
prelude::*,
view::{RenderGroups, RenderLayer, VisibilitySystems},
view::{RenderLayer, RenderLayers, VisibilitySystems},
};
use bevy_transform::{prelude::GlobalTransform, TransformSystem};
use bevy_ui::{DefaultUiCamera, Display, Node, Style, TargetCamera, UiScale};
@@ -101,15 +101,15 @@ fn update_debug_camera(
},
..default()
},
RenderGroups::from_layer(LAYOUT_DEBUG_LAYER),
RenderLayers::from_layer(LAYOUT_DEBUG_LAYER),
DebugOverlayCamera,
Name::new("Layout Debug Camera"),
))
.id()
};
if let Some((config, _)) = gizmo_config.get_config_mut_dyn(&TypeId::of::<UiGizmosDebug>()) {
config.enabled = true;
config.render_groups = RenderGroups::from_layer(LAYOUT_DEBUG_LAYER);
config.render_layers = RenderLayers::from_layer(LAYOUT_DEBUG_LAYER);
}
let cam = *options.layout_gizmos_camera.get_or_insert_with(spawn_cam);
let Ok(mut cam) = debug_cams.get_mut(cam) else {
10 changes: 5 additions & 5 deletions crates/bevy_gizmos/src/config.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ pub use bevy_gizmos_macros::GizmoConfigGroup;

use bevy_ecs::{component::Component, reflect::ReflectResource, system::Resource};
use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath};
use bevy_render::view::RenderGroups;
use bevy_render::view::RenderLayers;
use bevy_utils::TypeIdMap;
use core::panic;
use std::{
@@ -164,7 +164,7 @@ pub struct GizmoConfig {
/// Describes which rendering layers gizmos will be rendered to.
///
/// Gizmos will only be rendered to cameras with intersecting layers.
pub render_groups: RenderGroups,
pub render_layers: RenderLayers,

/// Describe how lines should join
pub line_joints: GizmoLineJoint,
@@ -178,7 +178,7 @@ impl Default for GizmoConfig {
line_perspective: false,
line_style: GizmoLineStyle::Solid,
depth_bias: 0.,
render_groups: Default::default(),
render_layers: Default::default(),

line_joints: GizmoLineJoint::None,
}
@@ -189,15 +189,15 @@ impl Default for GizmoConfig {
pub(crate) struct GizmoMeshConfig {
pub line_perspective: bool,
pub line_style: GizmoLineStyle,
pub render_groups: RenderGroups,
pub render_layers: RenderLayers,
}

impl From<&GizmoConfig> for GizmoMeshConfig {
fn from(item: &GizmoConfig) -> Self {
GizmoMeshConfig {
line_perspective: item.line_perspective,
line_style: item.line_style,
render_groups: item.render_groups.clone(),
render_layers: item.render_layers.clone(),
}
}
}
14 changes: 7 additions & 7 deletions crates/bevy_gizmos/src/pipeline_2d.rs
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ use bevy_render::{
render_phase::{AddRenderCommand, DrawFunctions, SetItemPipeline, SortedRenderPhase},
render_resource::*,
texture::BevyDefault,
view::{ExtractedRenderGroups, ExtractedView, Msaa, ViewTarget},
view::{ExtractedRenderLayers, ExtractedView, Msaa, ViewTarget},
Render, RenderApp, RenderSet,
};
use bevy_sprite::{Mesh2dPipeline, Mesh2dPipelineKey, SetMesh2dViewBindGroup};
@@ -257,17 +257,17 @@ fn queue_line_gizmos_2d(
mut views: Query<(
&ExtractedView,
&mut SortedRenderPhase<Transparent2d>,
Option<&ExtractedRenderGroups>,
Option<&ExtractedRenderLayers>,
)>,
) {
let draw_function = draw_functions.read().get_id::<DrawLineGizmo2d>().unwrap();

for (view, mut transparent_phase, render_groups) in &mut views {
for (view, mut transparent_phase, render_layers) in &mut views {
let mesh_key = Mesh2dPipelineKey::from_msaa_samples(msaa.samples())
| Mesh2dPipelineKey::from_hdr(view.hdr);

for (entity, handle, config) in &line_gizmos {
if !config.render_groups.intersects_extracted(render_groups) {
if !config.render_layers.intersects_extracted(render_layers) {
continue;
}

@@ -309,20 +309,20 @@ fn queue_line_joint_gizmos_2d(
mut views: Query<(
&ExtractedView,
&mut SortedRenderPhase<Transparent2d>,
Option<&ExtractedRenderGroups>,
Option<&ExtractedRenderLayers>,
)>,
) {
let draw_function = draw_functions
.read()
.get_id::<DrawLineJointGizmo2d>()
.unwrap();

for (view, mut transparent_phase, render_groups) in &mut views {
for (view, mut transparent_phase, render_layers) in &mut views {
let mesh_key = Mesh2dPipelineKey::from_msaa_samples(msaa.samples())
| Mesh2dPipelineKey::from_hdr(view.hdr);

for (entity, handle, config) in &line_gizmos {
if !config.render_groups.intersects_extracted(render_groups) {
if !config.render_layers.intersects_extracted(render_layers) {
continue;
}

14 changes: 7 additions & 7 deletions crates/bevy_gizmos/src/pipeline_3d.rs
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ use bevy_render::{
render_phase::{AddRenderCommand, DrawFunctions, SetItemPipeline, SortedRenderPhase},
render_resource::*,
texture::BevyDefault,
view::{ExtractedRenderGroups, ExtractedView, Msaa, ViewTarget},
view::{ExtractedRenderLayers, ExtractedView, Msaa, ViewTarget},
Render, RenderApp, RenderSet,
};
use bevy_utils::tracing::error;
@@ -282,7 +282,7 @@ fn queue_line_gizmos_3d(
mut views: Query<(
&ExtractedView,
&mut SortedRenderPhase<Transparent3d>,
Option<&ExtractedRenderGroups>,
Option<&ExtractedRenderLayers>,
(
Has<NormalPrepass>,
Has<DepthPrepass>,
@@ -296,7 +296,7 @@ fn queue_line_gizmos_3d(
for (
view,
mut transparent_phase,
render_groups,
render_layers,
(normal_prepass, depth_prepass, motion_vector_prepass, deferred_prepass),
) in &mut views
{
@@ -320,7 +320,7 @@ fn queue_line_gizmos_3d(
}

for (entity, handle, config) in &line_gizmos {
if !config.render_groups.intersects_extracted(render_groups) {
if !config.render_layers.intersects_extracted(render_layers) {
continue;
}

@@ -363,7 +363,7 @@ fn queue_line_joint_gizmos_3d(
mut views: Query<(
&ExtractedView,
&mut SortedRenderPhase<Transparent3d>,
Option<&ExtractedRenderGroups>,
Option<&ExtractedRenderLayers>,
(
Has<NormalPrepass>,
Has<DepthPrepass>,
@@ -380,7 +380,7 @@ fn queue_line_joint_gizmos_3d(
for (
view,
mut transparent_phase,
render_groups,
render_layers,
(normal_prepass, depth_prepass, motion_vector_prepass, deferred_prepass),
) in &mut views
{
@@ -404,7 +404,7 @@ fn queue_line_joint_gizmos_3d(
}

for (entity, handle, config) in &line_gizmos {
if !config.render_groups.intersects_extracted(render_groups) {
if !config.render_layers.intersects_extracted(render_layers) {
continue;
}

Loading