File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
tutorials/shaders/shader_reference Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -637,13 +637,23 @@ Example below:
637637 result = a + b;
638638 }
639639
640- .. note ::
640+ Function overloading is supported. You can define multiple functions with the same
641+ name, but different arguments. Note that `implicit casting <Casting _>`_ in overloaded
642+ function calls is not allowed, such as from ``int `` to ``float `` (``1 `` to ``1.0 ``).
643+
644+ .. code-block :: glsl
645+
646+ vec3 get_color(int t) {
647+ return vec3(1, 0, 0); // Red color.
648+ }
649+ vec3 get_color(float t) {
650+ return vec3(0, 1, 0); // Green color.
651+ }
652+ void fragment() {
653+ vec3 red = get_color(1);
654+ vec3 green = get_color(1.0);
655+ }
641656
642- Unlike GLSL, Godot's shader language does **not ** support function
643- overloading. This means that a function cannot be defined several times with
644- different argument types or numbers of arguments. As a workaround, use
645- different names for functions that accept a different number of arguments or
646- arguments of different types.
647657
648658 Varyings
649659--------
You can’t perform that action at this time.
0 commit comments