Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add node groups (subgraphs) for VisualShader #7730

Open
Geometror opened this issue Sep 18, 2023 · 8 comments · May be fixed by godotengine/godot#99404
Open

Add node groups (subgraphs) for VisualShader #7730

Geometror opened this issue Sep 18, 2023 · 8 comments · May be fixed by godotengine/godot#99404

Comments

@Geometror
Copy link
Member

Geometror commented Sep 18, 2023

Describe the project you are working on

Godot

Describe the problem or limitation you are having in your project

Complex visual shader graphs can quickly become challenging to manage and maintain.
The users often need to repeat sections of their graphs, leading to redundancy and reduced readability.

Describe the feature/enhancement and how it helps to overcome the problem or limitation

The ability to create your own nodes (as group nodes) inside of the VisualShader editor would address these issues by allowing users to encapsulate frequently used sections of a shader and reuse them across the graph/other shaders.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Some impulses for the implementation:

  • NodeGroup is a resource containing the subgraph and information about input/output ports.
  • A 'NodeGroup' node then uses this resource and can be placed in a VisuaShader graph.
  • The group nodes contain a button (+shortcut/context menu action) to edit the subgraph.
  • Creating such a group should be simple and retaining, e.g. just selecting the nodes it should contain -> button/context menu/shortcut -> the selected nodes are replaced automatically with the group node (which already has the correct input/output ports added)
  • Subgraphs are edited in their own GraphEdit instance which replaces the currently visible instance in the VisualShader editor (may increase memory usage, but could be more performant)
  • The subgraph contains at least two nodes: Group Input and Group Output. With these the input/output ports of the node group node can be configured (names/types).

I would propose an implementation very similar to Blender.

The group node:
grafik
Editing the subgraph:
grafik

If this enhancement will not be used often, can it be worked around with a few lines of script?

No.

Is there a reason why this should be core and not an add-on in the asset library?

This needs to be deeply integrated into the VisualShader editor and is therefore core.

@Calinou Calinou changed the title Node groups (subgraphs) for VisualShader Add node groups (subgraphs) for VisualShader Sep 18, 2023
@Zaskek
Copy link

Zaskek commented Sep 19, 2023

Fully supporting this;node based interfaces are basically the de facto standard in most artistic pipelines and more so in tech-art, not having the option to create subgraphs is a HUUUGE pain when using visualshaders when creating something more complex or that needs to be re-used on a lot of materials (think about a basic rain ripples-wetness effect that you would want to apply on all materials when it's raining,with a subgraph that would be as easy as creating it one time and then adding in on all materials with the hypothetic IsRaining parameter to switch it on and blend it on top of the base material).
It would also aid non coders artists in using godot, which i think are found mainly in the middle to big sized teams/studios and could be a problem for them in choosing godot as a tech solution for their projects(?) and well we are experiencing quite the influx of them...

@dsitnick
Copy link

dsitnick commented Oct 2, 2023

Absolutely, and this looks like a great approach. This should be high priority for VisualShaders.

It's a super crucial tool not just for complex shaders, but in having any kind of global functionality.
Want to make use of a singular toon ramp across multiple shaders? Forget it
Also with since the expression node doesn't support referencing an external file, it's totally unmaintainable to make use of a single expression across multiple VisualShaders.

I'm sure this is already on people's radar, but it's a significant roadblock for getting familiar with these workflows.

Side note: If possible, add support for parameter nodes inside the NodeGroup. These parameters should be independent from the Group Input node, and should be exposed in the materials of all shaders containing that NodeGroup. In case of parameter name collisions, the parameter inside NodeGroup should keep the name.

@oxplay2
Copy link

oxplay2 commented Feb 2, 2024

Very good proposal

Just now, when i need add "repeatable" node-areas for a very big node graph, i could just use groups.

So what i did now was create VisualShaderNodeCustom that require "additional code" to setup it.

This feature would be very good, because i could just setup nodes in group instead of writing custom VisualShaderNodeCustom.

Just please make sure that can be "repeated" without dupplicating code

@ClintochX
Copy link

have they started working on this? 😢 I really need this

@Calinou
Copy link
Member

Calinou commented Jun 18, 2024

have they started working on this? 😢 I really need this

Not yet, but godotengine/godot#88014 is the first step towards making this possible.

@omid3098
Copy link

With a HUGE thumbs up for this proposal, I also want to suggest having 3 different grouping methods.

  • Groups: Basic grouping functionality to pack nodes and save space and preserving input and output pins.
  • Local SubGraphs: Same as groups but you can instance them and modifying one instance, changes them all. Equivalent to how we use private functions in programming languages.
  • SubGraph Resource: Same as Local Subgraphs but they are saved as a separate asset and can be shared between shaders.

@Geometror Geometror self-assigned this Jul 30, 2024
@ArseniyMirniy
Copy link

ArseniyMirniy commented Oct 28, 2024

I really need this for my Godot 4 Color Correction and Screen Effects Visual Shaders. Frames are a good start, but we definitely require more for big graphs to avoid building the same constructions many times on a limited frame.

@Geometror any news?

@Geometror Geometror linked a pull request Nov 18, 2024 that will close this issue
7 tasks
@Geometror
Copy link
Member Author

@ArseniyMirniy Yes, I've just opened godotengine/godot#99404. While it still requires lots of work, it's a start :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

8 participants