How to create a custom shader node for visual shaders?

Godot Version 4.3

I am trying to create a custom shader node to use in a visual shader. I’ve read the documentation and to my understanding I’ve done the required steps. For reference, here is how my code begins:

@tool
extends VisualShaderNodeCustom
class_name ColorToAlpha

The documentation implies that a script with @tool and a registered class_name would appear under “Addons” in the visual shader editor (Right clicking shows a dialogue box which should have an Addon dropdown). I assume my issue is something to do with registering a class name but i do not know what that means exactly. I added the class_name to the beginning of my script, but is there something I have to do in project settings for it to appear? I’ve tried restarting my project and the node still does not appear.

The shader node I’m trying to make is supposed to take a Texture2D and Color input. The shader then looks for the inputted color in the texture, and replaces that pixel with alpha 0.0 making is fully transparent. Then it should output the new texture with updated transparency. I wrote some code for it but can’t test if it works cause the node won’t show up when adding a new node.

https://docs.godotengine.org/en/stable/tutorials/plugins/editor/visual_shader_plugins.html

Any help is appreciated, thanks.

1 Like

Maybe you forgot to implement some mandatory functions in the code? Check out my tutorial.

1 Like