Skip to content

Add shader graph node system (sky::sg) for UE-style material blueprints#77

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/design-shadergraph-node-system
Draft

Add shader graph node system (sky::sg) for UE-style material blueprints#77
Copilot wants to merge 2 commits intomainfrom
copilot/design-shadergraph-node-system

Conversation

Copy link

Copilot AI commented Mar 10, 2026

Introduces a visual shader graph node system (sky::sg namespace) following UE material blueprint conventions, with HLSL code generation and Qt-based editor integration.

Core Data Model (engine/render/shader/include/shader/shadergraph/)

  • ShaderGraphTypes.hSGDataType (Float/Vec2/3/4/Texture2D/Sampler), MaterialSlot enum, HLSL type helpers
  • ShaderGraphPin.hSGPin, SGPinID, SGConnection for typed graph connectivity
  • ShaderGraphNode.hSGNode base class with pin management and SGCodeGenContext for HLSL emission
  • Math nodes (14): Add, Subtract, Multiply, Divide, Lerp, Clamp, Saturate, Abs, Power, Dot, Cross, Normalize, ComponentMask, Append
  • Input nodes: TexCoord, VertexColor, WorldPosition, WorldNormal, Time, Constants (Float/Vec2/3/4), Parameters (Scalar/Vector/Texture), TextureSample
  • SGMaterialOutputNode — terminal node with PBR slots: BaseColor, Metallic, Roughness, Normal, Emissive, Opacity, OpacityMask
  • ShaderGraph — graph container with connection management, topological HLSL codegen, JSON serialization, and a static node-type factory registry
// Build a graph programmatically
sg::ShaderGraph graph;
auto texParam = std::make_shared<sg::SGTextureParamNode>("Albedo");
auto uvNode   = std::make_shared<sg::SGTexCoordNode>();
auto sample   = std::make_shared<sg::SGTextureSampleNode>();
auto output   = std::make_shared<sg::SGMaterialOutputNode>();
graph.AddNode(texParam); graph.AddNode(uvNode);
graph.AddNode(sample);   graph.AddNode(output);
graph.AddConnection({{texParam->GetId(), 0}, {sample->GetId(), 0}}); // Texture → sample
graph.AddConnection({{uvNode->GetId(),   0}, {sample->GetId(), 2}}); // UV → sample
graph.AddConnection({{sample->GetId(),   1}, {output->GetId(), 0}}); // RGB → BaseColor

auto code = graph.GenerateHLSL();
// code.declarations: "Texture2D Albedo;\nSamplerState AlbedoSampler;\n"
// code.body:         per-pixel HLSL assignments into `surface.*`

Asset Integration (engine/render/adaptor/)

  • ShaderGraphAsset.h/cppShaderGraphAssetData with AssetTraits<ShaderGraphAssetTag> (type "ShaderGraph", .shadergraph extension)

Editor UI (engine/render/editor/)

  • ShaderGraphNodeModel — QtNodes NodeDelegateModel wrappers; SGConcreteNodeModel<T> template for zero-boilerplate default-constructible models; embedded widgets for parameter naming and constant value editing
  • ShaderGraphWidgetDataFlowGraphModel-backed visual editor; nodes organized by category (Math / Input / Constant / Parameter / Texture / Output)
  • ShaderGraphEditWindowIAssetPreviewWndFactory for asset browser integration
  • ShaderGraphCreatorAssetCreatorBase registered as "Shader Graph" in RenderEditorModule

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: bluesky013 <35895395+bluesky013@users.noreply.github.com>
Copilot AI changed the title [WIP] Design shadergraph node system for UE shader blueprints Add shader graph node system (sky::sg) for UE-style material blueprints Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants