pub struct ShaderGraph {
pub name: String,
/* private fields */
}Expand description
A complete shader graph containing nodes and connections.
Fields§
§name: StringImplementations§
Source§impl ShaderGraph
impl ShaderGraph
Sourcepub fn add_node(&mut self, node_type: NodeType) -> NodeId
pub fn add_node(&mut self, node_type: NodeType) -> NodeId
Add a node to the graph, returning its ID.
Sourcepub fn add_node_with(&mut self, node: ShaderNode) -> NodeId
pub fn add_node_with(&mut self, node: ShaderNode) -> NodeId
Add a pre-built node to the graph.
Sourcepub fn insert_node(&mut self, node: ShaderNode) -> NodeId
pub fn insert_node(&mut self, node: ShaderNode) -> NodeId
Add a pre-built node, reusing its existing ID if set, or allocating one.
Sourcepub fn connect(
&mut self,
from_node: NodeId,
from_socket: usize,
to_node: NodeId,
to_socket: usize,
)
pub fn connect( &mut self, from_node: NodeId, from_socket: usize, to_node: NodeId, to_socket: usize, )
Connect an output socket of one node to an input socket of another.
Sourcepub fn disconnect_node(&mut self, node_id: NodeId)
pub fn disconnect_node(&mut self, node_id: NodeId)
Remove all connections involving a node.
Sourcepub fn disconnect(
&mut self,
from_node: NodeId,
from_socket: usize,
to_node: NodeId,
to_socket: usize,
)
pub fn disconnect( &mut self, from_node: NodeId, from_socket: usize, to_node: NodeId, to_socket: usize, )
Remove a specific connection.
Sourcepub fn remove_node(&mut self, node_id: NodeId)
pub fn remove_node(&mut self, node_id: NodeId)
Remove a node and all its connections.
Sourcepub fn node_mut(&mut self, id: NodeId) -> Option<&mut ShaderNode>
pub fn node_mut(&mut self, id: NodeId) -> Option<&mut ShaderNode>
Get a mutable reference to a node.
Sourcepub fn nodes(&self) -> impl Iterator<Item = &ShaderNode>
pub fn nodes(&self) -> impl Iterator<Item = &ShaderNode>
Iterate over all nodes.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes.
Sourcepub fn connections(&self) -> &[Connection]
pub fn connections(&self) -> &[Connection]
Get all connections.
Sourcepub fn incoming_connections(&self, node_id: NodeId) -> Vec<&Connection>
pub fn incoming_connections(&self, node_id: NodeId) -> Vec<&Connection>
Get connections feeding into a specific node’s input socket.
Sourcepub fn outgoing_connections(&self, node_id: NodeId) -> Vec<&Connection>
pub fn outgoing_connections(&self, node_id: NodeId) -> Vec<&Connection>
Get connections going out of a specific node.
Sourcepub fn output_nodes(&self) -> Vec<NodeId>
pub fn output_nodes(&self) -> Vec<NodeId>
Find all output nodes (MainColor, EmissionBuffer, BloomBuffer, NormalOutput).
Sourcepub fn source_nodes(&self) -> Vec<NodeId>
pub fn source_nodes(&self) -> Vec<NodeId>
Find all source nodes (no required input connections).
Sourcepub fn estimated_cost(&self) -> u32
pub fn estimated_cost(&self) -> u32
Compute the total estimated instruction cost of the graph.
Sourcepub fn validate(&self) -> Vec<String>
pub fn validate(&self) -> Vec<String>
Validate basic graph integrity: all connections reference existing nodes, socket indices are in range, no self-loops.
Sourcepub fn topology_hash(&self) -> u64
pub fn topology_hash(&self) -> u64
Compute a topology hash for caching/deduplication.
Sourcepub fn nodes_map(&self) -> &HashMap<NodeId, ShaderNode>
pub fn nodes_map(&self) -> &HashMap<NodeId, ShaderNode>
Return the internal nodes map (used for serialization).
Sourcepub fn next_id_counter(&self) -> u64
pub fn next_id_counter(&self) -> u64
Return the next_id counter (used for serialization).
Sourcepub fn set_next_id(&mut self, val: u64)
pub fn set_next_id(&mut self, val: u64)
Set the next_id counter (used during deserialization).
Sourcepub fn add_connection_raw(&mut self, conn: Connection)
pub fn add_connection_raw(&mut self, conn: Connection)
Add a raw connection without duplicate-input removal (used during deserialization).
Trait Implementations§
Source§impl Clone for ShaderGraph
impl Clone for ShaderGraph
Source§fn clone(&self) -> ShaderGraph
fn clone(&self) -> ShaderGraph
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ShaderGraph
impl Debug for ShaderGraph
Auto Trait Implementations§
impl Freeze for ShaderGraph
impl RefUnwindSafe for ShaderGraph
impl Send for ShaderGraph
impl Sync for ShaderGraph
impl Unpin for ShaderGraph
impl UnsafeUnpin for ShaderGraph
impl UnwindSafe for ShaderGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.