-
Notifications
You must be signed in to change notification settings - Fork 10
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
(WIP) Update to bevy 0.11 #21
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ use bevy::render::render_graph::RenderGraph; | |
use bevy::render::render_phase::{sort_phase_system, AddRenderCommand, DrawFunctions}; | ||
use bevy::render::render_resource::{SpecializedMeshPipelines, VertexFormat}; | ||
use bevy::render::view::RenderLayers; | ||
use bevy::render::{RenderApp, RenderSet}; | ||
use bevy::render::{Render, RenderApp, RenderSet}; | ||
use bevy::transform::TransformSystem; | ||
use interpolation::Lerp; | ||
|
||
|
@@ -207,37 +207,55 @@ impl Plugin for OutlinePlugin { | |
Shader::from_wgsl | ||
); | ||
|
||
app.add_plugin(ExtractComponentPlugin::<OutlineStencil>::extract_visible()) | ||
.add_plugin(ExtractComponentPlugin::<OutlineRenderLayers>::default()) | ||
.add_plugin(UniformComponentPlugin::<OutlineStencilUniform>::default()) | ||
.add_plugin(UniformComponentPlugin::<OutlineVolumeUniform>::default()) | ||
.add_plugin(UniformComponentPlugin::<OutlineFragmentUniform>::default()) | ||
.add_plugin(UniformComponentPlugin::<OutlineViewUniform>::default()) | ||
.add_system( | ||
compute_outline_depth | ||
.in_base_set(CoreSet::PostUpdate) | ||
.after(TransformSystem::TransformPropagate), | ||
) | ||
.sub_app_mut(RenderApp) | ||
.init_resource::<DrawFunctions<StencilOutline>>() | ||
.init_resource::<DrawFunctions<OpaqueOutline>>() | ||
.init_resource::<DrawFunctions<TransparentOutline>>() | ||
.init_resource::<OutlinePipeline>() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Everything here (and similar add_systems/add_plugins changes) was following the migration guide, including this line but I wanted to point out this one https://bevyengine.org/learn/migration-guides/0.10-0.11/#webgpu-support this line actually got removed here and is now done in the finish function on line 282 |
||
.init_resource::<SpecializedMeshPipelines<OutlinePipeline>>() | ||
.add_render_command::<StencilOutline, DrawStencil>() | ||
.add_render_command::<OpaqueOutline, DrawOutline>() | ||
.add_render_command::<TransparentOutline, DrawOutline>() | ||
.add_system(extract_outline_view_uniforms.in_schedule(ExtractSchedule)) | ||
.add_system(extract_outline_stencil_uniforms.in_schedule(ExtractSchedule)) | ||
.add_system(extract_outline_volume_uniforms.in_schedule(ExtractSchedule)) | ||
.add_system(sort_phase_system::<StencilOutline>.in_set(RenderSet::PhaseSort)) | ||
.add_system(sort_phase_system::<OpaqueOutline>.in_set(RenderSet::PhaseSort)) | ||
.add_system(sort_phase_system::<TransparentOutline>.in_set(RenderSet::PhaseSort)) | ||
.add_system(queue_outline_view_bind_group.in_set(RenderSet::Queue)) | ||
.add_system(queue_outline_stencil_bind_group.in_set(RenderSet::Queue)) | ||
.add_system(queue_outline_volume_bind_group.in_set(RenderSet::Queue)) | ||
.add_system(queue_outline_stencil_mesh.in_set(RenderSet::Queue)) | ||
.add_system(queue_outline_volume_mesh.in_set(RenderSet::Queue)); | ||
app.add_plugins(( | ||
ExtractComponentPlugin::<OutlineStencil>::extract_visible(), | ||
ExtractComponentPlugin::<OutlineRenderLayers>::default(), | ||
UniformComponentPlugin::<OutlineStencilUniform>::default(), | ||
UniformComponentPlugin::<OutlineVolumeUniform>::default(), | ||
UniformComponentPlugin::<OutlineFragmentUniform>::default(), | ||
UniformComponentPlugin::<OutlineViewUniform>::default(), | ||
)) | ||
.add_systems( | ||
PostUpdate, | ||
compute_outline_depth.after(TransformSystem::TransformPropagate), | ||
) | ||
.sub_app_mut(RenderApp) | ||
.init_resource::<DrawFunctions<StencilOutline>>() | ||
.init_resource::<DrawFunctions<OpaqueOutline>>() | ||
.init_resource::<DrawFunctions<TransparentOutline>>() | ||
.init_resource::<SpecializedMeshPipelines<OutlinePipeline>>() | ||
.add_render_command::<StencilOutline, DrawStencil>() | ||
.add_render_command::<OpaqueOutline, DrawOutline>() | ||
.add_render_command::<TransparentOutline, DrawOutline>() | ||
.add_systems(ExtractSchedule, extract_outline_view_uniforms) | ||
.add_systems(ExtractSchedule, extract_outline_stencil_uniforms) | ||
.add_systems(ExtractSchedule, extract_outline_volume_uniforms) | ||
.add_systems( | ||
Render, | ||
sort_phase_system::<StencilOutline>.in_set(RenderSet::PhaseSort), | ||
) | ||
.add_systems( | ||
Render, | ||
sort_phase_system::<OpaqueOutline>.in_set(RenderSet::PhaseSort), | ||
) | ||
.add_systems( | ||
Render, | ||
sort_phase_system::<TransparentOutline>.in_set(RenderSet::PhaseSort), | ||
) | ||
.add_systems( | ||
Render, | ||
queue_outline_view_bind_group.in_set(RenderSet::Queue), | ||
) | ||
.add_systems( | ||
Render, | ||
queue_outline_stencil_bind_group.in_set(RenderSet::Queue), | ||
) | ||
.add_systems( | ||
Render, | ||
queue_outline_volume_bind_group.in_set(RenderSet::Queue), | ||
) | ||
.add_systems(Render, queue_outline_stencil_mesh.in_set(RenderSet::Queue)) | ||
.add_systems(Render, queue_outline_volume_mesh.in_set(RenderSet::Queue)); | ||
|
||
let world = &mut app.sub_app_mut(RenderApp).world; | ||
let node = OutlineNode::new(world); | ||
|
@@ -248,16 +266,10 @@ impl Plugin for OutlinePlugin { | |
.get_sub_graph_mut(bevy::core_pipeline::core_3d::graph::NAME) | ||
.unwrap(); | ||
draw_3d_graph.add_node(OUTLINE_PASS_NODE_NAME, node); | ||
draw_3d_graph.add_slot_edge( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
draw_3d_graph.input_node().id, | ||
bevy::core_pipeline::core_3d::graph::input::VIEW_ENTITY, | ||
OUTLINE_PASS_NODE_NAME, | ||
OutlineNode::IN_VIEW, | ||
); | ||
|
||
// Run after main 3D pass, but before UI psss | ||
draw_3d_graph.add_node_edge( | ||
bevy::core_pipeline::core_3d::graph::node::MAIN_PASS, | ||
bevy::core_pipeline::core_3d::graph::node::END_MAIN_PASS, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is due to this it's listed under the 0.11 update https://bevyengine.org/news/bevy-0-11/#rendering but not in the migration guide. As I mentioned in the PR description, when I had this set to START_MAIN_PASS, sometimes while running the examples I didn't get outlines at all. END_MAIN_PASS works better but I did notice a bit more transparency than usual in the shapes example. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am pretty sure using |
||
OUTLINE_PASS_NODE_NAME, | ||
); | ||
#[cfg(feature = "bevy_ui")] | ||
|
@@ -266,4 +278,9 @@ impl Plugin for OutlinePlugin { | |
bevy::ui::draw_ui_graph::node::UI_PASS, | ||
); | ||
} | ||
|
||
fn finish(&self, app: &mut App) { | ||
app.sub_app_mut(RenderApp) | ||
.init_resource::<OutlinePipeline>(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ use std::cmp::Reverse; | |
use bevy::ecs::system::lifetimeless::Read; | ||
use bevy::prelude::*; | ||
use bevy::render::camera::ExtractedCamera; | ||
use bevy::render::render_graph::{NodeRunError, SlotInfo, SlotType}; | ||
use bevy::render::render_graph::NodeRunError; | ||
use bevy::render::render_phase::{ | ||
CachedRenderPipelinePhaseItem, DrawFunctionId, PhaseItem, RenderPhase, | ||
}; | ||
|
@@ -128,8 +128,6 @@ pub(crate) struct OutlineNode { | |
} | ||
|
||
impl OutlineNode { | ||
pub(crate) const IN_VIEW: &'static str = "view"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these changes are again due to this |
||
|
||
pub(crate) fn new(world: &mut World) -> Self { | ||
Self { | ||
query: world.query_filtered(), | ||
|
@@ -138,10 +136,6 @@ impl OutlineNode { | |
} | ||
|
||
impl Node for OutlineNode { | ||
fn input(&self) -> Vec<SlotInfo> { | ||
vec![SlotInfo::new(Self::IN_VIEW, SlotType::Entity)] | ||
} | ||
|
||
fn update(&mut self, world: &mut World) { | ||
self.query.update_archetypes(world); | ||
} | ||
|
@@ -152,7 +146,7 @@ impl Node for OutlineNode { | |
render_context: &mut RenderContext, | ||
world: &World, | ||
) -> Result<(), NodeRunError> { | ||
let view_entity = graph.get_input_entity(Self::IN_VIEW)?; | ||
let view_entity = graph.view_entity(); | ||
let (camera, stencil_phase, opaque_phase, transparent_phase, camera_3d, target, depth) = | ||
match self.query.get_manual(world, view_entity) { | ||
Ok(query) => query, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
#import bevy_pbr::mesh_view_bindings | ||
#import bevy_pbr::mesh_types | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these shader changes were due to this https://bevyengine.org/learn/migration-guides/0.10-0.11/#improve-shader-import-model I'm not as experienced with these shaders, so I wouldn't be surprised if there are changes here that "work" but may only work in the cases I've been testing. |
||
#import bevy_render::view View | ||
#import bevy_pbr::mesh_types Mesh | ||
#import bevy_pbr::mesh_types SkinnedMesh | ||
|
||
struct VertexInput { | ||
@location(0) position: vec3<f32>, | ||
#ifndef OFFSET_ZERO | ||
@location(1) normal: vec3<f32>, | ||
#endif | ||
#ifdef SKINNED | ||
@location(2) joint_indexes: vec4<u32>, | ||
@location(3) joint_weights: vec4<f32>, | ||
@location(5) joint_indices: vec4<u32>, | ||
@location(6) joint_weights: vec4<f32>, | ||
#endif | ||
}; | ||
|
||
|
@@ -30,14 +31,14 @@ struct OutlineVertexUniform { | |
offset: f32, | ||
}; | ||
|
||
@group(0) @binding(0) | ||
var<uniform> view: View; | ||
|
||
@group(1) @binding(0) | ||
var<uniform> mesh: Mesh; | ||
|
||
#ifdef SKINNED | ||
@group(1) @binding(1) | ||
var<uniform> joint_matrices: SkinnedMesh; | ||
#import bevy_pbr::skinning | ||
#endif | ||
#import bevy_pbr::morph | ||
|
||
@group(2) @binding(0) | ||
var<uniform> view_uniform: OutlineViewUniform; | ||
|
@@ -62,7 +63,7 @@ fn model_origin_z(plane: vec3<f32>, view_proj: mat4x4<f32>) -> f32 { | |
@vertex | ||
fn vertex(vertex: VertexInput) -> VertexOutput { | ||
#ifdef SKINNED | ||
let model = skin_model(vertex.joint_indexes, vertex.joint_weights); | ||
let model = bevy_pbr::skinning::skin_model(vertex.joint_indices, vertex.joint_weights); | ||
#else | ||
let model = mesh.model; | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migration guide: https://bevyengine.org/learn/migration-guides/0.10-0.11/#change-default-tonemapping-method
without these, everything was pink!