use serde::{Deserialize, Serialize};
use crate::material::Material;
use crate::pass::PassKind;
use crate::resource::ResourceId;
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
pub struct NodeId(pub String);
impl NodeId {
#[must_use]
pub fn new(s: impl Into<String>) -> Self {
Self(s.into())
}
#[must_use]
pub fn as_str(&self) -> &str {
&self.0
}
}
impl From<&str> for NodeId {
fn from(s: &str) -> Self {
Self(s.to_string())
}
}
impl From<String> for NodeId {
fn from(s: String) -> Self {
Self(s)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Node {
pub id: NodeId,
pub pass: PassKind,
pub inputs: Vec<ResourceId>,
pub outputs: Vec<ResourceId>,
pub material: Option<Material>,
}
impl Node {
#[must_use]
pub fn fullscreen_effect(
id: impl Into<NodeId>,
material: Material,
input: impl Into<ResourceId>,
output: impl Into<ResourceId>,
) -> Self {
Self {
id: id.into(),
pass: PassKind::Render,
inputs: vec![input.into()],
outputs: vec![output.into()],
material: Some(material),
}
}
#[must_use]
pub fn clear(id: impl Into<NodeId>, output: impl Into<ResourceId>) -> Self {
Self {
id: id.into(),
pass: PassKind::Render,
inputs: vec![],
outputs: vec![output.into()],
material: None,
}
}
}