pub struct ShaderNode {
pub id: NodeId,
pub node_type: NodeType,
pub label: String,
pub inputs: Vec<Socket>,
pub outputs: Vec<Socket>,
pub properties: HashMap<String, ParamValue>,
pub editor_x: f32,
pub editor_y: f32,
pub enabled: bool,
pub conditional_var: Option<String>,
pub conditional_threshold: f32,
}Expand description
A single node instance in a shader graph.
Fields§
§id: NodeId§node_type: NodeType§label: String§inputs: Vec<Socket>§outputs: Vec<Socket>§properties: HashMap<String, ParamValue>Extra per-node properties keyed by name.
editor_x: f32Position in the editor (for serialization).
editor_y: f32§enabled: boolWhether this node is enabled. Disabled nodes are skipped during compilation.
conditional_var: Option<String>Conditional: if set, this node is only active when the named game state variable exceeds the threshold.
conditional_threshold: f32Implementations§
Source§impl ShaderNode
impl ShaderNode
Sourcepub fn new(id: NodeId, node_type: NodeType) -> Self
pub fn new(id: NodeId, node_type: NodeType) -> Self
Create a new node with default sockets for the given type.
Sourcepub fn with_property(self, key: &str, value: ParamValue) -> Self
pub fn with_property(self, key: &str, value: ParamValue) -> Self
Set a property value.
Sourcepub fn with_input_default(self, socket_name: &str, value: ParamValue) -> Self
pub fn with_input_default(self, socket_name: &str, value: ParamValue) -> Self
Set a default value for an input socket by name.
Sourcepub fn with_condition(self, var_name: &str, threshold: f32) -> Self
pub fn with_condition(self, var_name: &str, threshold: f32) -> Self
Set the conditional gate on this node.
Sourcepub fn output_type(&self, index: usize) -> Option<DataType>
pub fn output_type(&self, index: usize) -> Option<DataType>
Get the output socket data type at the given index.
Sourcepub fn input_type(&self, index: usize) -> Option<DataType>
pub fn input_type(&self, index: usize) -> Option<DataType>
Get the input socket data type at the given index.
Sourcepub fn input_default(&self, index: usize) -> Option<&ParamValue>
pub fn input_default(&self, index: usize) -> Option<&ParamValue>
Get the default value for input socket at the given index.
Sourcepub fn var_prefix(&self) -> String
pub fn var_prefix(&self) -> String
Return the GLSL variable prefix for this node.
Sourcepub fn estimated_cost(&self) -> u32
pub fn estimated_cost(&self) -> u32
Compute a rough cost estimate for this node.
Trait Implementations§
Source§impl Clone for ShaderNode
impl Clone for ShaderNode
Source§fn clone(&self) -> ShaderNode
fn clone(&self) -> ShaderNode
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 ShaderNode
impl RefUnwindSafe for ShaderNode
impl Send for ShaderNode
impl Sync for ShaderNode
impl Unpin for ShaderNode
impl UnsafeUnpin for ShaderNode
impl UnwindSafe for ShaderNode
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.