godot-proposals icon indicating copy to clipboard operation
godot-proposals copied to clipboard

Add portals (set/get variable) to the visual shader editor

Open SubtleMetaphor opened this issue 1 year ago • 2 comments

Describe the project you are working on

Godot

Describe the problem or limitation you are having in your project

When working with the Shader Editor (creating shaders visually using nodes) it can become quite tangled or difficult to organize.

Here's an example from Unity's shader editor (which does not support portals/variables), where things have gotten frustratingly entangled:

82a0b4130e78a4af1511df02bb0e72fa

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

One feature that some tools or engines have is the ability to create a "portal" inside the shader editor. Essentially a node for setting a variable, and later getting it at some stage. It is, in a way, similar to the varyings implementation in Godot. However, varyings is a way for the vertex shader to communicate with the fragment shader, and that is not what this is. There may be portals that only exist within the vertex shader, or only within the fragment shader. Using a varying for this is not ideal for a lot of situations where you want higher fidelity (by only using fragment shader), or where you only want the data to exist within the vertex shader.

61559c3289aad2a5af18074e0b815328 (Screenshot of a shader made in Amplify Shader Editor for Unity, which does support setting/getting variables.)

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

Here's close up shots of portals/variable set/get.

386d30599d2e0fdc7f16c346936f0ece (From this screenshot in Amplify Shader Editor, vertexBitangent is set, and then used in the "line" below it.)

495ca19baf09442980ed779d7af661bb (Here's a screenshot from Unigine's shader editor, which does support portals.)

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

N/A

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

N/A

SubtleMetaphor avatar Sep 25 '23 15:09 SubtleMetaphor