Visual shader editor vs making them by hand / code

Godot Version

4.3

Question

This is more a theoretical question: I learn and work a lot with shaders lately and while searching for good examples I found out that people quite often use code to create shaders instead of using the visual shader editor.

The question is: Why is that? I’m coming from Unity and find it way more ergonomic to do them in the visual editor. I even started to 1:1 re-create the code-shaders from tutorials in visual shaders and it works like a charm.

  • Are visual shaders relatively new? I just recently started Godot with 4.3
  • Are there performance downsides with the visual shader editor? I noticed it creates lots of boilerplate when checking the created code

The reason why I think visual shader editor is superior to coding them yourself

  • Preview in the shader editor shows you intermediate states of your shader until you reach “output”
  • I don’t have to learn yet another syntax (though, this is from a gdscript beginner perspective and after a while, I would have room in my head again to learn yet another thing)
  • Assumption: the visual editor is less error prone than scripting them yourself since you cannot create syntax errors. You can only connect what is connectable, you can only create what exists within the shader language

I’m curious about your thoughts! I bet there are things I cannot yet see and I should also mention I only do 2d shader stuff so maybe in 3d, shaders are a whole different story

A lot of shader writing is math, writing math formulas is easier expressed in text for many. I find decomposing vectors clunky in visual editors compared to albedo.rb = vec2(1.0).

It’s also much easier to share, just copy and paste. So if you are seeing a lot of people writing code it’s because it’s easier showing writing code.


Visual shader’s generate code, the generated code is usually worse than hand-crafted. Always profile your game!

I think I know what you are talking about, and it’s a nice feature. One could emulate a similar thing by assigning intermediate steps to the end result just to check, but it’s clunky

I would argue the visual shading is another syntax, just graphical.

Could be more error prone, the connections do automatic conversions that may not be what the programmer wanted, like from vec4 to floats. You can’t make syntax errors in GLSL either, the program won’t run haha.

1 Like

You got me with “easy to share”! Your Argumentation makes sense and I’ll try coding them for a while instead of using the GUI :slightly_smiling_face:

Let’s see how it feels