#pragma once #include "gfx/dag_types.h" #include #include namespace fn::gfx { // Result of translating a Code-mode GLSL fragment shader into a DAG generator // body. `body_template` carries `__BASE__` placeholders that the body_glsl // lambda substitutes for the node's vec4 base index at compile time. struct CodeToGeneratorResult { bool ok = false; std::string err; std::string body_template; // body with __BASE__ tokens int param_count = 0; // size of step.params (4 × n_uniforms) std::vector param_defaults; std::vector param_names; std::vector controls; }; // Translate a Code-mode GLSL source (with `void main()` + `fragColor = ...;`) // into a DAG Gen body + controls. Each annotated uniform becomes a DagControl; // the body uses `uv` from the function parameter (any local `vec2 uv = ...;` // line is stripped). Returns ok=false with err set on parse / unsupported-type // errors. Pure: no I/O. // // Layout: each uniform claims one vec4 (4 floats), wasting unused components // to keep the float→vec4 mapping trivial. Total floats = 4 × num_uniforms. CodeToGeneratorResult code_to_generator(const std::string& source); // Wrap a translation result into a DagNodeDef ready for dag_register_node(). // kind = Gen, num_inputs = 0, is_builtin = false. DagNodeDef make_generator_def(const std::string& name, const std::string& label, const std::string& desc, const CodeToGeneratorResult& tr); } // namespace fn::gfx