1/**************************************************************************/
2/* visual_shader_nodes.h */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#ifndef VISUAL_SHADER_NODES_H
32#define VISUAL_SHADER_NODES_H
33
34#include "scene/resources/curve_texture.h"
35#include "scene/resources/visual_shader.h"
36
37class Cubemap;
38class Texture2DArray;
39
40///////////////////////////////////////
41/// Vector Base Node
42///////////////////////////////////////
43
44class VisualShaderNodeVectorBase : public VisualShaderNode {
45 GDCLASS(VisualShaderNodeVectorBase, VisualShaderNode);
46
47public:
48 enum OpType {
49 OP_TYPE_VECTOR_2D,
50 OP_TYPE_VECTOR_3D,
51 OP_TYPE_VECTOR_4D,
52 OP_TYPE_MAX,
53 };
54
55protected:
56 OpType op_type = OP_TYPE_VECTOR_3D;
57
58protected:
59 static void _bind_methods();
60
61public:
62 virtual String get_caption() const override = 0;
63
64 virtual int get_input_port_count() const override = 0;
65 virtual PortType get_input_port_type(int p_port) const override;
66 virtual String get_input_port_name(int p_port) const override = 0;
67
68 virtual int get_output_port_count() const override = 0;
69 virtual PortType get_output_port_type(int p_port) const override;
70 virtual String get_output_port_name(int p_port) const override = 0;
71
72 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override = 0;
73
74 virtual void set_op_type(OpType p_op_type);
75 OpType get_op_type() const;
76
77 virtual Vector<StringName> get_editable_properties() const override;
78
79 VisualShaderNodeVectorBase();
80};
81
82VARIANT_ENUM_CAST(VisualShaderNodeVectorBase::OpType)
83
84///////////////////////////////////////
85/// CONSTANTS
86///////////////////////////////////////
87
88class VisualShaderNodeConstant : public VisualShaderNode {
89 GDCLASS(VisualShaderNodeConstant, VisualShaderNode);
90
91public:
92 virtual String get_caption() const override = 0;
93
94 virtual int get_input_port_count() const override = 0;
95 virtual PortType get_input_port_type(int p_port) const override = 0;
96 virtual String get_input_port_name(int p_port) const override = 0;
97
98 virtual int get_output_port_count() const override = 0;
99 virtual PortType get_output_port_type(int p_port) const override = 0;
100 virtual String get_output_port_name(int p_port) const override = 0;
101
102 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override = 0;
103
104 VisualShaderNodeConstant();
105};
106
107class VisualShaderNodeFloatConstant : public VisualShaderNodeConstant {
108 GDCLASS(VisualShaderNodeFloatConstant, VisualShaderNodeConstant);
109 float constant = 0.0f;
110
111protected:
112 static void _bind_methods();
113
114public:
115 virtual String get_caption() const override;
116
117 virtual int get_input_port_count() const override;
118 virtual PortType get_input_port_type(int p_port) const override;
119 virtual String get_input_port_name(int p_port) const override;
120
121 virtual int get_output_port_count() const override;
122 virtual PortType get_output_port_type(int p_port) const override;
123 virtual String get_output_port_name(int p_port) const override;
124
125 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
126
127 void set_constant(float p_constant);
128 float get_constant() const;
129
130 virtual Vector<StringName> get_editable_properties() const override;
131
132 VisualShaderNodeFloatConstant();
133};
134
135///////////////////////////////////////
136
137class VisualShaderNodeIntConstant : public VisualShaderNodeConstant {
138 GDCLASS(VisualShaderNodeIntConstant, VisualShaderNodeConstant);
139 int constant = 0;
140
141protected:
142 static void _bind_methods();
143
144public:
145 virtual String get_caption() const override;
146
147 virtual int get_input_port_count() const override;
148 virtual PortType get_input_port_type(int p_port) const override;
149 virtual String get_input_port_name(int p_port) const override;
150
151 virtual int get_output_port_count() const override;
152 virtual PortType get_output_port_type(int p_port) const override;
153 virtual String get_output_port_name(int p_port) const override;
154
155 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
156
157 void set_constant(int p_constant);
158 int get_constant() const;
159
160 virtual Vector<StringName> get_editable_properties() const override;
161
162 VisualShaderNodeIntConstant();
163};
164
165///////////////////////////////////////
166
167class VisualShaderNodeUIntConstant : public VisualShaderNodeConstant {
168 GDCLASS(VisualShaderNodeUIntConstant, VisualShaderNodeConstant);
169 int constant = 0;
170
171protected:
172 static void _bind_methods();
173
174public:
175 virtual String get_caption() const override;
176
177 virtual int get_input_port_count() const override;
178 virtual PortType get_input_port_type(int p_port) const override;
179 virtual String get_input_port_name(int p_port) const override;
180
181 virtual int get_output_port_count() const override;
182 virtual PortType get_output_port_type(int p_port) const override;
183 virtual String get_output_port_name(int p_port) const override;
184
185 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
186
187 void set_constant(int p_constant);
188 int get_constant() const;
189
190 virtual Vector<StringName> get_editable_properties() const override;
191
192 VisualShaderNodeUIntConstant();
193};
194
195///////////////////////////////////////
196
197class VisualShaderNodeBooleanConstant : public VisualShaderNodeConstant {
198 GDCLASS(VisualShaderNodeBooleanConstant, VisualShaderNodeConstant);
199 bool constant = false;
200
201protected:
202 static void _bind_methods();
203
204public:
205 virtual String get_caption() const override;
206
207 virtual int get_input_port_count() const override;
208 virtual PortType get_input_port_type(int p_port) const override;
209 virtual String get_input_port_name(int p_port) const override;
210
211 virtual int get_output_port_count() const override;
212 virtual PortType get_output_port_type(int p_port) const override;
213 virtual String get_output_port_name(int p_port) const override;
214
215 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
216
217 void set_constant(bool p_constant);
218 bool get_constant() const;
219
220 virtual Vector<StringName> get_editable_properties() const override;
221
222 VisualShaderNodeBooleanConstant();
223};
224
225///////////////////////////////////////
226
227class VisualShaderNodeColorConstant : public VisualShaderNodeConstant {
228 GDCLASS(VisualShaderNodeColorConstant, VisualShaderNodeConstant);
229 Color constant = Color(1, 1, 1, 1);
230
231protected:
232 static void _bind_methods();
233
234public:
235 virtual String get_caption() const override;
236
237 virtual int get_input_port_count() const override;
238 virtual PortType get_input_port_type(int p_port) const override;
239 virtual String get_input_port_name(int p_port) const override;
240
241 virtual int get_output_port_count() const override;
242 virtual PortType get_output_port_type(int p_port) const override;
243 virtual String get_output_port_name(int p_port) const override;
244 virtual bool is_output_port_expandable(int p_port) const override;
245
246 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
247
248 void set_constant(const Color &p_constant);
249 Color get_constant() const;
250
251 virtual Vector<StringName> get_editable_properties() const override;
252
253 VisualShaderNodeColorConstant();
254};
255
256///////////////////////////////////////
257
258class VisualShaderNodeVec2Constant : public VisualShaderNodeConstant {
259 GDCLASS(VisualShaderNodeVec2Constant, VisualShaderNodeConstant);
260 Vector2 constant;
261
262protected:
263 static void _bind_methods();
264
265public:
266 virtual String get_caption() const override;
267
268 virtual int get_input_port_count() const override;
269 virtual PortType get_input_port_type(int p_port) const override;
270 virtual String get_input_port_name(int p_port) const override;
271
272 virtual int get_output_port_count() const override;
273 virtual PortType get_output_port_type(int p_port) const override;
274 virtual String get_output_port_name(int p_port) const override;
275
276 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
277
278 void set_constant(const Vector2 &p_constant);
279 Vector2 get_constant() const;
280
281 virtual Vector<StringName> get_editable_properties() const override;
282
283 VisualShaderNodeVec2Constant();
284};
285
286///////////////////////////////////////
287
288class VisualShaderNodeVec3Constant : public VisualShaderNodeConstant {
289 GDCLASS(VisualShaderNodeVec3Constant, VisualShaderNodeConstant);
290 Vector3 constant;
291
292protected:
293 static void _bind_methods();
294
295public:
296 virtual String get_caption() const override;
297
298 virtual int get_input_port_count() const override;
299 virtual PortType get_input_port_type(int p_port) const override;
300 virtual String get_input_port_name(int p_port) const override;
301
302 virtual int get_output_port_count() const override;
303 virtual PortType get_output_port_type(int p_port) const override;
304 virtual String get_output_port_name(int p_port) const override;
305
306 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
307
308 void set_constant(const Vector3 &p_constant);
309 Vector3 get_constant() const;
310
311 virtual Vector<StringName> get_editable_properties() const override;
312
313 VisualShaderNodeVec3Constant();
314};
315
316///////////////////////////////////////
317
318class VisualShaderNodeVec4Constant : public VisualShaderNodeConstant {
319 GDCLASS(VisualShaderNodeVec4Constant, VisualShaderNodeConstant);
320 Quaternion constant;
321
322protected:
323 static void _bind_methods();
324
325public:
326 virtual String get_caption() const override;
327
328 virtual int get_input_port_count() const override;
329 virtual PortType get_input_port_type(int p_port) const override;
330 virtual String get_input_port_name(int p_port) const override;
331
332 virtual int get_output_port_count() const override;
333 virtual PortType get_output_port_type(int p_port) const override;
334 virtual String get_output_port_name(int p_port) const override;
335
336 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
337
338 void set_constant(const Quaternion &p_constant);
339 Quaternion get_constant() const;
340
341 virtual Vector<StringName> get_editable_properties() const override;
342
343 VisualShaderNodeVec4Constant();
344};
345
346///////////////////////////////////////
347
348class VisualShaderNodeTransformConstant : public VisualShaderNodeConstant {
349 GDCLASS(VisualShaderNodeTransformConstant, VisualShaderNodeConstant);
350 Transform3D constant;
351
352protected:
353 static void _bind_methods();
354
355public:
356 virtual String get_caption() const override;
357
358 virtual int get_input_port_count() const override;
359 virtual PortType get_input_port_type(int p_port) const override;
360 virtual String get_input_port_name(int p_port) const override;
361
362 virtual int get_output_port_count() const override;
363 virtual PortType get_output_port_type(int p_port) const override;
364 virtual String get_output_port_name(int p_port) const override;
365
366 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
367
368 void set_constant(const Transform3D &p_constant);
369 Transform3D get_constant() const;
370
371 virtual Vector<StringName> get_editable_properties() const override;
372
373 VisualShaderNodeTransformConstant();
374};
375
376///////////////////////////////////////
377/// TEXTURES
378///////////////////////////////////////
379
380class VisualShaderNodeTexture : public VisualShaderNode {
381 GDCLASS(VisualShaderNodeTexture, VisualShaderNode);
382 Ref<Texture2D> texture;
383
384public:
385 enum Source {
386 SOURCE_TEXTURE,
387 SOURCE_SCREEN,
388 SOURCE_2D_TEXTURE,
389 SOURCE_2D_NORMAL,
390 SOURCE_DEPTH,
391 SOURCE_PORT,
392 SOURCE_3D_NORMAL,
393 SOURCE_ROUGHNESS,
394 SOURCE_MAX,
395 };
396
397 enum TextureType {
398 TYPE_DATA,
399 TYPE_COLOR,
400 TYPE_NORMAL_MAP,
401 TYPE_MAX,
402 };
403
404private:
405 Source source = SOURCE_TEXTURE;
406 TextureType texture_type = TYPE_DATA;
407
408protected:
409 static void _bind_methods();
410
411public:
412 virtual String get_caption() const override;
413
414 virtual int get_input_port_count() const override;
415 virtual PortType get_input_port_type(int p_port) const override;
416 virtual String get_input_port_name(int p_port) const override;
417
418 virtual int get_output_port_count() const override;
419 virtual PortType get_output_port_type(int p_port) const override;
420 virtual String get_output_port_name(int p_port) const override;
421 virtual bool is_output_port_expandable(int p_port) const override;
422
423 virtual bool is_input_port_default(int p_port, Shader::Mode p_mode) const override;
424
425 virtual Vector<VisualShader::DefaultTextureParam> get_default_texture_parameters(VisualShader::Type p_type, int p_id) const override;
426 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
427 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
428
429 void set_source(Source p_source);
430 Source get_source() const;
431
432 void set_texture(Ref<Texture2D> p_texture);
433 Ref<Texture2D> get_texture() const;
434
435 void set_texture_type(TextureType p_texture_type);
436 TextureType get_texture_type() const;
437
438 virtual Vector<StringName> get_editable_properties() const override;
439
440 virtual String get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const override;
441
442 VisualShaderNodeTexture();
443};
444
445VARIANT_ENUM_CAST(VisualShaderNodeTexture::TextureType)
446VARIANT_ENUM_CAST(VisualShaderNodeTexture::Source)
447
448///////////////////////////////////////
449
450class VisualShaderNodeCurveTexture : public VisualShaderNodeResizableBase {
451 GDCLASS(VisualShaderNodeCurveTexture, VisualShaderNodeResizableBase);
452 Ref<CurveTexture> texture;
453
454protected:
455 static void _bind_methods();
456
457public:
458 virtual String get_caption() const override;
459
460 virtual int get_input_port_count() const override;
461 virtual PortType get_input_port_type(int p_port) const override;
462 virtual String get_input_port_name(int p_port) const override;
463
464 virtual int get_output_port_count() const override;
465 virtual PortType get_output_port_type(int p_port) const override;
466 virtual String get_output_port_name(int p_port) const override;
467
468 virtual Vector<VisualShader::DefaultTextureParam> get_default_texture_parameters(VisualShader::Type p_type, int p_id) const override;
469 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
470 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
471
472 void set_texture(Ref<CurveTexture> p_texture);
473 Ref<CurveTexture> get_texture() const;
474
475 virtual Vector<StringName> get_editable_properties() const override;
476 virtual bool is_use_prop_slots() const override;
477
478 VisualShaderNodeCurveTexture();
479};
480
481///////////////////////////////////////
482
483class VisualShaderNodeCurveXYZTexture : public VisualShaderNodeResizableBase {
484 GDCLASS(VisualShaderNodeCurveXYZTexture, VisualShaderNodeResizableBase);
485 Ref<CurveXYZTexture> texture;
486
487protected:
488 static void _bind_methods();
489
490public:
491 virtual String get_caption() const override;
492
493 virtual int get_input_port_count() const override;
494 virtual PortType get_input_port_type(int p_port) const override;
495 virtual String get_input_port_name(int p_port) const override;
496
497 virtual int get_output_port_count() const override;
498 virtual PortType get_output_port_type(int p_port) const override;
499 virtual String get_output_port_name(int p_port) const override;
500
501 virtual Vector<VisualShader::DefaultTextureParam> get_default_texture_parameters(VisualShader::Type p_type, int p_id) const override;
502 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
503 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
504
505 void set_texture(Ref<CurveXYZTexture> p_texture);
506 Ref<CurveXYZTexture> get_texture() const;
507
508 virtual Vector<StringName> get_editable_properties() const override;
509 virtual bool is_use_prop_slots() const override;
510
511 VisualShaderNodeCurveXYZTexture();
512};
513
514///////////////////////////////////////
515
516class VisualShaderNodeSample3D : public VisualShaderNode {
517 GDCLASS(VisualShaderNodeSample3D, VisualShaderNode);
518
519public:
520 enum Source {
521 SOURCE_TEXTURE,
522 SOURCE_PORT,
523 SOURCE_MAX,
524 };
525
526protected:
527 Source source = SOURCE_TEXTURE;
528
529 static void _bind_methods();
530
531public:
532 virtual int get_input_port_count() const override;
533 virtual PortType get_input_port_type(int p_port) const override;
534 virtual String get_input_port_name(int p_port) const override;
535 virtual bool is_input_port_default(int p_port, Shader::Mode p_mode) const override;
536
537 virtual int get_output_port_count() const override;
538 virtual PortType get_output_port_type(int p_port) const override;
539 virtual String get_output_port_name(int p_port) const override;
540 virtual bool is_output_port_expandable(int p_port) const override;
541
542 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
543
544 void set_source(Source p_source);
545 Source get_source() const;
546
547 virtual String get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const override;
548
549 VisualShaderNodeSample3D();
550};
551
552VARIANT_ENUM_CAST(VisualShaderNodeSample3D::Source)
553
554class VisualShaderNodeTexture2DArray : public VisualShaderNodeSample3D {
555 GDCLASS(VisualShaderNodeTexture2DArray, VisualShaderNodeSample3D);
556 Ref<Texture2DArray> texture_array;
557
558protected:
559 static void _bind_methods();
560
561public:
562 virtual String get_caption() const override;
563
564 virtual String get_input_port_name(int p_port) const override;
565
566 virtual Vector<VisualShader::DefaultTextureParam> get_default_texture_parameters(VisualShader::Type p_type, int p_id) const override;
567 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
568
569 void set_texture_array(Ref<Texture2DArray> p_texture_array);
570 Ref<Texture2DArray> get_texture_array() const;
571
572 virtual Vector<StringName> get_editable_properties() const override;
573
574 VisualShaderNodeTexture2DArray();
575};
576
577class VisualShaderNodeTexture3D : public VisualShaderNodeSample3D {
578 GDCLASS(VisualShaderNodeTexture3D, VisualShaderNodeSample3D);
579 Ref<Texture3D> texture;
580
581protected:
582 static void _bind_methods();
583
584public:
585 virtual String get_caption() const override;
586
587 virtual String get_input_port_name(int p_port) const override;
588
589 virtual Vector<VisualShader::DefaultTextureParam> get_default_texture_parameters(VisualShader::Type p_type, int p_id) const override;
590 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
591
592 void set_texture(Ref<Texture3D> p_texture);
593 Ref<Texture3D> get_texture() const;
594
595 virtual Vector<StringName> get_editable_properties() const override;
596
597 VisualShaderNodeTexture3D();
598};
599
600class VisualShaderNodeCubemap : public VisualShaderNode {
601 GDCLASS(VisualShaderNodeCubemap, VisualShaderNode);
602 Ref<Cubemap> cube_map;
603
604public:
605 enum Source {
606 SOURCE_TEXTURE,
607 SOURCE_PORT,
608 SOURCE_MAX,
609 };
610
611 enum TextureType {
612 TYPE_DATA,
613 TYPE_COLOR,
614 TYPE_NORMAL_MAP,
615 TYPE_MAX,
616 };
617
618private:
619 Source source = SOURCE_TEXTURE;
620 TextureType texture_type = TYPE_DATA;
621
622protected:
623 static void _bind_methods();
624
625public:
626 virtual String get_caption() const override;
627
628 virtual int get_input_port_count() const override;
629 virtual PortType get_input_port_type(int p_port) const override;
630 virtual String get_input_port_name(int p_port) const override;
631 virtual bool is_input_port_default(int p_port, Shader::Mode p_mode) const override;
632
633 virtual int get_output_port_count() const override;
634 virtual PortType get_output_port_type(int p_port) const override;
635 virtual String get_output_port_name(int p_port) const override;
636 virtual bool is_output_port_expandable(int p_port) const override;
637
638 virtual Vector<VisualShader::DefaultTextureParam> get_default_texture_parameters(VisualShader::Type p_type, int p_id) const override;
639 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
640 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
641
642 void set_source(Source p_source);
643 Source get_source() const;
644
645 void set_cube_map(Ref<Cubemap> p_cube_map);
646 Ref<Cubemap> get_cube_map() const;
647
648 void set_texture_type(TextureType p_texture_type);
649 TextureType get_texture_type() const;
650
651 virtual Vector<StringName> get_editable_properties() const override;
652 virtual String get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const override;
653
654 VisualShaderNodeCubemap();
655};
656
657VARIANT_ENUM_CAST(VisualShaderNodeCubemap::TextureType)
658VARIANT_ENUM_CAST(VisualShaderNodeCubemap::Source)
659
660///////////////////////////////////////
661
662class VisualShaderNodeLinearSceneDepth : public VisualShaderNode {
663 GDCLASS(VisualShaderNodeLinearSceneDepth, VisualShaderNode);
664
665public:
666 virtual String get_caption() const override;
667
668 virtual int get_input_port_count() const override;
669 virtual PortType get_input_port_type(int p_port) const override;
670 virtual String get_input_port_name(int p_port) const override;
671
672 virtual int get_output_port_count() const override;
673 virtual PortType get_output_port_type(int p_port) const override;
674 virtual String get_output_port_name(int p_port) const override;
675 virtual bool has_output_port_preview(int p_port) const override;
676
677 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
678 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
679
680 VisualShaderNodeLinearSceneDepth();
681};
682
683class VisualShaderNodeWorldPositionFromDepth : public VisualShaderNode {
684 GDCLASS(VisualShaderNodeWorldPositionFromDepth, VisualShaderNode);
685
686public:
687 virtual String get_caption() const override;
688
689 virtual int get_input_port_count() const override;
690 virtual PortType get_input_port_type(int p_port) const override;
691 virtual String get_input_port_name(int p_port) const override;
692 virtual bool is_input_port_default(int p_port, Shader::Mode p_mode) const override;
693
694 virtual int get_output_port_count() const override;
695 virtual PortType get_output_port_type(int p_port) const override;
696 virtual String get_output_port_name(int p_port) const override;
697 virtual bool has_output_port_preview(int p_port) const override;
698
699 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
700 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
701
702 VisualShaderNodeWorldPositionFromDepth();
703};
704
705class VisualShaderNodeScreenNormalWorldSpace : public VisualShaderNode {
706 GDCLASS(VisualShaderNodeScreenNormalWorldSpace, VisualShaderNode);
707
708public:
709 virtual String get_caption() const override;
710
711 virtual int get_input_port_count() const override;
712 virtual PortType get_input_port_type(int p_port) const override;
713 virtual String get_input_port_name(int p_port) const override;
714 virtual bool is_input_port_default(int p_port, Shader::Mode p_mode) const override;
715
716 virtual int get_output_port_count() const override;
717 virtual PortType get_output_port_type(int p_port) const override;
718 virtual String get_output_port_name(int p_port) const override;
719 virtual bool has_output_port_preview(int p_port) const override;
720
721 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
722 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
723
724 VisualShaderNodeScreenNormalWorldSpace();
725};
726
727///////////////////////////////////////
728/// OPS
729///////////////////////////////////////
730
731class VisualShaderNodeFloatOp : public VisualShaderNode {
732 GDCLASS(VisualShaderNodeFloatOp, VisualShaderNode);
733
734public:
735 enum Operator {
736 OP_ADD,
737 OP_SUB,
738 OP_MUL,
739 OP_DIV,
740 OP_MOD,
741 OP_POW,
742 OP_MAX,
743 OP_MIN,
744 OP_ATAN2,
745 OP_STEP,
746 OP_ENUM_SIZE,
747 };
748
749protected:
750 Operator op = OP_ADD;
751
752 static void _bind_methods();
753
754public:
755 virtual String get_caption() const override;
756
757 virtual int get_input_port_count() const override;
758 virtual PortType get_input_port_type(int p_port) const override;
759 virtual String get_input_port_name(int p_port) const override;
760
761 virtual int get_output_port_count() const override;
762 virtual PortType get_output_port_type(int p_port) const override;
763 virtual String get_output_port_name(int p_port) const override;
764
765 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
766
767 void set_operator(Operator p_op);
768 Operator get_operator() const;
769
770 virtual Vector<StringName> get_editable_properties() const override;
771
772 VisualShaderNodeFloatOp();
773};
774
775VARIANT_ENUM_CAST(VisualShaderNodeFloatOp::Operator)
776
777class VisualShaderNodeIntOp : public VisualShaderNode {
778 GDCLASS(VisualShaderNodeIntOp, VisualShaderNode);
779
780public:
781 enum Operator {
782 OP_ADD,
783 OP_SUB,
784 OP_MUL,
785 OP_DIV,
786 OP_MOD,
787 OP_MAX,
788 OP_MIN,
789 OP_BITWISE_AND,
790 OP_BITWISE_OR,
791 OP_BITWISE_XOR,
792 OP_BITWISE_LEFT_SHIFT,
793 OP_BITWISE_RIGHT_SHIFT,
794 OP_ENUM_SIZE,
795 };
796
797protected:
798 Operator op = OP_ADD;
799
800 static void _bind_methods();
801
802public:
803 virtual String get_caption() const override;
804
805 virtual int get_input_port_count() const override;
806 virtual PortType get_input_port_type(int p_port) const override;
807 virtual String get_input_port_name(int p_port) const override;
808
809 virtual int get_output_port_count() const override;
810 virtual PortType get_output_port_type(int p_port) const override;
811 virtual String get_output_port_name(int p_port) const override;
812
813 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
814
815 void set_operator(Operator p_op);
816 Operator get_operator() const;
817
818 virtual Vector<StringName> get_editable_properties() const override;
819
820 VisualShaderNodeIntOp();
821};
822
823VARIANT_ENUM_CAST(VisualShaderNodeIntOp::Operator)
824
825class VisualShaderNodeUIntOp : public VisualShaderNode {
826 GDCLASS(VisualShaderNodeUIntOp, VisualShaderNode);
827
828public:
829 enum Operator {
830 OP_ADD,
831 OP_SUB,
832 OP_MUL,
833 OP_DIV,
834 OP_MOD,
835 OP_MAX,
836 OP_MIN,
837 OP_BITWISE_AND,
838 OP_BITWISE_OR,
839 OP_BITWISE_XOR,
840 OP_BITWISE_LEFT_SHIFT,
841 OP_BITWISE_RIGHT_SHIFT,
842 OP_ENUM_SIZE,
843 };
844
845protected:
846 Operator op = OP_ADD;
847
848 static void _bind_methods();
849
850public:
851 virtual String get_caption() const override;
852
853 virtual int get_input_port_count() const override;
854 virtual PortType get_input_port_type(int p_port) const override;
855 virtual String get_input_port_name(int p_port) const override;
856
857 virtual int get_output_port_count() const override;
858 virtual PortType get_output_port_type(int p_port) const override;
859 virtual String get_output_port_name(int p_port) const override;
860
861 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
862
863 void set_operator(Operator p_op);
864 Operator get_operator() const;
865
866 virtual Vector<StringName> get_editable_properties() const override;
867
868 VisualShaderNodeUIntOp();
869};
870
871VARIANT_ENUM_CAST(VisualShaderNodeUIntOp::Operator)
872
873class VisualShaderNodeVectorOp : public VisualShaderNodeVectorBase {
874 GDCLASS(VisualShaderNodeVectorOp, VisualShaderNodeVectorBase);
875
876public:
877 enum Operator {
878 OP_ADD,
879 OP_SUB,
880 OP_MUL,
881 OP_DIV,
882 OP_MOD,
883 OP_POW,
884 OP_MAX,
885 OP_MIN,
886 OP_CROSS,
887 OP_ATAN2,
888 OP_REFLECT,
889 OP_STEP,
890 OP_ENUM_SIZE,
891 };
892
893protected:
894 Operator op = OP_ADD;
895
896 static void _bind_methods();
897
898public:
899 virtual String get_caption() const override;
900
901 virtual int get_input_port_count() const override;
902 virtual String get_input_port_name(int p_port) const override;
903
904 virtual int get_output_port_count() const override;
905 virtual String get_output_port_name(int p_port) const override;
906
907 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
908
909 virtual void set_op_type(OpType p_op_type) override;
910
911 void set_operator(Operator p_op);
912 Operator get_operator() const;
913
914 virtual Vector<StringName> get_editable_properties() const override;
915 String get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const override;
916
917 VisualShaderNodeVectorOp();
918};
919
920VARIANT_ENUM_CAST(VisualShaderNodeVectorOp::Operator)
921
922///////////////////////////////////////
923
924class VisualShaderNodeColorOp : public VisualShaderNode {
925 GDCLASS(VisualShaderNodeColorOp, VisualShaderNode);
926
927public:
928 enum Operator {
929 OP_SCREEN,
930 OP_DIFFERENCE,
931 OP_DARKEN,
932 OP_LIGHTEN,
933 OP_OVERLAY,
934 OP_DODGE,
935 OP_BURN,
936 OP_SOFT_LIGHT,
937 OP_HARD_LIGHT,
938 OP_MAX,
939 };
940
941protected:
942 Operator op = OP_SCREEN;
943
944 static void _bind_methods();
945
946public:
947 virtual String get_caption() const override;
948
949 virtual int get_input_port_count() const override;
950 virtual PortType get_input_port_type(int p_port) const override;
951 virtual String get_input_port_name(int p_port) const override;
952
953 virtual int get_output_port_count() const override;
954 virtual PortType get_output_port_type(int p_port) const override;
955 virtual String get_output_port_name(int p_port) const override;
956
957 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
958
959 void set_operator(Operator p_op);
960 Operator get_operator() const;
961
962 virtual Vector<StringName> get_editable_properties() const override;
963
964 VisualShaderNodeColorOp();
965};
966
967VARIANT_ENUM_CAST(VisualShaderNodeColorOp::Operator)
968
969////////////////////////////////
970/// TRANSFORM-TRANSFORM OPERATOR
971////////////////////////////////
972
973class VisualShaderNodeTransformOp : public VisualShaderNode {
974 GDCLASS(VisualShaderNodeTransformOp, VisualShaderNode);
975
976public:
977 enum Operator {
978 OP_AxB,
979 OP_BxA,
980 OP_AxB_COMP,
981 OP_BxA_COMP,
982 OP_ADD,
983 OP_A_MINUS_B,
984 OP_B_MINUS_A,
985 OP_A_DIV_B,
986 OP_B_DIV_A,
987 OP_MAX,
988 };
989
990protected:
991 Operator op = OP_AxB;
992
993 static void _bind_methods();
994
995public:
996 virtual String get_caption() const override;
997
998 virtual int get_input_port_count() const override;
999 virtual PortType get_input_port_type(int p_port) const override;
1000 virtual String get_input_port_name(int p_port) const override;
1001
1002 virtual int get_output_port_count() const override;
1003 virtual PortType get_output_port_type(int p_port) const override;
1004 virtual String get_output_port_name(int p_port) const override;
1005
1006 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1007
1008 void set_operator(Operator p_op);
1009 Operator get_operator() const;
1010
1011 virtual Vector<StringName> get_editable_properties() const override;
1012
1013 VisualShaderNodeTransformOp();
1014};
1015
1016VARIANT_ENUM_CAST(VisualShaderNodeTransformOp::Operator)
1017
1018///////////////////////////////////////
1019/// TRANSFORM-VECTOR MULTIPLICATION
1020///////////////////////////////////////
1021
1022class VisualShaderNodeTransformVecMult : public VisualShaderNode {
1023 GDCLASS(VisualShaderNodeTransformVecMult, VisualShaderNode);
1024
1025public:
1026 enum Operator {
1027 OP_AxB,
1028 OP_BxA,
1029 OP_3x3_AxB,
1030 OP_3x3_BxA,
1031 OP_MAX,
1032 };
1033
1034protected:
1035 Operator op = OP_AxB;
1036
1037 static void _bind_methods();
1038
1039public:
1040 virtual String get_caption() const override;
1041
1042 virtual int get_input_port_count() const override;
1043 virtual PortType get_input_port_type(int p_port) const override;
1044 virtual String get_input_port_name(int p_port) const override;
1045
1046 virtual int get_output_port_count() const override;
1047 virtual PortType get_output_port_type(int p_port) const override;
1048 virtual String get_output_port_name(int p_port) const override;
1049
1050 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1051
1052 void set_operator(Operator p_op);
1053 Operator get_operator() const;
1054
1055 virtual Vector<StringName> get_editable_properties() const override;
1056
1057 VisualShaderNodeTransformVecMult();
1058};
1059
1060VARIANT_ENUM_CAST(VisualShaderNodeTransformVecMult::Operator)
1061
1062///////////////////////////////////////
1063/// FLOAT FUNC
1064///////////////////////////////////////
1065
1066class VisualShaderNodeFloatFunc : public VisualShaderNode {
1067 GDCLASS(VisualShaderNodeFloatFunc, VisualShaderNode);
1068
1069public:
1070 enum Function {
1071 FUNC_SIN,
1072 FUNC_COS,
1073 FUNC_TAN,
1074 FUNC_ASIN,
1075 FUNC_ACOS,
1076 FUNC_ATAN,
1077 FUNC_SINH,
1078 FUNC_COSH,
1079 FUNC_TANH,
1080 FUNC_LOG,
1081 FUNC_EXP,
1082 FUNC_SQRT,
1083 FUNC_ABS,
1084 FUNC_SIGN,
1085 FUNC_FLOOR,
1086 FUNC_ROUND,
1087 FUNC_CEIL,
1088 FUNC_FRACT,
1089 FUNC_SATURATE,
1090 FUNC_NEGATE,
1091 FUNC_ACOSH,
1092 FUNC_ASINH,
1093 FUNC_ATANH,
1094 FUNC_DEGREES,
1095 FUNC_EXP2,
1096 FUNC_INVERSE_SQRT,
1097 FUNC_LOG2,
1098 FUNC_RADIANS,
1099 FUNC_RECIPROCAL,
1100 FUNC_ROUNDEVEN,
1101 FUNC_TRUNC,
1102 FUNC_ONEMINUS,
1103 FUNC_MAX,
1104 };
1105
1106protected:
1107 Function func = FUNC_SIGN;
1108
1109 static void _bind_methods();
1110
1111public:
1112 virtual String get_caption() const override;
1113
1114 virtual int get_input_port_count() const override;
1115 virtual PortType get_input_port_type(int p_port) const override;
1116 virtual String get_input_port_name(int p_port) const override;
1117
1118 virtual int get_output_port_count() const override;
1119 virtual PortType get_output_port_type(int p_port) const override;
1120 virtual String get_output_port_name(int p_port) const override;
1121
1122 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1123
1124 void set_function(Function p_func);
1125 Function get_function() const;
1126
1127 virtual Vector<StringName> get_editable_properties() const override;
1128
1129 VisualShaderNodeFloatFunc();
1130};
1131
1132VARIANT_ENUM_CAST(VisualShaderNodeFloatFunc::Function)
1133
1134///////////////////////////////////////
1135/// INT FUNC
1136///////////////////////////////////////
1137
1138class VisualShaderNodeIntFunc : public VisualShaderNode {
1139 GDCLASS(VisualShaderNodeIntFunc, VisualShaderNode);
1140
1141public:
1142 enum Function {
1143 FUNC_ABS,
1144 FUNC_NEGATE,
1145 FUNC_SIGN,
1146 FUNC_BITWISE_NOT,
1147 FUNC_MAX,
1148 };
1149
1150protected:
1151 Function func = FUNC_SIGN;
1152
1153 static void _bind_methods();
1154
1155public:
1156 virtual String get_caption() const override;
1157
1158 virtual int get_input_port_count() const override;
1159 virtual PortType get_input_port_type(int p_port) const override;
1160 virtual String get_input_port_name(int p_port) const override;
1161
1162 virtual int get_output_port_count() const override;
1163 virtual PortType get_output_port_type(int p_port) const override;
1164 virtual String get_output_port_name(int p_port) const override;
1165
1166 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1167
1168 void set_function(Function p_func);
1169 Function get_function() const;
1170
1171 virtual Vector<StringName> get_editable_properties() const override;
1172
1173 VisualShaderNodeIntFunc();
1174};
1175
1176VARIANT_ENUM_CAST(VisualShaderNodeIntFunc::Function)
1177
1178///////////////////////////////////////
1179/// UINT FUNC
1180///////////////////////////////////////
1181
1182class VisualShaderNodeUIntFunc : public VisualShaderNode {
1183 GDCLASS(VisualShaderNodeUIntFunc, VisualShaderNode);
1184
1185public:
1186 enum Function {
1187 FUNC_NEGATE,
1188 FUNC_BITWISE_NOT,
1189 FUNC_MAX,
1190 };
1191
1192protected:
1193 Function func = FUNC_NEGATE;
1194
1195 static void _bind_methods();
1196
1197public:
1198 virtual String get_caption() const override;
1199
1200 virtual int get_input_port_count() const override;
1201 virtual PortType get_input_port_type(int p_port) const override;
1202 virtual String get_input_port_name(int p_port) const override;
1203
1204 virtual int get_output_port_count() const override;
1205 virtual PortType get_output_port_type(int p_port) const override;
1206 virtual String get_output_port_name(int p_port) const override;
1207
1208 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1209
1210 void set_function(Function p_func);
1211 Function get_function() const;
1212
1213 virtual Vector<StringName> get_editable_properties() const override;
1214
1215 VisualShaderNodeUIntFunc();
1216};
1217
1218VARIANT_ENUM_CAST(VisualShaderNodeUIntFunc::Function)
1219
1220///////////////////////////////////////
1221/// VECTOR FUNC
1222///////////////////////////////////////
1223
1224class VisualShaderNodeVectorFunc : public VisualShaderNodeVectorBase {
1225 GDCLASS(VisualShaderNodeVectorFunc, VisualShaderNodeVectorBase);
1226
1227 void _update_default_input_values();
1228
1229public:
1230 enum Function {
1231 FUNC_NORMALIZE,
1232 FUNC_SATURATE,
1233 FUNC_NEGATE,
1234 FUNC_RECIPROCAL,
1235 FUNC_ABS,
1236 FUNC_ACOS,
1237 FUNC_ACOSH,
1238 FUNC_ASIN,
1239 FUNC_ASINH,
1240 FUNC_ATAN,
1241 FUNC_ATANH,
1242 FUNC_CEIL,
1243 FUNC_COS,
1244 FUNC_COSH,
1245 FUNC_DEGREES,
1246 FUNC_EXP,
1247 FUNC_EXP2,
1248 FUNC_FLOOR,
1249 FUNC_FRACT,
1250 FUNC_INVERSE_SQRT,
1251 FUNC_LOG,
1252 FUNC_LOG2,
1253 FUNC_RADIANS,
1254 FUNC_ROUND,
1255 FUNC_ROUNDEVEN,
1256 FUNC_SIGN,
1257 FUNC_SIN,
1258 FUNC_SINH,
1259 FUNC_SQRT,
1260 FUNC_TAN,
1261 FUNC_TANH,
1262 FUNC_TRUNC,
1263 FUNC_ONEMINUS,
1264 FUNC_MAX,
1265 };
1266
1267protected:
1268 Function func = FUNC_NORMALIZE;
1269
1270 static void _bind_methods();
1271
1272public:
1273 virtual String get_caption() const override;
1274
1275 virtual int get_input_port_count() const override;
1276 virtual String get_input_port_name(int p_port) const override;
1277
1278 virtual int get_output_port_count() const override;
1279 virtual String get_output_port_name(int p_port) const override;
1280
1281 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1282
1283 virtual void set_op_type(OpType p_op_type) override;
1284
1285 void set_function(Function p_func);
1286 Function get_function() const;
1287
1288 virtual Vector<StringName> get_editable_properties() const override;
1289
1290 VisualShaderNodeVectorFunc();
1291};
1292
1293VARIANT_ENUM_CAST(VisualShaderNodeVectorFunc::Function)
1294
1295///////////////////////////////////////
1296/// COLOR FUNC
1297///////////////////////////////////////
1298
1299class VisualShaderNodeColorFunc : public VisualShaderNode {
1300 GDCLASS(VisualShaderNodeColorFunc, VisualShaderNode);
1301
1302public:
1303 enum Function {
1304 FUNC_GRAYSCALE,
1305 FUNC_HSV2RGB,
1306 FUNC_RGB2HSV,
1307 FUNC_SEPIA,
1308 FUNC_MAX,
1309 };
1310
1311protected:
1312 Function func = FUNC_GRAYSCALE;
1313
1314 static void _bind_methods();
1315
1316public:
1317 virtual String get_caption() const override;
1318
1319 virtual int get_input_port_count() const override;
1320 virtual PortType get_input_port_type(int p_port) const override;
1321 virtual String get_input_port_name(int p_port) const override;
1322
1323 virtual int get_output_port_count() const override;
1324 virtual PortType get_output_port_type(int p_port) const override;
1325 virtual String get_output_port_name(int p_port) const override;
1326
1327 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1328
1329 void set_function(Function p_func);
1330 Function get_function() const;
1331
1332 virtual Vector<StringName> get_editable_properties() const override;
1333
1334 VisualShaderNodeColorFunc();
1335};
1336
1337VARIANT_ENUM_CAST(VisualShaderNodeColorFunc::Function)
1338
1339///////////////////////////////////////
1340/// TRANSFORM FUNC
1341///////////////////////////////////////
1342
1343class VisualShaderNodeTransformFunc : public VisualShaderNode {
1344 GDCLASS(VisualShaderNodeTransformFunc, VisualShaderNode);
1345
1346public:
1347 enum Function {
1348 FUNC_INVERSE,
1349 FUNC_TRANSPOSE,
1350 FUNC_MAX,
1351 };
1352
1353protected:
1354 Function func = FUNC_INVERSE;
1355
1356 static void _bind_methods();
1357
1358public:
1359 virtual String get_caption() const override;
1360
1361 virtual int get_input_port_count() const override;
1362 virtual PortType get_input_port_type(int p_port) const override;
1363 virtual String get_input_port_name(int p_port) const override;
1364
1365 virtual int get_output_port_count() const override;
1366 virtual PortType get_output_port_type(int p_port) const override;
1367 virtual String get_output_port_name(int p_port) const override;
1368
1369 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1370
1371 void set_function(Function p_func);
1372 Function get_function() const;
1373
1374 virtual Vector<StringName> get_editable_properties() const override;
1375
1376 VisualShaderNodeTransformFunc();
1377};
1378
1379VARIANT_ENUM_CAST(VisualShaderNodeTransformFunc::Function)
1380
1381///////////////////////////////////////
1382/// UV FUNC
1383///////////////////////////////////////
1384
1385class VisualShaderNodeUVFunc : public VisualShaderNode {
1386 GDCLASS(VisualShaderNodeUVFunc, VisualShaderNode);
1387
1388public:
1389 enum Function {
1390 FUNC_PANNING,
1391 FUNC_SCALING,
1392 FUNC_MAX,
1393 };
1394
1395protected:
1396 Function func = FUNC_PANNING;
1397
1398 static void _bind_methods();
1399
1400public:
1401 virtual String get_caption() const override;
1402
1403 virtual int get_input_port_count() const override;
1404 virtual PortType get_input_port_type(int p_port) const override;
1405 virtual String get_input_port_name(int p_port) const override;
1406 virtual bool is_input_port_default(int p_port, Shader::Mode p_mode) const override;
1407
1408 virtual int get_output_port_count() const override;
1409 virtual PortType get_output_port_type(int p_port) const override;
1410 virtual String get_output_port_name(int p_port) const override;
1411
1412 virtual bool is_show_prop_names() const override;
1413
1414 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1415
1416 void set_function(Function p_func);
1417 Function get_function() const;
1418
1419 virtual Vector<StringName> get_editable_properties() const override;
1420
1421 VisualShaderNodeUVFunc();
1422};
1423
1424VARIANT_ENUM_CAST(VisualShaderNodeUVFunc::Function)
1425
1426///////////////////////////////////////
1427/// UV POLARCOORD
1428///////////////////////////////////////
1429
1430class VisualShaderNodeUVPolarCoord : public VisualShaderNode {
1431 GDCLASS(VisualShaderNodeUVPolarCoord, VisualShaderNode);
1432
1433public:
1434 virtual String get_caption() const override;
1435
1436 virtual int get_input_port_count() const override;
1437 virtual PortType get_input_port_type(int p_port) const override;
1438 virtual String get_input_port_name(int p_port) const override;
1439 virtual bool is_input_port_default(int p_port, Shader::Mode p_mode) const override;
1440
1441 virtual int get_output_port_count() const override;
1442 virtual PortType get_output_port_type(int p_port) const override;
1443 virtual String get_output_port_name(int p_port) const override;
1444
1445 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1446
1447 VisualShaderNodeUVPolarCoord();
1448};
1449
1450///////////////////////////////////////
1451/// DOT
1452///////////////////////////////////////
1453
1454class VisualShaderNodeDotProduct : public VisualShaderNode {
1455 GDCLASS(VisualShaderNodeDotProduct, VisualShaderNode);
1456
1457public:
1458 virtual String get_caption() const override;
1459
1460 virtual int get_input_port_count() const override;
1461 virtual PortType get_input_port_type(int p_port) const override;
1462 virtual String get_input_port_name(int p_port) const override;
1463
1464 virtual int get_output_port_count() const override;
1465 virtual PortType get_output_port_type(int p_port) const override;
1466 virtual String get_output_port_name(int p_port) const override;
1467
1468 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1469
1470 VisualShaderNodeDotProduct();
1471};
1472
1473///////////////////////////////////////
1474/// LENGTH
1475///////////////////////////////////////
1476
1477class VisualShaderNodeVectorLen : public VisualShaderNodeVectorBase {
1478 GDCLASS(VisualShaderNodeVectorLen, VisualShaderNodeVectorBase);
1479
1480public:
1481 virtual String get_caption() const override;
1482
1483 virtual int get_input_port_count() const override;
1484 virtual String get_input_port_name(int p_port) const override;
1485
1486 virtual int get_output_port_count() const override;
1487 virtual PortType get_output_port_type(int p_port) const override;
1488 virtual String get_output_port_name(int p_port) const override;
1489
1490 virtual void set_op_type(OpType p_op_type) override;
1491 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1492
1493 VisualShaderNodeVectorLen();
1494};
1495
1496///////////////////////////////////////
1497/// DETERMINANT
1498///////////////////////////////////////
1499
1500class VisualShaderNodeDeterminant : public VisualShaderNode {
1501 GDCLASS(VisualShaderNodeDeterminant, VisualShaderNode);
1502
1503public:
1504 virtual String get_caption() const override;
1505
1506 virtual int get_input_port_count() const override;
1507 virtual PortType get_input_port_type(int p_port) const override;
1508 virtual String get_input_port_name(int p_port) const override;
1509
1510 virtual int get_output_port_count() const override;
1511 virtual PortType get_output_port_type(int p_port) const override;
1512 virtual String get_output_port_name(int p_port) const override;
1513
1514 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1515
1516 VisualShaderNodeDeterminant();
1517};
1518
1519///////////////////////////////////////
1520/// CLAMP
1521///////////////////////////////////////
1522
1523class VisualShaderNodeClamp : public VisualShaderNode {
1524 GDCLASS(VisualShaderNodeClamp, VisualShaderNode);
1525
1526public:
1527 enum OpType {
1528 OP_TYPE_FLOAT,
1529 OP_TYPE_INT,
1530 OP_TYPE_UINT,
1531 OP_TYPE_VECTOR_2D,
1532 OP_TYPE_VECTOR_3D,
1533 OP_TYPE_VECTOR_4D,
1534 OP_TYPE_MAX,
1535 };
1536
1537protected:
1538 OpType op_type = OP_TYPE_FLOAT;
1539 static void _bind_methods();
1540
1541public:
1542 virtual String get_caption() const override;
1543
1544 virtual int get_input_port_count() const override;
1545 virtual PortType get_input_port_type(int p_port) const override;
1546 virtual String get_input_port_name(int p_port) const override;
1547
1548 virtual int get_output_port_count() const override;
1549 virtual PortType get_output_port_type(int p_port) const override;
1550 virtual String get_output_port_name(int p_port) const override;
1551
1552 void set_op_type(OpType p_op_type);
1553 OpType get_op_type() const;
1554
1555 virtual Vector<StringName> get_editable_properties() const override;
1556
1557 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1558
1559 VisualShaderNodeClamp();
1560};
1561
1562VARIANT_ENUM_CAST(VisualShaderNodeClamp::OpType)
1563
1564///////////////////////////////////////
1565/// DERIVATIVE FUNCTION
1566///////////////////////////////////////
1567
1568class VisualShaderNodeDerivativeFunc : public VisualShaderNode {
1569 GDCLASS(VisualShaderNodeDerivativeFunc, VisualShaderNode);
1570
1571public:
1572 enum OpType {
1573 OP_TYPE_SCALAR,
1574 OP_TYPE_VECTOR_2D,
1575 OP_TYPE_VECTOR_3D,
1576 OP_TYPE_VECTOR_4D,
1577 OP_TYPE_MAX,
1578 };
1579
1580 enum Function {
1581 FUNC_SUM,
1582 FUNC_X,
1583 FUNC_Y,
1584 FUNC_MAX,
1585 };
1586
1587 enum Precision {
1588 PRECISION_NONE,
1589 PRECISION_COARSE,
1590 PRECISION_FINE,
1591 PRECISION_MAX,
1592 };
1593
1594protected:
1595 OpType op_type = OP_TYPE_SCALAR;
1596 Function func = FUNC_SUM;
1597 Precision precision = PRECISION_NONE;
1598
1599protected:
1600 static void _bind_methods();
1601
1602public:
1603 virtual String get_caption() const override;
1604
1605 virtual int get_input_port_count() const override;
1606 virtual PortType get_input_port_type(int p_port) const override;
1607 virtual String get_input_port_name(int p_port) const override;
1608
1609 virtual int get_output_port_count() const override;
1610 virtual PortType get_output_port_type(int p_port) const override;
1611 virtual String get_output_port_name(int p_port) const override;
1612
1613 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1614 virtual String get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const override;
1615
1616 void set_op_type(OpType p_op_type);
1617 OpType get_op_type() const;
1618
1619 void set_function(Function p_func);
1620 Function get_function() const;
1621
1622 void set_precision(Precision p_precision);
1623 Precision get_precision() const;
1624
1625 virtual Vector<StringName> get_editable_properties() const override;
1626
1627 VisualShaderNodeDerivativeFunc();
1628};
1629
1630VARIANT_ENUM_CAST(VisualShaderNodeDerivativeFunc::OpType)
1631VARIANT_ENUM_CAST(VisualShaderNodeDerivativeFunc::Function)
1632VARIANT_ENUM_CAST(VisualShaderNodeDerivativeFunc::Precision)
1633
1634///////////////////////////////////////
1635/// FACEFORWARD
1636///////////////////////////////////////
1637
1638class VisualShaderNodeFaceForward : public VisualShaderNodeVectorBase {
1639 GDCLASS(VisualShaderNodeFaceForward, VisualShaderNodeVectorBase);
1640
1641public:
1642 virtual String get_caption() const override;
1643
1644 virtual int get_input_port_count() const override;
1645 virtual String get_input_port_name(int p_port) const override;
1646
1647 virtual int get_output_port_count() const override;
1648 virtual String get_output_port_name(int p_port) const override;
1649
1650 virtual void set_op_type(OpType p_op_type) override;
1651 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1652
1653 VisualShaderNodeFaceForward();
1654};
1655
1656///////////////////////////////////////
1657/// OUTER PRODUCT
1658///////////////////////////////////////
1659
1660class VisualShaderNodeOuterProduct : public VisualShaderNode {
1661 GDCLASS(VisualShaderNodeOuterProduct, VisualShaderNode);
1662
1663public:
1664 virtual String get_caption() const override;
1665
1666 virtual int get_input_port_count() const override;
1667 virtual PortType get_input_port_type(int p_port) const override;
1668 virtual String get_input_port_name(int p_port) const override;
1669
1670 virtual int get_output_port_count() const override;
1671 virtual PortType get_output_port_type(int p_port) const override;
1672 virtual String get_output_port_name(int p_port) const override;
1673
1674 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1675
1676 VisualShaderNodeOuterProduct();
1677};
1678
1679///////////////////////////////////////
1680/// STEP
1681///////////////////////////////////////
1682
1683class VisualShaderNodeStep : public VisualShaderNode {
1684 GDCLASS(VisualShaderNodeStep, VisualShaderNode);
1685
1686public:
1687 enum OpType {
1688 OP_TYPE_SCALAR,
1689 OP_TYPE_VECTOR_2D,
1690 OP_TYPE_VECTOR_2D_SCALAR,
1691 OP_TYPE_VECTOR_3D,
1692 OP_TYPE_VECTOR_3D_SCALAR,
1693 OP_TYPE_VECTOR_4D,
1694 OP_TYPE_VECTOR_4D_SCALAR,
1695 OP_TYPE_MAX,
1696 };
1697
1698protected:
1699 OpType op_type = OP_TYPE_SCALAR;
1700 static void _bind_methods();
1701
1702public:
1703 virtual String get_caption() const override;
1704
1705 virtual int get_input_port_count() const override;
1706 virtual PortType get_input_port_type(int p_port) const override;
1707 virtual String get_input_port_name(int p_port) const override;
1708 virtual int get_default_input_port(PortType p_type) const override;
1709
1710 virtual int get_output_port_count() const override;
1711 virtual PortType get_output_port_type(int p_port) const override;
1712 virtual String get_output_port_name(int p_port) const override;
1713
1714 void set_op_type(OpType p_op_type);
1715 OpType get_op_type() const;
1716
1717 virtual Vector<StringName> get_editable_properties() const override;
1718
1719 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1720
1721 VisualShaderNodeStep();
1722};
1723
1724VARIANT_ENUM_CAST(VisualShaderNodeStep::OpType)
1725
1726///////////////////////////////////////
1727/// SMOOTHSTEP
1728///////////////////////////////////////
1729
1730class VisualShaderNodeSmoothStep : public VisualShaderNode {
1731 GDCLASS(VisualShaderNodeSmoothStep, VisualShaderNode);
1732
1733public:
1734 enum OpType {
1735 OP_TYPE_SCALAR,
1736 OP_TYPE_VECTOR_2D,
1737 OP_TYPE_VECTOR_2D_SCALAR,
1738 OP_TYPE_VECTOR_3D,
1739 OP_TYPE_VECTOR_3D_SCALAR,
1740 OP_TYPE_VECTOR_4D,
1741 OP_TYPE_VECTOR_4D_SCALAR,
1742 OP_TYPE_MAX,
1743 };
1744
1745protected:
1746 OpType op_type = OP_TYPE_SCALAR;
1747 static void _bind_methods();
1748
1749public:
1750 virtual String get_caption() const override;
1751
1752 virtual int get_input_port_count() const override;
1753 virtual PortType get_input_port_type(int p_port) const override;
1754 virtual String get_input_port_name(int p_port) const override;
1755 virtual int get_default_input_port(PortType p_type) const override;
1756
1757 virtual int get_output_port_count() const override;
1758 virtual PortType get_output_port_type(int p_port) const override;
1759 virtual String get_output_port_name(int p_port) const override;
1760
1761 void set_op_type(OpType p_op_type);
1762 OpType get_op_type() const;
1763
1764 virtual Vector<StringName> get_editable_properties() const override;
1765
1766 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1767
1768 VisualShaderNodeSmoothStep();
1769};
1770
1771VARIANT_ENUM_CAST(VisualShaderNodeSmoothStep::OpType)
1772
1773///////////////////////////////////////
1774/// DISTANCE
1775///////////////////////////////////////
1776
1777class VisualShaderNodeVectorDistance : public VisualShaderNodeVectorBase {
1778 GDCLASS(VisualShaderNodeVectorDistance, VisualShaderNodeVectorBase);
1779
1780public:
1781 virtual String get_caption() const override;
1782
1783 virtual int get_input_port_count() const override;
1784 virtual String get_input_port_name(int p_port) const override;
1785
1786 virtual int get_output_port_count() const override;
1787 virtual PortType get_output_port_type(int p_port) const override;
1788 virtual String get_output_port_name(int p_port) const override;
1789
1790 virtual void set_op_type(OpType p_op_type) override;
1791 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1792
1793 VisualShaderNodeVectorDistance();
1794};
1795
1796///////////////////////////////////////
1797/// REFRACT
1798///////////////////////////////////////
1799
1800class VisualShaderNodeVectorRefract : public VisualShaderNodeVectorBase {
1801 GDCLASS(VisualShaderNodeVectorRefract, VisualShaderNodeVectorBase);
1802
1803public:
1804 virtual String get_caption() const override;
1805
1806 virtual int get_input_port_count() const override;
1807 virtual String get_input_port_name(int p_port) const override;
1808
1809 virtual int get_output_port_count() const override;
1810 virtual String get_output_port_name(int p_port) const override;
1811
1812 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1813 virtual void set_op_type(OpType p_op_type) override;
1814
1815 VisualShaderNodeVectorRefract();
1816};
1817
1818///////////////////////////////////////
1819/// MIX
1820///////////////////////////////////////
1821
1822class VisualShaderNodeMix : public VisualShaderNode {
1823 GDCLASS(VisualShaderNodeMix, VisualShaderNode);
1824
1825public:
1826 enum OpType {
1827 OP_TYPE_SCALAR,
1828 OP_TYPE_VECTOR_2D,
1829 OP_TYPE_VECTOR_2D_SCALAR,
1830 OP_TYPE_VECTOR_3D,
1831 OP_TYPE_VECTOR_3D_SCALAR,
1832 OP_TYPE_VECTOR_4D,
1833 OP_TYPE_VECTOR_4D_SCALAR,
1834 OP_TYPE_MAX,
1835 };
1836
1837protected:
1838 OpType op_type = OP_TYPE_SCALAR;
1839 static void _bind_methods();
1840
1841public:
1842 virtual String get_caption() const override;
1843
1844 virtual int get_input_port_count() const override;
1845 virtual PortType get_input_port_type(int p_port) const override;
1846 virtual String get_input_port_name(int p_port) const override;
1847
1848 virtual int get_output_port_count() const override;
1849 virtual PortType get_output_port_type(int p_port) const override;
1850 virtual String get_output_port_name(int p_port) const override;
1851
1852 void set_op_type(OpType p_op_type);
1853 OpType get_op_type() const;
1854
1855 virtual Vector<StringName> get_editable_properties() const override;
1856
1857 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1858
1859 VisualShaderNodeMix();
1860};
1861
1862VARIANT_ENUM_CAST(VisualShaderNodeMix::OpType)
1863
1864///////////////////////////////////////
1865/// COMPOSE
1866///////////////////////////////////////
1867
1868class VisualShaderNodeVectorCompose : public VisualShaderNodeVectorBase {
1869 GDCLASS(VisualShaderNodeVectorCompose, VisualShaderNodeVectorBase);
1870
1871public:
1872 virtual String get_caption() const override;
1873
1874 virtual int get_input_port_count() const override;
1875 virtual PortType get_input_port_type(int p_port) const override;
1876 virtual String get_input_port_name(int p_port) const override;
1877
1878 virtual int get_output_port_count() const override;
1879 virtual String get_output_port_name(int p_port) const override;
1880
1881 virtual void set_op_type(OpType p_op_type) override;
1882 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1883
1884 VisualShaderNodeVectorCompose();
1885};
1886
1887///////////////////////////////////////
1888
1889class VisualShaderNodeTransformCompose : public VisualShaderNode {
1890 GDCLASS(VisualShaderNodeTransformCompose, VisualShaderNode);
1891
1892public:
1893 virtual String get_caption() const override;
1894
1895 virtual int get_input_port_count() const override;
1896 virtual PortType get_input_port_type(int p_port) const override;
1897 virtual String get_input_port_name(int p_port) const override;
1898
1899 virtual int get_output_port_count() const override;
1900 virtual PortType get_output_port_type(int p_port) const override;
1901 virtual String get_output_port_name(int p_port) const override;
1902
1903 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1904
1905 VisualShaderNodeTransformCompose();
1906};
1907
1908///////////////////////////////////////
1909/// DECOMPOSE
1910///////////////////////////////////////
1911
1912class VisualShaderNodeVectorDecompose : public VisualShaderNodeVectorBase {
1913 GDCLASS(VisualShaderNodeVectorDecompose, VisualShaderNodeVectorBase);
1914
1915public:
1916 virtual String get_caption() const override;
1917
1918 virtual int get_input_port_count() const override;
1919 virtual String get_input_port_name(int p_port) const override;
1920
1921 virtual int get_output_port_count() const override;
1922 virtual PortType get_output_port_type(int p_port) const override;
1923 virtual String get_output_port_name(int p_port) const override;
1924
1925 virtual void set_op_type(OpType p_op_type) override;
1926 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1927
1928 VisualShaderNodeVectorDecompose();
1929};
1930
1931///////////////////////////////////////
1932
1933class VisualShaderNodeTransformDecompose : public VisualShaderNode {
1934 GDCLASS(VisualShaderNodeTransformDecompose, VisualShaderNode);
1935
1936public:
1937 virtual String get_caption() const override;
1938
1939 virtual int get_input_port_count() const override;
1940 virtual PortType get_input_port_type(int p_port) const override;
1941 virtual String get_input_port_name(int p_port) const override;
1942
1943 virtual int get_output_port_count() const override;
1944 virtual PortType get_output_port_type(int p_port) const override;
1945 virtual String get_output_port_name(int p_port) const override;
1946
1947 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1948
1949 VisualShaderNodeTransformDecompose();
1950};
1951
1952///////////////////////////////////////
1953/// PARAMETERS
1954///////////////////////////////////////
1955
1956class VisualShaderNodeFloatParameter : public VisualShaderNodeParameter {
1957 GDCLASS(VisualShaderNodeFloatParameter, VisualShaderNodeParameter);
1958
1959public:
1960 enum Hint {
1961 HINT_NONE,
1962 HINT_RANGE,
1963 HINT_RANGE_STEP,
1964 HINT_MAX,
1965 };
1966
1967private:
1968 Hint hint = HINT_NONE;
1969 float hint_range_min = 0.0f;
1970 float hint_range_max = 1.0f;
1971 float hint_range_step = 0.1f;
1972 bool default_value_enabled = false;
1973 float default_value = 0.0f;
1974
1975protected:
1976 static void _bind_methods();
1977
1978public:
1979 virtual String get_caption() const override;
1980
1981 virtual int get_input_port_count() const override;
1982 virtual PortType get_input_port_type(int p_port) const override;
1983 virtual String get_input_port_name(int p_port) const override;
1984
1985 virtual int get_output_port_count() const override;
1986 virtual PortType get_output_port_type(int p_port) const override;
1987 virtual String get_output_port_name(int p_port) const override;
1988
1989 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
1990 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
1991
1992 virtual bool is_show_prop_names() const override;
1993 virtual bool is_use_prop_slots() const override;
1994
1995 void set_hint(Hint p_hint);
1996 Hint get_hint() const;
1997
1998 void set_min(float p_value);
1999 float get_min() const;
2000
2001 void set_max(float p_value);
2002 float get_max() const;
2003
2004 void set_step(float p_value);
2005 float get_step() const;
2006
2007 void set_default_value_enabled(bool p_enabled);
2008 bool is_default_value_enabled() const;
2009
2010 void set_default_value(float p_value);
2011 float get_default_value() const;
2012
2013 bool is_qualifier_supported(Qualifier p_qual) const override;
2014 bool is_convertible_to_constant() const override;
2015
2016 virtual Vector<StringName> get_editable_properties() const override;
2017
2018 VisualShaderNodeFloatParameter();
2019};
2020
2021VARIANT_ENUM_CAST(VisualShaderNodeFloatParameter::Hint)
2022
2023class VisualShaderNodeIntParameter : public VisualShaderNodeParameter {
2024 GDCLASS(VisualShaderNodeIntParameter, VisualShaderNodeParameter);
2025
2026public:
2027 enum Hint {
2028 HINT_NONE,
2029 HINT_RANGE,
2030 HINT_RANGE_STEP,
2031 HINT_MAX,
2032 };
2033
2034private:
2035 Hint hint = HINT_NONE;
2036 int hint_range_min = 0;
2037 int hint_range_max = 100;
2038 int hint_range_step = 1;
2039 bool default_value_enabled = false;
2040 int default_value = 0;
2041
2042protected:
2043 static void _bind_methods();
2044
2045public:
2046 virtual String get_caption() const override;
2047
2048 virtual int get_input_port_count() const override;
2049 virtual PortType get_input_port_type(int p_port) const override;
2050 virtual String get_input_port_name(int p_port) const override;
2051
2052 virtual int get_output_port_count() const override;
2053 virtual PortType get_output_port_type(int p_port) const override;
2054 virtual String get_output_port_name(int p_port) const override;
2055
2056 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
2057 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2058
2059 virtual bool is_show_prop_names() const override;
2060 virtual bool is_use_prop_slots() const override;
2061
2062 void set_hint(Hint p_hint);
2063 Hint get_hint() const;
2064
2065 void set_min(int p_value);
2066 int get_min() const;
2067
2068 void set_max(int p_value);
2069 int get_max() const;
2070
2071 void set_step(int p_value);
2072 int get_step() const;
2073
2074 void set_default_value_enabled(bool p_enabled);
2075 bool is_default_value_enabled() const;
2076
2077 void set_default_value(int p_value);
2078 int get_default_value() const;
2079
2080 bool is_qualifier_supported(Qualifier p_qual) const override;
2081 bool is_convertible_to_constant() const override;
2082
2083 virtual Vector<StringName> get_editable_properties() const override;
2084
2085 VisualShaderNodeIntParameter();
2086};
2087
2088VARIANT_ENUM_CAST(VisualShaderNodeIntParameter::Hint)
2089
2090///////////////////////////////////////
2091
2092class VisualShaderNodeUIntParameter : public VisualShaderNodeParameter {
2093 GDCLASS(VisualShaderNodeUIntParameter, VisualShaderNodeParameter);
2094
2095private:
2096 bool default_value_enabled = false;
2097 int default_value = 0;
2098
2099protected:
2100 static void _bind_methods();
2101
2102public:
2103 virtual String get_caption() const override;
2104
2105 virtual int get_input_port_count() const override;
2106 virtual PortType get_input_port_type(int p_port) const override;
2107 virtual String get_input_port_name(int p_port) const override;
2108
2109 virtual int get_output_port_count() const override;
2110 virtual PortType get_output_port_type(int p_port) const override;
2111 virtual String get_output_port_name(int p_port) const override;
2112
2113 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
2114 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2115
2116 virtual bool is_show_prop_names() const override;
2117 virtual bool is_use_prop_slots() const override;
2118
2119 void set_default_value_enabled(bool p_enabled);
2120 bool is_default_value_enabled() const;
2121
2122 void set_default_value(int p_value);
2123 int get_default_value() const;
2124
2125 bool is_qualifier_supported(Qualifier p_qual) const override;
2126 bool is_convertible_to_constant() const override;
2127
2128 virtual Vector<StringName> get_editable_properties() const override;
2129
2130 VisualShaderNodeUIntParameter();
2131};
2132
2133///////////////////////////////////////
2134
2135class VisualShaderNodeBooleanParameter : public VisualShaderNodeParameter {
2136 GDCLASS(VisualShaderNodeBooleanParameter, VisualShaderNodeParameter);
2137
2138private:
2139 bool default_value_enabled = false;
2140 bool default_value = false;
2141
2142protected:
2143 static void _bind_methods();
2144
2145public:
2146 virtual String get_caption() const override;
2147
2148 virtual int get_input_port_count() const override;
2149 virtual PortType get_input_port_type(int p_port) const override;
2150 virtual String get_input_port_name(int p_port) const override;
2151
2152 virtual int get_output_port_count() const override;
2153 virtual PortType get_output_port_type(int p_port) const override;
2154 virtual String get_output_port_name(int p_port) const override;
2155
2156 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
2157 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2158
2159 virtual bool is_show_prop_names() const override;
2160 virtual bool is_use_prop_slots() const override;
2161
2162 void set_default_value_enabled(bool p_enabled);
2163 bool is_default_value_enabled() const;
2164
2165 void set_default_value(bool p_value);
2166 bool get_default_value() const;
2167
2168 bool is_qualifier_supported(Qualifier p_qual) const override;
2169 bool is_convertible_to_constant() const override;
2170
2171 virtual Vector<StringName> get_editable_properties() const override;
2172
2173 VisualShaderNodeBooleanParameter();
2174};
2175
2176///////////////////////////////////////
2177
2178class VisualShaderNodeColorParameter : public VisualShaderNodeParameter {
2179 GDCLASS(VisualShaderNodeColorParameter, VisualShaderNodeParameter);
2180
2181private:
2182 bool default_value_enabled = false;
2183 Color default_value = Color(1.0, 1.0, 1.0, 1.0);
2184
2185protected:
2186 static void _bind_methods();
2187
2188public:
2189 virtual String get_caption() const override;
2190
2191 virtual int get_input_port_count() const override;
2192 virtual PortType get_input_port_type(int p_port) const override;
2193 virtual String get_input_port_name(int p_port) const override;
2194
2195 virtual int get_output_port_count() const override;
2196 virtual PortType get_output_port_type(int p_port) const override;
2197 virtual String get_output_port_name(int p_port) const override;
2198
2199 bool is_output_port_expandable(int p_port) const override;
2200
2201 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
2202 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2203
2204 virtual bool is_show_prop_names() const override;
2205
2206 void set_default_value_enabled(bool p_enabled);
2207 bool is_default_value_enabled() const;
2208
2209 void set_default_value(const Color &p_value);
2210 Color get_default_value() const;
2211
2212 bool is_qualifier_supported(Qualifier p_qual) const override;
2213 bool is_convertible_to_constant() const override;
2214
2215 virtual Vector<StringName> get_editable_properties() const override;
2216
2217 VisualShaderNodeColorParameter();
2218};
2219
2220///////////////////////////////////////
2221
2222class VisualShaderNodeVec2Parameter : public VisualShaderNodeParameter {
2223 GDCLASS(VisualShaderNodeVec2Parameter, VisualShaderNodeParameter);
2224
2225private:
2226 bool default_value_enabled = false;
2227 Vector2 default_value;
2228
2229protected:
2230 static void _bind_methods();
2231
2232public:
2233 virtual String get_caption() const override;
2234
2235 virtual int get_input_port_count() const override;
2236 virtual PortType get_input_port_type(int p_port) const override;
2237 virtual String get_input_port_name(int p_port) const override;
2238
2239 virtual int get_output_port_count() const override;
2240 virtual PortType get_output_port_type(int p_port) const override;
2241 virtual String get_output_port_name(int p_port) const override;
2242
2243 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
2244 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2245
2246 virtual bool is_show_prop_names() const override;
2247 virtual bool is_use_prop_slots() const override;
2248
2249 void set_default_value_enabled(bool p_enabled);
2250 bool is_default_value_enabled() const;
2251
2252 void set_default_value(const Vector2 &p_value);
2253 Vector2 get_default_value() const;
2254
2255 bool is_qualifier_supported(Qualifier p_qual) const override;
2256 bool is_convertible_to_constant() const override;
2257
2258 virtual Vector<StringName> get_editable_properties() const override;
2259
2260 VisualShaderNodeVec2Parameter();
2261};
2262
2263///////////////////////////////////////
2264
2265class VisualShaderNodeVec3Parameter : public VisualShaderNodeParameter {
2266 GDCLASS(VisualShaderNodeVec3Parameter, VisualShaderNodeParameter);
2267
2268private:
2269 bool default_value_enabled = false;
2270 Vector3 default_value;
2271
2272protected:
2273 static void _bind_methods();
2274
2275public:
2276 virtual String get_caption() const override;
2277
2278 virtual int get_input_port_count() const override;
2279 virtual PortType get_input_port_type(int p_port) const override;
2280 virtual String get_input_port_name(int p_port) const override;
2281
2282 virtual int get_output_port_count() const override;
2283 virtual PortType get_output_port_type(int p_port) const override;
2284 virtual String get_output_port_name(int p_port) const override;
2285
2286 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
2287 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2288
2289 virtual bool is_show_prop_names() const override;
2290 virtual bool is_use_prop_slots() const override;
2291
2292 void set_default_value_enabled(bool p_enabled);
2293 bool is_default_value_enabled() const;
2294
2295 void set_default_value(const Vector3 &p_value);
2296 Vector3 get_default_value() const;
2297
2298 bool is_qualifier_supported(Qualifier p_qual) const override;
2299 bool is_convertible_to_constant() const override;
2300
2301 virtual Vector<StringName> get_editable_properties() const override;
2302
2303 VisualShaderNodeVec3Parameter();
2304};
2305
2306///////////////////////////////////////
2307
2308class VisualShaderNodeVec4Parameter : public VisualShaderNodeParameter {
2309 GDCLASS(VisualShaderNodeVec4Parameter, VisualShaderNodeParameter);
2310
2311private:
2312 bool default_value_enabled = false;
2313 Vector4 default_value;
2314
2315protected:
2316 static void _bind_methods();
2317
2318public:
2319 virtual String get_caption() const override;
2320
2321 virtual int get_input_port_count() const override;
2322 virtual PortType get_input_port_type(int p_port) const override;
2323 virtual String get_input_port_name(int p_port) const override;
2324
2325 virtual int get_output_port_count() const override;
2326 virtual PortType get_output_port_type(int p_port) const override;
2327 virtual String get_output_port_name(int p_port) const override;
2328
2329 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
2330 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2331
2332 virtual bool is_show_prop_names() const override;
2333 virtual bool is_use_prop_slots() const override;
2334
2335 void set_default_value_enabled(bool p_enabled);
2336 bool is_default_value_enabled() const;
2337
2338 void set_default_value(const Vector4 &p_value);
2339 Vector4 get_default_value() const;
2340
2341 bool is_qualifier_supported(Qualifier p_qual) const override;
2342 bool is_convertible_to_constant() const override;
2343
2344 virtual Vector<StringName> get_editable_properties() const override;
2345
2346 VisualShaderNodeVec4Parameter();
2347};
2348
2349///////////////////////////////////////
2350
2351class VisualShaderNodeTransformParameter : public VisualShaderNodeParameter {
2352 GDCLASS(VisualShaderNodeTransformParameter, VisualShaderNodeParameter);
2353
2354private:
2355 bool default_value_enabled = false;
2356 Transform3D default_value = Transform3D(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
2357
2358protected:
2359 static void _bind_methods();
2360
2361public:
2362 virtual String get_caption() const override;
2363
2364 virtual int get_input_port_count() const override;
2365 virtual PortType get_input_port_type(int p_port) const override;
2366 virtual String get_input_port_name(int p_port) const override;
2367
2368 virtual int get_output_port_count() const override;
2369 virtual PortType get_output_port_type(int p_port) const override;
2370 virtual String get_output_port_name(int p_port) const override;
2371
2372 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
2373 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2374
2375 virtual bool is_show_prop_names() const override;
2376 virtual bool is_use_prop_slots() const override;
2377
2378 void set_default_value_enabled(bool p_enabled);
2379 bool is_default_value_enabled() const;
2380
2381 void set_default_value(const Transform3D &p_value);
2382 Transform3D get_default_value() const;
2383
2384 bool is_qualifier_supported(Qualifier p_qual) const override;
2385 bool is_convertible_to_constant() const override;
2386
2387 virtual Vector<StringName> get_editable_properties() const override;
2388
2389 VisualShaderNodeTransformParameter();
2390};
2391
2392///////////////////////////////////////
2393
2394class VisualShaderNodeTextureParameter : public VisualShaderNodeParameter {
2395 GDCLASS(VisualShaderNodeTextureParameter, VisualShaderNodeParameter);
2396
2397public:
2398 enum TextureType {
2399 TYPE_DATA,
2400 TYPE_COLOR,
2401 TYPE_NORMAL_MAP,
2402 TYPE_ANISOTROPY,
2403 TYPE_MAX,
2404 };
2405
2406 enum ColorDefault {
2407 COLOR_DEFAULT_WHITE,
2408 COLOR_DEFAULT_BLACK,
2409 COLOR_DEFAULT_TRANSPARENT,
2410 COLOR_DEFAULT_MAX,
2411 };
2412
2413 enum TextureFilter {
2414 FILTER_DEFAULT,
2415 FILTER_NEAREST,
2416 FILTER_LINEAR,
2417 FILTER_NEAREST_MIPMAP,
2418 FILTER_LINEAR_MIPMAP,
2419 FILTER_NEAREST_MIPMAP_ANISOTROPIC,
2420 FILTER_LINEAR_MIPMAP_ANISOTROPIC,
2421 FILTER_MAX,
2422 };
2423
2424 enum TextureRepeat {
2425 REPEAT_DEFAULT,
2426 REPEAT_ENABLED,
2427 REPEAT_DISABLED,
2428 REPEAT_MAX,
2429 };
2430
2431 enum TextureSource {
2432 SOURCE_NONE,
2433 SOURCE_SCREEN,
2434 SOURCE_DEPTH,
2435 SOURCE_NORMAL_ROUGHNESS,
2436 SOURCE_MAX,
2437 };
2438
2439protected:
2440 TextureType texture_type = TYPE_DATA;
2441 ColorDefault color_default = COLOR_DEFAULT_WHITE;
2442 TextureFilter texture_filter = FILTER_DEFAULT;
2443 TextureRepeat texture_repeat = REPEAT_DEFAULT;
2444 TextureSource texture_source = SOURCE_NONE;
2445
2446protected:
2447 static void _bind_methods();
2448
2449public:
2450 virtual int get_input_port_count() const override;
2451 virtual PortType get_input_port_type(int p_port) const override;
2452 virtual String get_input_port_name(int p_port) const override;
2453
2454 virtual int get_output_port_count() const override;
2455 virtual PortType get_output_port_type(int p_port) const override;
2456
2457 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2458
2459 virtual HashMap<StringName, String> get_editable_properties_names() const override;
2460 virtual bool is_show_prop_names() const override;
2461
2462 Vector<StringName> get_editable_properties() const override;
2463
2464 void set_texture_type(TextureType p_type);
2465 TextureType get_texture_type() const;
2466
2467 void set_color_default(ColorDefault p_default);
2468 ColorDefault get_color_default() const;
2469
2470 void set_texture_filter(TextureFilter p_filter);
2471 TextureFilter get_texture_filter() const;
2472
2473 void set_texture_repeat(TextureRepeat p_repeat);
2474 TextureRepeat get_texture_repeat() const;
2475
2476 void set_texture_source(TextureSource p_source);
2477 TextureSource get_texture_source() const;
2478
2479 bool is_qualifier_supported(Qualifier p_qual) const override;
2480 bool is_convertible_to_constant() const override;
2481
2482 VisualShaderNodeTextureParameter();
2483};
2484
2485VARIANT_ENUM_CAST(VisualShaderNodeTextureParameter::TextureType)
2486VARIANT_ENUM_CAST(VisualShaderNodeTextureParameter::ColorDefault)
2487VARIANT_ENUM_CAST(VisualShaderNodeTextureParameter::TextureFilter)
2488VARIANT_ENUM_CAST(VisualShaderNodeTextureParameter::TextureRepeat)
2489VARIANT_ENUM_CAST(VisualShaderNodeTextureParameter::TextureSource)
2490
2491///////////////////////////////////////
2492
2493class VisualShaderNodeTexture2DParameter : public VisualShaderNodeTextureParameter {
2494 GDCLASS(VisualShaderNodeTexture2DParameter, VisualShaderNodeTextureParameter);
2495
2496public:
2497 virtual String get_caption() const override;
2498 virtual String get_output_port_name(int p_port) const override;
2499
2500 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
2501
2502 VisualShaderNodeTexture2DParameter();
2503};
2504
2505///////////////////////////////////////
2506
2507class VisualShaderNodeTextureParameterTriplanar : public VisualShaderNodeTextureParameter {
2508 GDCLASS(VisualShaderNodeTextureParameterTriplanar, VisualShaderNodeTextureParameter);
2509
2510public:
2511 virtual String get_caption() const override;
2512
2513 virtual int get_input_port_count() const override;
2514 virtual PortType get_input_port_type(int p_port) const override;
2515 virtual String get_input_port_name(int p_port) const override;
2516
2517 virtual int get_output_port_count() const override;
2518 virtual PortType get_output_port_type(int p_port) const override;
2519 virtual String get_output_port_name(int p_port) const override;
2520
2521 virtual bool is_input_port_default(int p_port, Shader::Mode p_mode) const override;
2522
2523 virtual String generate_global_per_node(Shader::Mode p_mode, int p_id) const override;
2524 virtual String generate_global_per_func(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
2525 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
2526 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2527
2528 VisualShaderNodeTextureParameterTriplanar();
2529};
2530
2531///////////////////////////////////////
2532
2533class VisualShaderNodeTexture2DArrayParameter : public VisualShaderNodeTextureParameter {
2534 GDCLASS(VisualShaderNodeTexture2DArrayParameter, VisualShaderNodeTextureParameter);
2535
2536public:
2537 virtual String get_caption() const override;
2538 virtual String get_output_port_name(int p_port) const override;
2539
2540 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
2541
2542 VisualShaderNodeTexture2DArrayParameter();
2543};
2544
2545///////////////////////////////////////
2546
2547class VisualShaderNodeTexture3DParameter : public VisualShaderNodeTextureParameter {
2548 GDCLASS(VisualShaderNodeTexture3DParameter, VisualShaderNodeTextureParameter);
2549
2550public:
2551 virtual String get_caption() const override;
2552 virtual String get_output_port_name(int p_port) const override;
2553
2554 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
2555
2556 VisualShaderNodeTexture3DParameter();
2557};
2558
2559///////////////////////////////////////
2560
2561class VisualShaderNodeCubemapParameter : public VisualShaderNodeTextureParameter {
2562 GDCLASS(VisualShaderNodeCubemapParameter, VisualShaderNodeTextureParameter);
2563
2564public:
2565 virtual String get_caption() const override;
2566 virtual String get_output_port_name(int p_port) const override;
2567
2568 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
2569
2570 VisualShaderNodeCubemapParameter();
2571};
2572
2573///////////////////////////////////////
2574/// IF
2575///////////////////////////////////////
2576
2577class VisualShaderNodeIf : public VisualShaderNode {
2578 GDCLASS(VisualShaderNodeIf, VisualShaderNode);
2579
2580public:
2581 virtual String get_caption() const override;
2582
2583 virtual int get_input_port_count() const override;
2584 virtual PortType get_input_port_type(int p_port) const override;
2585 virtual String get_input_port_name(int p_port) const override;
2586
2587 virtual int get_output_port_count() const override;
2588 virtual PortType get_output_port_type(int p_port) const override;
2589 virtual String get_output_port_name(int p_port) const override;
2590
2591 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2592
2593 VisualShaderNodeIf();
2594};
2595
2596///////////////////////////////////////
2597/// SWITCH
2598///////////////////////////////////////
2599
2600class VisualShaderNodeSwitch : public VisualShaderNode {
2601 GDCLASS(VisualShaderNodeSwitch, VisualShaderNode);
2602
2603public:
2604 enum OpType {
2605 OP_TYPE_FLOAT,
2606 OP_TYPE_INT,
2607 OP_TYPE_UINT,
2608 OP_TYPE_VECTOR_2D,
2609 OP_TYPE_VECTOR_3D,
2610 OP_TYPE_VECTOR_4D,
2611 OP_TYPE_BOOLEAN,
2612 OP_TYPE_TRANSFORM,
2613 OP_TYPE_MAX,
2614 };
2615
2616protected:
2617 OpType op_type = OP_TYPE_FLOAT;
2618
2619 static void _bind_methods();
2620
2621public:
2622 virtual String get_caption() const override;
2623
2624 virtual int get_input_port_count() const override;
2625 virtual PortType get_input_port_type(int p_port) const override;
2626 virtual String get_input_port_name(int p_port) const override;
2627
2628 virtual int get_output_port_count() const override;
2629 virtual PortType get_output_port_type(int p_port) const override;
2630 virtual String get_output_port_name(int p_port) const override;
2631
2632 void set_op_type(OpType p_op_type);
2633 OpType get_op_type() const;
2634
2635 virtual Vector<StringName> get_editable_properties() const override;
2636
2637 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2638
2639 VisualShaderNodeSwitch();
2640};
2641
2642VARIANT_ENUM_CAST(VisualShaderNodeSwitch::OpType)
2643
2644///////////////////////////////////////
2645/// FRESNEL
2646///////////////////////////////////////
2647
2648class VisualShaderNodeFresnel : public VisualShaderNode {
2649 GDCLASS(VisualShaderNodeFresnel, VisualShaderNode);
2650
2651public:
2652 virtual String get_caption() const override;
2653
2654 virtual int get_input_port_count() const override;
2655 virtual PortType get_input_port_type(int p_port) const override;
2656 virtual String get_input_port_name(int p_port) const override;
2657
2658 virtual int get_output_port_count() const override;
2659 virtual PortType get_output_port_type(int p_port) const override;
2660 virtual String get_output_port_name(int p_port) const override;
2661
2662 virtual bool is_input_port_default(int p_port, Shader::Mode p_mode) const override;
2663 virtual bool is_generate_input_var(int p_port) const override;
2664 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2665
2666 VisualShaderNodeFresnel();
2667};
2668
2669///////////////////////////////////////
2670/// Is
2671///////////////////////////////////////
2672
2673class VisualShaderNodeIs : public VisualShaderNode {
2674 GDCLASS(VisualShaderNodeIs, VisualShaderNode);
2675
2676public:
2677 enum Function {
2678 FUNC_IS_INF,
2679 FUNC_IS_NAN,
2680 FUNC_MAX,
2681 };
2682
2683protected:
2684 Function func = FUNC_IS_INF;
2685
2686protected:
2687 static void _bind_methods();
2688
2689public:
2690 virtual String get_caption() const override;
2691
2692 virtual int get_input_port_count() const override;
2693 virtual PortType get_input_port_type(int p_port) const override;
2694 virtual String get_input_port_name(int p_port) const override;
2695
2696 virtual int get_output_port_count() const override;
2697 virtual PortType get_output_port_type(int p_port) const override;
2698 virtual String get_output_port_name(int p_port) const override;
2699
2700 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2701
2702 void set_function(Function p_func);
2703 Function get_function() const;
2704
2705 virtual Vector<StringName> get_editable_properties() const override;
2706
2707 VisualShaderNodeIs();
2708};
2709
2710VARIANT_ENUM_CAST(VisualShaderNodeIs::Function)
2711
2712///////////////////////////////////////
2713/// Compare
2714///////////////////////////////////////
2715
2716class VisualShaderNodeCompare : public VisualShaderNode {
2717 GDCLASS(VisualShaderNodeCompare, VisualShaderNode);
2718
2719public:
2720 enum ComparisonType {
2721 CTYPE_SCALAR,
2722 CTYPE_SCALAR_INT,
2723 CTYPE_SCALAR_UINT,
2724 CTYPE_VECTOR_2D,
2725 CTYPE_VECTOR_3D,
2726 CTYPE_VECTOR_4D,
2727 CTYPE_BOOLEAN,
2728 CTYPE_TRANSFORM,
2729 CTYPE_MAX,
2730 };
2731
2732 enum Function {
2733 FUNC_EQUAL,
2734 FUNC_NOT_EQUAL,
2735 FUNC_GREATER_THAN,
2736 FUNC_GREATER_THAN_EQUAL,
2737 FUNC_LESS_THAN,
2738 FUNC_LESS_THAN_EQUAL,
2739 FUNC_MAX,
2740 };
2741
2742 enum Condition {
2743 COND_ALL,
2744 COND_ANY,
2745 COND_MAX,
2746 };
2747
2748protected:
2749 ComparisonType comparison_type = CTYPE_SCALAR;
2750 Function func = FUNC_EQUAL;
2751 Condition condition = COND_ALL;
2752
2753protected:
2754 static void _bind_methods();
2755
2756public:
2757 virtual String get_caption() const override;
2758
2759 virtual int get_input_port_count() const override;
2760 virtual PortType get_input_port_type(int p_port) const override;
2761 virtual String get_input_port_name(int p_port) const override;
2762
2763 virtual int get_output_port_count() const override;
2764 virtual PortType get_output_port_type(int p_port) const override;
2765 virtual String get_output_port_name(int p_port) const override;
2766
2767 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2768
2769 void set_comparison_type(ComparisonType p_type);
2770 ComparisonType get_comparison_type() const;
2771
2772 void set_function(Function p_func);
2773 Function get_function() const;
2774
2775 void set_condition(Condition p_cond);
2776 Condition get_condition() const;
2777
2778 virtual Vector<StringName> get_editable_properties() const override;
2779 virtual String get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const override;
2780
2781 VisualShaderNodeCompare();
2782};
2783
2784VARIANT_ENUM_CAST(VisualShaderNodeCompare::ComparisonType)
2785VARIANT_ENUM_CAST(VisualShaderNodeCompare::Function)
2786VARIANT_ENUM_CAST(VisualShaderNodeCompare::Condition)
2787
2788class VisualShaderNodeMultiplyAdd : public VisualShaderNode {
2789 GDCLASS(VisualShaderNodeMultiplyAdd, VisualShaderNode);
2790
2791public:
2792 enum OpType {
2793 OP_TYPE_SCALAR,
2794 OP_TYPE_VECTOR_2D,
2795 OP_TYPE_VECTOR_3D,
2796 OP_TYPE_VECTOR_4D,
2797 OP_TYPE_MAX,
2798 };
2799
2800protected:
2801 OpType op_type = OP_TYPE_SCALAR;
2802
2803protected:
2804 static void _bind_methods();
2805
2806public:
2807 virtual String get_caption() const override;
2808
2809 virtual int get_input_port_count() const override;
2810 virtual PortType get_input_port_type(int p_port) const override;
2811 virtual String get_input_port_name(int p_port) const override;
2812
2813 virtual int get_output_port_count() const override;
2814 virtual PortType get_output_port_type(int p_port) const override;
2815 virtual String get_output_port_name(int p_port) const override;
2816
2817 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2818
2819 void set_op_type(OpType p_op_type);
2820 OpType get_op_type() const;
2821
2822 virtual Vector<StringName> get_editable_properties() const override;
2823
2824 VisualShaderNodeMultiplyAdd();
2825};
2826
2827VARIANT_ENUM_CAST(VisualShaderNodeMultiplyAdd::OpType)
2828
2829class VisualShaderNodeBillboard : public VisualShaderNode {
2830 GDCLASS(VisualShaderNodeBillboard, VisualShaderNode);
2831
2832public:
2833 enum BillboardType {
2834 BILLBOARD_TYPE_DISABLED,
2835 BILLBOARD_TYPE_ENABLED,
2836 BILLBOARD_TYPE_FIXED_Y,
2837 BILLBOARD_TYPE_PARTICLES,
2838 BILLBOARD_TYPE_MAX,
2839 };
2840
2841protected:
2842 BillboardType billboard_type = BILLBOARD_TYPE_ENABLED;
2843 bool keep_scale = false;
2844
2845protected:
2846 static void _bind_methods();
2847
2848public:
2849 virtual String get_caption() const override;
2850
2851 virtual int get_input_port_count() const override;
2852 virtual PortType get_input_port_type(int p_port) const override;
2853 virtual String get_input_port_name(int p_port) const override;
2854
2855 virtual int get_output_port_count() const override;
2856 virtual PortType get_output_port_type(int p_port) const override;
2857 virtual String get_output_port_name(int p_port) const override;
2858
2859 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2860
2861 virtual bool is_show_prop_names() const override;
2862
2863 void set_billboard_type(BillboardType p_billboard_type);
2864 BillboardType get_billboard_type() const;
2865
2866 void set_keep_scale_enabled(bool p_enabled);
2867 bool is_keep_scale_enabled() const;
2868
2869 virtual Vector<StringName> get_editable_properties() const override;
2870
2871 VisualShaderNodeBillboard();
2872};
2873
2874VARIANT_ENUM_CAST(VisualShaderNodeBillboard::BillboardType)
2875
2876///////////////////////////////////////
2877/// DistanceFade
2878///////////////////////////////////////
2879
2880class VisualShaderNodeDistanceFade : public VisualShaderNode {
2881 GDCLASS(VisualShaderNodeDistanceFade, VisualShaderNode);
2882
2883public:
2884 virtual String get_caption() const override;
2885
2886 virtual int get_input_port_count() const override;
2887 virtual PortType get_input_port_type(int p_port) const override;
2888 virtual String get_input_port_name(int p_port) const override;
2889
2890 virtual int get_output_port_count() const override;
2891 virtual PortType get_output_port_type(int p_port) const override;
2892 virtual String get_output_port_name(int p_port) const override;
2893 virtual bool has_output_port_preview(int p_port) const override;
2894
2895 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2896
2897 VisualShaderNodeDistanceFade();
2898};
2899
2900class VisualShaderNodeProximityFade : public VisualShaderNode {
2901 GDCLASS(VisualShaderNodeProximityFade, VisualShaderNode);
2902
2903public:
2904 virtual String get_caption() const override;
2905
2906 virtual int get_input_port_count() const override;
2907 virtual PortType get_input_port_type(int p_port) const override;
2908 virtual String get_input_port_name(int p_port) const override;
2909
2910 virtual int get_output_port_count() const override;
2911 virtual PortType get_output_port_type(int p_port) const override;
2912 virtual String get_output_port_name(int p_port) const override;
2913 virtual bool has_output_port_preview(int p_port) const override;
2914
2915 virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
2916 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2917
2918 VisualShaderNodeProximityFade();
2919};
2920
2921class VisualShaderNodeRandomRange : public VisualShaderNode {
2922 GDCLASS(VisualShaderNodeRandomRange, VisualShaderNode);
2923
2924public:
2925 virtual String get_caption() const override;
2926
2927 virtual int get_input_port_count() const override;
2928 virtual PortType get_input_port_type(int p_port) const override;
2929 virtual String get_input_port_name(int p_port) const override;
2930
2931 virtual int get_output_port_count() const override;
2932 virtual PortType get_output_port_type(int p_port) const override;
2933 virtual String get_output_port_name(int p_port) const override;
2934
2935 virtual String generate_global_per_node(Shader::Mode p_mode, int p_id) const override;
2936 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2937
2938 VisualShaderNodeRandomRange();
2939};
2940
2941class VisualShaderNodeRemap : public VisualShaderNode {
2942 GDCLASS(VisualShaderNodeRemap, VisualShaderNode);
2943
2944public:
2945 virtual String get_caption() const override;
2946
2947 virtual int get_input_port_count() const override;
2948 virtual PortType get_input_port_type(int p_port) const override;
2949 virtual String get_input_port_name(int p_port) const override;
2950
2951 virtual int get_output_port_count() const override;
2952 virtual PortType get_output_port_type(int p_port) const override;
2953 virtual String get_output_port_name(int p_port) const override;
2954
2955 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2956
2957 VisualShaderNodeRemap();
2958};
2959
2960class VisualShaderNodeRotationByAxis : public VisualShaderNode {
2961 GDCLASS(VisualShaderNodeRotationByAxis, VisualShaderNode);
2962
2963public:
2964 virtual String get_caption() const override;
2965
2966 virtual int get_input_port_count() const override;
2967 virtual PortType get_input_port_type(int p_port) const override;
2968 virtual String get_input_port_name(int p_port) const override;
2969
2970 virtual int get_output_port_count() const override;
2971 virtual PortType get_output_port_type(int p_port) const override;
2972 virtual String get_output_port_name(int p_port) const override;
2973 virtual bool has_output_port_preview(int p_port) const override;
2974
2975 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
2976
2977 VisualShaderNodeRotationByAxis();
2978};
2979
2980#endif // VISUAL_SHADER_NODES_H
2981