pub struct MeshNode {
pub pass: MeshPass,
pub queue: Rc<RefCell<MeshQueue>>,
pub clear_color: Option<Color>,
}Expand description
Render node for 3D mesh rendering with depth testing.
MeshNode renders all meshes queued in its associated MeshQueue.
It supports:
- Depth testing for correct occlusion
- Per-instance transforms and color tints
- Optional texturing
- Compositing over previous pass output (background blitting)
§Integration with Render Graph
When used after other nodes (e.g., an effect pass for a background),
MeshNode first blits the input texture, then renders meshes on top
with depth testing. This allows 3D objects to be composited over
procedural backgrounds.
§Clear Behavior
By default, MeshNode does not clear the target, allowing it to
render on top of the previous pass. Use with_clear
if you want to clear to a solid color first.
§Example
let queue = Rc::new(RefCell::new(MeshQueue::new()));
let cube_idx = queue.borrow_mut().add_mesh(Mesh::cube(&gpu));
let graph = RenderGraph::builder()
.node(EffectNode::new(sky_effect)) // Background
.node(MeshNode::new(&gpu, Rc::clone(&queue))) // 3D meshes on top
.node(PostProcessNode::new(tonemap)) // Post-process
.build(&gpu);
// In render loop:
queue.borrow_mut().draw(cube_idx, Transform::default(), Color::WHITE);
graph.execute(&gpu, time, &camera);
queue.borrow_mut().clear_queue();Fields§
§pass: MeshPassThe mesh rendering pass with pipeline and depth buffer.
queue: Rc<RefCell<MeshQueue>>Shared queue containing meshes, textures, and draw calls.
clear_color: Option<Color>Optional clear color. None preserves previous pass output.
Implementations§
Source§impl MeshNode
impl MeshNode
Sourcepub fn new(gpu: &GpuContext, queue: Rc<RefCell<MeshQueue>>) -> Self
pub fn new(gpu: &GpuContext, queue: Rc<RefCell<MeshQueue>>) -> Self
Creates a new mesh render node.
The node is configured to render on top of the previous pass by default (no clearing). The depth buffer is created at the current GPU surface size.
§Arguments
gpu- GPU context for creating the mesh pass and depth bufferqueue- Shared mesh queue (typicallyRc<RefCell<MeshQueue>>)
Sourcepub fn with_clear(self, color: Color) -> Self
pub fn with_clear(self, color: Color) -> Self
Sets a clear color, causing the target to be cleared before rendering.
Use this when MeshNode is the first node in the graph or when you
don’t want to preserve the previous pass output.
§Arguments
color- The color to clear to before rendering meshes
§Returns
Self for method chaining (builder pattern).
Trait Implementations§
Source§impl RenderNode for MeshNode
impl RenderNode for MeshNode
Source§fn execute(
&self,
ctx: &mut RenderContext<'_>,
target: &TextureView,
input: Option<&TextureView>,
)
fn execute( &self, ctx: &mut RenderContext<'_>, target: &TextureView, input: Option<&TextureView>, )
Source§fn check_hot_reload(&mut self, gpu: &GpuContext)
fn check_hot_reload(&mut self, gpu: &GpuContext)
execute() to check for hot-reload changes. Read moreAuto Trait Implementations§
impl Freeze for MeshNode
impl !RefUnwindSafe for MeshNode
impl !Send for MeshNode
impl !Sync for MeshNode
impl Unpin for MeshNode
impl !UnwindSafe for MeshNode
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more