Application
Video Demo
Quick Notes
An application created in C++ to represent shader creation using shader nodes, UI was created with ImGui as a research into the creation of Visual Programing frameworks.
To create the context menu I used a popup context menu from ImGui with a nodeMap collection, this map simply held the name of the node in string format and a function pointer to its create static function, that way I can specify which create function to call based on the button clicked and I save myself a hefty switch statement.
Now that we have the context menu working, and made it expandable as well we are ready to include node functionality.
For the nodes, I decided to have an Output node that would show the end result of the shader graph, as well as some basic operations like Multiply, Add, Substract, Color, Normalize with the intention of adding more later.
Design for Nodes includes a ShaderNode which is the item that is now being handled by the Manager, this ShaderNode object contains a node that can be anything derived from ShaderNodeBase, this way we can implement MultiplyNode, AddNode, NormalizeNode etc and it would be accepted in the manager. The nodes themselves would just contain Pin objects (these can be Input pins or Output pins) and their number depends on the node used. For example, AddNode has 2 Input Pins and 1 Output Pin. Pins handle their own drawing and functionality including knowing who owns it.
For connectivity between Pins I created a Link class, the idea is that when 2 pins are chosen there would be a Link created for them and this Link would be used to draw the lines between. For now I created a method that will be executed on click (should be drag but that inserts more complications that I will address soon) basically the method takes one Pin clicked and sets it in stand-by then when another pin is clicked if it’s a good match (Input <-> Output, Output <-> Input) then it establishes a link between them. During the canvas drawing phase the Links are drawn and their values are passed down from output pin to input pin.