rasen
The rasen
crate contains the core graph compiler itself. It provides graph building utilities (the Graph
struct),
various types (rasen::types::*
) and operations (rasen::node::*
) definitions, and SPIR-V compilation utilities (the
Builder
struct).
It's perfectly possible to use this crate as-is by creating a Graph
struct and buidling the module node-by-node,
though this method tends to be quite verbose:
extern crate rasen;
use rasen::prelude::*;
fn main() {
let mut graph = Graph::new();
let normal = graph.add_node(Node::Input(0, TypeName::Vec(3)));
let min_light = graph.add_node(Node::Constant(TypedValue::Float(0.1)));
let max_light = graph.add_node(Node::Constant(TypedValue::Float(1.0)));
let light_dir = graph.add_node(Node::Constant(TypedValue::Vec3(0.3, -0.5, 0.2)));
let mat_color = graph.add_node(Node::Constant(TypedValue::Vec4(0.25, 0.625, 1.0, 1.0)));
let normalize = graph.add_node(Node::Normalize);
let dot = graph.add_node(Node::Dot);
let clamp = graph.add_node(Node::Clamp);
let multiply = graph.add_node(Node::Multiply);
let color = graph.add_node(Node::Output(0, TypeName::Vec(4)));
graph.add_edge(normal, normalize, 0);
graph.add_edge(normalize, dot, 0);
graph.add_edge(light_dir, dot, 1);
graph.add_edge(dot, clamp, 0);
graph.add_edge(min_light, clamp, 1);
graph.add_edge(max_light, clamp, 2);
graph.add_edge(clamp, multiply, 0);
graph.add_edge(mat_color, multiply, 1);
graph.add_edge(multiply, color, 0);
let bytecode = build_program(&graph, ShaderType::Fragment).unwrap();
}