godot-visual-script icon indicating copy to clipboard operation
godot-visual-script copied to clipboard

Groups Nodes replace Functions in Visual Scripting

Open swarnimarun opened this issue 5 years ago • 10 comments

Groups Nodes replace Functions

Grouping of Nodes in a chain should be allowed to simplify the process of creation of Node Units and increasing reusability of parts of the Visual Scripts.

image Quick Mockup.

Group Nodes should be stored as custom Nodes that are accessible from the same drop down for searching the Nodes and also allow for saving and loading groups as resources for use as custom nodes all across the project.

Probably even have a default folder where we can place all the Grouped Node(Custom Node) Resources that we want to be accessible across the project as custom nodes, automagically. This would remove the need to newbie users to learn how to create Tool Scripts.

Details

The Groups will be simple and clean and will act like bookmarks that will take us to the respective Group Node Structure we double click on.

The Groups will be a much simpler concept compared to functions but will technically use the same structure/codebase. It will also the first step towards addition of Unified Visual Script editor Graph.

Being able to save these can come extremely handy, such as having a module for simple visual script functions required and even Visual Shader node groups.

swarnimarun avatar May 07 '19 21:05 swarnimarun

cc: @fire

swarnimarun avatar May 07 '19 21:05 swarnimarun

Moved this comment here.

Groups

We have a super class called groups which are an interface with implementation.

This feature is useful for merge and removing entire groups of nodes.

Groups have:

  • title
  • a list of grouped nodes
  • input-output port
  • position

Comments

Comments derives from the group class.

Each comment group can be moved as a group.

Each comment has:

  • Inherited group properties
  • comment string.

Custom nodes

Custom nodes derive from the group class.

Each custom node has:

  • Inherited group members
  • Gdscript

Expression nodes in Visual Shader

An expression derives from the group class

Each expression node has:

  • Inherited group members
  • Shaders code (text)

To do for loops requires a generic shader node.

The Expression node is enough for "for" loops. The Visual Shaders currently do not support Functions and Flow control signatures.

#22243

Requires adding a method to add input variables.

fire avatar May 07 '19 21:05 fire

I don't think it's good for ui to merge the concept of commenting and node definition. The "GroupA" in the mockup should stay a comment and not a integrated blob structure that auto expands from a node definition.

There could be a concept of autoloaded visual script libraries that are vs scripts and are effectively globals.

fire avatar May 08 '19 14:05 fire

This feature/proposal went through a lot of discussions internally and we decided to not remove functions for both backwards compatibilities and to keep the system as simplistic.

But rather add a Visualscript submodules feature to be able to save blocks of visual script code as resources aka submodules and then reuse it in any other script or multiple times in the same script via simple import mechanisms. And have the same edit functionality as the VisualScript.

swarnimarun avatar Sep 20 '19 01:09 swarnimarun

Hey all, any update on the project? I'm currently writing a shader mixed with nodes and "expression" nodes (code), but I really need to collect a lot of reused code into a custom node. Would be awesome to have this feature now 0:) Cheers and stay healthy!

shiMusa avatar Mar 17 '20 01:03 shiMusa

@shiMusa Well things will get redone for 4.0 and this will likely make it in then, so not likely that it will be available in 3.2. Unless I find a way to implement it without breaking compatibility.....

swarnimarun avatar Mar 17 '20 07:03 swarnimarun

@swarnimarun Ping! How is the rebase?

fire avatar Jan 18 '21 16:01 fire

@fire https://github.com/godotengine/godot/pull/45294

Created the draft PR, will be testing it a bit just to see if perhaps something else might have broken during rebase of Godot GUI code changes.

swarnimarun avatar Jan 18 '21 19:01 swarnimarun

I'll keep this proposal open until it is merged.

fire avatar Feb 07 '21 16:02 fire

Note that I've transferred it despite groups being useful in shaders as well because most of the discussion and work referenced here seems to be around scripting. A new proposal can be made in the main repo for group in graphs in general or for grouping in shaders. I suspect the underlying implementations for shaders would be pretty different anyway.

YuriSizov avatar Aug 24 '22 20:08 YuriSizov