pub struct ShaderGraph {
pub name: String,
pub nodes: HashMap<NodeId, ShaderNode>,
pub edges: Vec<ShaderEdge>,
pub parameters: Vec<ShaderParameter>,
pub output_node: Option<NodeId>,
/* private fields */
}Expand description
A directed acyclic graph of shader processing nodes.
Fields§
§name: String§nodes: HashMap<NodeId, ShaderNode>§edges: Vec<ShaderEdge>§parameters: Vec<ShaderParameter>§output_node: Option<NodeId>The node whose output is the final fragment color.
Implementations§
Source§impl ShaderGraph
impl ShaderGraph
pub fn new(name: impl Into<String>) -> Self
pub fn add_node(&mut self, node_type: NodeType) -> NodeId
pub fn add_node_at(&mut self, node_type: NodeType, x: f32, y: f32) -> NodeId
pub fn remove_node(&mut self, id: NodeId) -> bool
pub fn node(&self, id: NodeId) -> Option<&ShaderNode>
pub fn node_mut(&mut self, id: NodeId) -> Option<&mut ShaderNode>
pub fn set_output(&mut self, id: NodeId)
pub fn connect( &mut self, from_node: NodeId, from_slot: u8, to_node: NodeId, to_slot: u8, ) -> Result<EdgeId, GraphError>
pub fn disconnect(&mut self, edge_id: EdgeId) -> bool
pub fn disconnect_input(&mut self, to_node: NodeId, to_slot: u8)
pub fn add_parameter(&mut self, param: ShaderParameter) -> usize
pub fn set_parameter_float(&mut self, name: &str, value: f32)
Sourcepub fn update_parameters(&mut self, time: f32)
pub fn update_parameters(&mut self, time: f32)
Update animated parameters by evaluating their MathFunction drivers.
Sourcepub fn compile(&self) -> Result<CompiledShader, GraphError>
pub fn compile(&self) -> Result<CompiledShader, GraphError>
Compile the graph to GLSL. Returns an error if the graph is invalid.
Sourcepub fn validate(&self) -> Vec<GraphError>
pub fn validate(&self) -> Vec<GraphError>
Validate graph structure without compiling.
Sourcepub fn topological_order(&self) -> Result<Vec<NodeId>, GraphError>
pub fn topological_order(&self) -> Result<Vec<NodeId>, GraphError>
Returns nodes in evaluation order (inputs before outputs).
pub fn to_toml(&self) -> String
Sourcepub fn stats(&self) -> GraphStats
pub fn stats(&self) -> GraphStats
Statistics about the graph.
Trait Implementations§
Source§impl Clone for ShaderGraph
impl Clone for ShaderGraph
Source§fn clone(&self) -> ShaderGraph
fn clone(&self) -> ShaderGraph
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto 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
Mutably borrows from an owned value. Read more
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.