Expand description
Node-based materials. A material is a graph of small nodes (textures, colours, maths, noise,
gradients…) saved as a .kmat file; to_wgsl turns it into a fragment shader that the
renderer compiles like any other custom shader. Drop a .kmat file on a model to use it.
Every socket carries a vec3 (a number is spread over all three channels), so any output can
feed any input. The three texture slots of a material (albedo, normal, ORM) are bound for the
“Texture” node.
use kvas_engine::material_graph::{MaterialGraph, to_wgsl};
let graph = MaterialGraph::default_graph();
let wgsl = to_wgsl(&graph).unwrap();
assert!(wgsl.contains("fn fs_main"));Structs§
- MatNode
- A node of the graph.
- Material
Graph - A whole material.
- Node
Spec - Static description of a node type.
- Socket
- One input socket of a node.
Enums§
- Graph
Mode - What a graph produces.
Constants§
- SPECS
- Every node type.
Functions§
- all_
specs - Every node type of both lists.
- available
- Whether a node type can be used in a graph of this kind.
- is_
output - True for the three result nodes.
- spec
- Looks a node type up by name.
- to_wgsl
- Generates the shader of a graph (the prelude and the library functions are added by the renderer):
a mesh shader for materials and shaders, an
effectfunction for camera effects.