Skip to main content

Flow

The MaterialFlow plugin provides a visual material editor within Tellusim Engine applications. It enables node-based material authoring via a graph-based UI and supports live material preview.

MaterialFlow dynamically generates MaterialShading shading files for use in real-time rendering pipelines.

info

MaterialFlow is built on top of the ControlFlowGLSL node editor.

info

This plugin is integrated into Tellusim Explorer.

#include <materials/flow/include/TellusimMaterialFlow.h>

Example

// Create MaterialFlow control attached to a UI panel
MaterialFlow material_flow(&right_panel);
if(!material_flow.create()) return false;

// Set callback to update the material when the flow graph changes
material_flow.setChangedCallback([&](MaterialFlow *flow) {
if(flow->getSource() && material_shading.create(flow->getSource() + "#pragma dynamic\n#pragma quiet\n")) {
geometry_mesh.setMaterial(0, material_shading);
MaterialRoot::PassMask mask = MaterialRoot::PassMaskNone;
if(flow->getSource().contains("deferred")) mask |= MaterialRoot::PassMaskDeferred;
if(flow->getSource().contains("forward")) mask |= MaterialRoot::PassMaskForward;
if(flow->getSource().contains("transparent")) mask |= MaterialRoot::PassMaskTransparent;
if(flow->getSource().contains("shadow_map")) mask |= MaterialRoot::PassMaskShadowMap;
material_shading.setPassMask(mask);
material_shading.updateScene();
} else {
geometry_mesh.setMaterial(0, material_metallic);
}
object_mesh.updateGeometries();
object_mesh.updateScene();
});

// Undo/redo actions
if(window.getKeyboardKey('z', true) && window.getKeyboardKey(Window::KeyOption)) {
if(window.getKeyboardKey(Window::KeyShift)) material_flow.redo();
else material_flow.undo();
}
if(window.getKeyboardKey('y', true) && window.getKeyboardKey(Window::KeyOption)) {
material_flow.redo();
}