Blender V4.3
shader_nodes.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#ifndef __NODES_H__
6#define __NODES_H__
7
8#include "graph/node.h"
9#include "scene/image.h"
10#include "scene/shader_graph.h"
11
12#include "util/array.h"
13#include "util/string.h"
14
16
17class ImageManager;
18class LightManager;
19class Scene;
20class Shader;
21
22/* Texture Mapping */
23
25 public:
28 bool skip();
29 void compile(SVMCompiler &compiler, int offset_in, int offset_out);
30 int compile(SVMCompiler &compiler, ShaderInput *vector_in);
31 void compile(OSLCompiler &compiler);
32
33 int compile_begin(SVMCompiler &compiler, ShaderInput *vector_in);
34 void compile_end(SVMCompiler &compiler, ShaderInput *vector_in, int vector_offset);
35
39
42
43 enum Type { POINT = 0, TEXTURE = 1, VECTOR = 2, NORMAL = 3 };
45
46 enum Mapping { NONE = 0, X = 1, Y = 2, Z = 3 };
48
51};
52
53/* Nodes */
54
71
72/* Any node which uses image manager's slot should be a subclass of this one. */
74 public:
75 explicit ImageSlotTextureNode(const NodeType *node_type) : TextureNode(node_type)
76 {
78 }
79
80 virtual bool equals(const ShaderNode &other)
81 {
82 const ImageSlotTextureNode &other_node = (const ImageSlotTextureNode &)other;
83 return TextureNode::equals(other) && handle == other_node.handle;
84 }
85
87};
88
90 public:
92 ShaderNode *clone(ShaderGraph *graph) const;
93 void attributes(Shader *shader, AttributeRequestSet *attributes);
95 {
96 return true;
97 }
98
99 virtual bool equals(const ShaderNode &other)
100 {
101 const ImageTextureNode &other_node = (const ImageTextureNode &)other;
102 return ImageSlotTextureNode::equals(other) && animated == other_node.animated;
103 }
104
106
107 /* Parameters. */
108 NODE_SOCKET_API(ustring, filename)
109 NODE_SOCKET_API(ustring, colorspace)
112 NODE_SOCKET_API(InterpolationType, interpolation)
114 NODE_SOCKET_API(float, projection_blend)
115 NODE_SOCKET_API(bool, animated)
118
119 protected:
120 void cull_tiles(Scene *scene, ShaderGraph *graph);
121};
122
124 public:
126 ShaderNode *clone(ShaderGraph *graph) const;
127 void attributes(Shader *shader, AttributeRequestSet *attributes);
129 {
130 return true;
131 }
132
133 virtual bool equals(const ShaderNode &other)
134 {
135 const EnvironmentTextureNode &other_node = (const EnvironmentTextureNode &)other;
136 return ImageSlotTextureNode::equals(other) && animated == other_node.animated;
137 }
138
140
141 /* Parameters. */
142 NODE_SOCKET_API(ustring, filename)
143 NODE_SOCKET_API(ustring, colorspace)
146 NODE_SOCKET_API(InterpolationType, interpolation)
147 NODE_SOCKET_API(bool, animated)
149};
150
152 public:
154
156 NODE_SOCKET_API(float3, sun_direction)
157 NODE_SOCKET_API(float, turbidity)
158 NODE_SOCKET_API(float, ground_albedo)
159 NODE_SOCKET_API(bool, sun_disc)
160 NODE_SOCKET_API(float, sun_size)
161 NODE_SOCKET_API(float, sun_intensity)
162 NODE_SOCKET_API(float, sun_elevation)
163 NODE_SOCKET_API(float, sun_rotation)
164 NODE_SOCKET_API(float, altitude)
165 NODE_SOCKET_API(float, air_density)
166 NODE_SOCKET_API(float, dust_density)
167 NODE_SOCKET_API(float, ozone_density)
170
171 void simplify_settings(Scene *scene);
172
174 {
175 /* Clamping for numerical precision. */
176 return fmaxf(sun_size, 0.0005f);
177 }
178
180};
181
182class OutputNode : public ShaderNode {
183 public:
185
186 NODE_SOCKET_API(Node *, surface)
187 NODE_SOCKET_API(Node *, volume)
188 NODE_SOCKET_API(float3, displacement)
189 NODE_SOCKET_API(float3, normal)
190
191 /* Don't allow output node de-duplication. */
192 virtual bool equals(const ShaderNode & /*other*/)
193 {
194 return false;
195 }
196};
197
198class OutputAOVNode : public ShaderNode {
199 public:
201 virtual void simplify_settings(Scene *scene);
202
203 NODE_SOCKET_API(float, value)
204 NODE_SOCKET_API(float3, color)
205
206 NODE_SOCKET_API(ustring, name)
207
208 /* Don't allow output node de-duplication. */
209 virtual bool equals(const ShaderNode & /*other*/)
210 {
211 return false;
212 }
213
216};
217
225
227 public:
229
230 NODE_SOCKET_API(int, dimensions)
232 NODE_SOCKET_API(bool, use_normalize)
233 NODE_SOCKET_API(float, w)
234 NODE_SOCKET_API(float, scale)
235 NODE_SOCKET_API(float, detail)
236 NODE_SOCKET_API(float, roughness)
237 NODE_SOCKET_API(float, lacunarity)
238 NODE_SOCKET_API(float, offset)
239 NODE_SOCKET_API(float, gain)
240 NODE_SOCKET_API(float, distortion)
242};
243
245 public:
247
250 NODE_SOCKET_API(float, scale)
251 NODE_SOCKET_API(float, frequency)
252 NODE_SOCKET_API(float, anisotropy)
253 NODE_SOCKET_API(float, orientation_2d)
254 NODE_SOCKET_API(float3, orientation_3d)
255};
256
258 public:
260
261 virtual int get_feature()
262 {
263 int result = ShaderNode::get_feature();
264 if (dimensions == 4) {
266 }
267 else if (dimensions >= 2 && feature == NODE_VORONOI_SMOOTH_F1) {
269 }
270 return result;
271 }
272
273 NODE_SOCKET_API(int, dimensions)
276 NODE_SOCKET_API(bool, use_normalize)
277 NODE_SOCKET_API(float, w)
278 NODE_SOCKET_API(float, scale)
279 NODE_SOCKET_API(float, detail)
280 NODE_SOCKET_API(float, roughness)
281 NODE_SOCKET_API(float, lacunarity)
282 NODE_SOCKET_API(float, exponent)
283 NODE_SOCKET_API(float, smoothness)
284 NODE_SOCKET_API(float, randomness)
286};
287
289 public:
291
292 NODE_SOCKET_API(NodeWaveType, wave_type)
296
297 NODE_SOCKET_API(float, scale)
298 NODE_SOCKET_API(float, distortion)
299 NODE_SOCKET_API(float, detail)
300 NODE_SOCKET_API(float, detail_scale)
301 NODE_SOCKET_API(float, detail_roughness)
302 NODE_SOCKET_API(float, phase)
304};
305
307 public:
309
310 NODE_SOCKET_API(int, depth)
312 NODE_SOCKET_API(float, scale)
313 NODE_SOCKET_API(float, distortion)
314};
315
317 public:
319
321 NODE_SOCKET_API(float3, color1)
322 NODE_SOCKET_API(float3, color2)
323 NODE_SOCKET_API(float, scale)
324};
325
327 public:
329
330 NODE_SOCKET_API(float, offset)
331 NODE_SOCKET_API(float, squash)
332 NODE_SOCKET_API(int, offset_frequency)
333 NODE_SOCKET_API(int, squash_frequency)
334
335 NODE_SOCKET_API(float3, color1)
336 NODE_SOCKET_API(float3, color2)
337 NODE_SOCKET_API(float3, mortar)
338 NODE_SOCKET_API(float, scale)
339 NODE_SOCKET_API(float, mortar_size)
340 NODE_SOCKET_API(float, mortar_smooth)
341 NODE_SOCKET_API(float, bias)
342 NODE_SOCKET_API(float, brick_width)
343 NODE_SOCKET_API(float, row_height)
345};
346
348 public:
350
352 ShaderNode *clone(ShaderGraph *graph) const;
353 void attributes(Shader *shader, AttributeRequestSet *attributes);
355 {
356 return true;
357 }
358
360 {
361 return true;
362 }
363
364 /* Parameters. */
365 NODE_SOCKET_API(ustring, filename)
367 NODE_SOCKET_API(InterpolationType, interpolation)
370
371 /* Runtime. */
373
375
376 virtual bool equals(const ShaderNode &other)
377 {
378 const PointDensityTextureNode &other_node = (const PointDensityTextureNode &)other;
379 return ShaderNode::equals(other) && handle == other_node.handle;
380 }
381};
382
383class IESLightNode : public TextureNode {
384 public:
386
388 ShaderNode *clone(ShaderGraph *graph) const;
389
390 NODE_SOCKET_API(ustring, filename)
391 NODE_SOCKET_API(ustring, ies)
392
393 NODE_SOCKET_API(float, strength)
395
396 private:
397 LightManager *light_manager;
398 int slot;
399
400 void get_slot();
401};
402
404 public:
406
407 NODE_SOCKET_API(int, dimensions)
409 NODE_SOCKET_API(float, w)
410};
411
412class MappingNode : public ShaderNode {
413 public:
415 void constant_fold(const ConstantFolder &folder);
416
418 NODE_SOCKET_API(float3, location)
419 NODE_SOCKET_API(float3, rotation)
420 NODE_SOCKET_API(float3, scale)
421 NODE_SOCKET_API(NodeMappingType, mapping_type)
422};
423
424class RGBToBWNode : public ShaderNode {
425 public:
427 void constant_fold(const ConstantFolder &folder);
428
429 NODE_SOCKET_API(float3, color)
430};
431
432class ConvertNode : public ShaderNode {
433 public:
434 ConvertNode(SocketType::Type from, SocketType::Type to, bool autoconvert = false);
435 ConvertNode(const ConvertNode &other);
437
438 void constant_fold(const ConstantFolder &folder);
439
440 private:
441 SocketType::Type from, to;
442
443 union {
450 };
451 ustring value_string;
452
453 static const int MAX_TYPE = 13;
454 static bool register_types();
455 static Node *create(const NodeType *type);
456 static const NodeType *node_types[MAX_TYPE][MAX_TYPE];
457 static bool initialized;
458};
459
460class BsdfBaseNode : public ShaderNode {
461 public:
462 BsdfBaseNode(const NodeType *node_type);
463
465 {
466 return true;
467 }
469 {
470 return closure;
471 }
472 virtual bool has_bump();
473
474 virtual bool equals(const ShaderNode & /*other*/)
475 {
476 /* TODO(sergey): With some care BSDF nodes can be de-duplicated. */
477 return false;
478 }
479
480 virtual int get_feature()
481 {
483 }
484
485 protected:
487};
488
489class BsdfNode : public BsdfBaseNode {
490 public:
491 explicit BsdfNode(const NodeType *node_type);
493
494 void compile(SVMCompiler &compiler,
495 ShaderInput *bsdf_y,
496 ShaderInput *bsdf_z,
497 ShaderInput *data_y = nullptr,
498 ShaderInput *data_z = nullptr,
499 ShaderInput *data_w = nullptr);
500
501 NODE_SOCKET_API(float3, color)
502 NODE_SOCKET_API(float3, normal)
503 NODE_SOCKET_API(float, surface_mix_weight)
504};
505
506class DiffuseBsdfNode : public BsdfNode {
507 public:
509
510 NODE_SOCKET_API(float, roughness)
511};
512
513/* Disney principled BRDF */
515 public:
517
518 bool has_surface_bssrdf();
519 bool has_bssrdf_bump();
520 void simplify_settings(Scene *scene);
521
522 NODE_SOCKET_API(float3, base_color)
523 NODE_SOCKET_API(float, metallic)
524 NODE_SOCKET_API(float, roughness)
525 NODE_SOCKET_API(float, ior)
526 NODE_SOCKET_API(float3, normal)
527 NODE_SOCKET_API(float, alpha)
528 NODE_SOCKET_API(float, diffuse_roughness)
529 NODE_SOCKET_API(ClosureType, subsurface_method)
530 NODE_SOCKET_API(float, subsurface_weight)
531 NODE_SOCKET_API(float3, subsurface_radius)
532 NODE_SOCKET_API(float, subsurface_scale)
533 NODE_SOCKET_API(float, subsurface_ior)
534 NODE_SOCKET_API(float, subsurface_anisotropy)
535 NODE_SOCKET_API(ClosureType, distribution)
536 NODE_SOCKET_API(float, specular_ior_level)
537 NODE_SOCKET_API(float3, specular_tint)
538 NODE_SOCKET_API(float, anisotropic)
539 NODE_SOCKET_API(float, anisotropic_rotation)
540 NODE_SOCKET_API(float3, tangent)
541 NODE_SOCKET_API(float, transmission_weight)
542 NODE_SOCKET_API(float, sheen_weight)
543 NODE_SOCKET_API(float, sheen_roughness)
544 NODE_SOCKET_API(float3, sheen_tint)
545 NODE_SOCKET_API(float, coat_weight)
546 NODE_SOCKET_API(float, coat_roughness)
547 NODE_SOCKET_API(float, coat_ior)
548 NODE_SOCKET_API(float3, coat_tint)
549 NODE_SOCKET_API(float3, coat_normal)
550 NODE_SOCKET_API(float3, emission_color)
551 NODE_SOCKET_API(float, emission_strength)
552 NODE_SOCKET_API(float, surface_mix_weight)
553 NODE_SOCKET_API(float, thin_film_thickness)
554 NODE_SOCKET_API(float, thin_film_ior)
555
556 public:
557 void attributes(Shader *shader, AttributeRequestSet *attributes);
559 {
560 return true;
561 }
564};
565
570
572 public:
574
576 {
577 return true;
578 }
579};
580
582 public:
584
585 NODE_SOCKET_API(float3, position)
586 NODE_SOCKET_API(float3, direction)
587
589 {
590 return true;
591 }
592};
593
594class SheenBsdfNode : public BsdfNode {
595 public:
597
598 NODE_SOCKET_API(float, roughness)
599 NODE_SOCKET_API(ClosureType, distribution)
600
602 {
603 return distribution;
604 }
605};
606
608 public:
610
611 void simplify_settings(Scene *scene);
613 {
614 return closure;
615 }
616
617 NODE_SOCKET_API(float3, edge_tint)
620 NODE_SOCKET_API(float3, tangent)
621 NODE_SOCKET_API(float, roughness)
622 NODE_SOCKET_API(float, anisotropy)
623 NODE_SOCKET_API(float, rotation)
624 NODE_SOCKET_API(ClosureType, distribution)
625 NODE_SOCKET_API(ClosureType, fresnel_type)
626
627 void attributes(Shader *shader, AttributeRequestSet *attributes);
629 {
630 return true;
631 }
632
633 bool is_isotropic();
634};
635
636class GlossyBsdfNode : public BsdfNode {
637 public:
639
640 void simplify_settings(Scene *scene);
642 {
643 return distribution;
644 }
645
646 NODE_SOCKET_API(float3, tangent)
647 NODE_SOCKET_API(float, roughness)
648 NODE_SOCKET_API(float, anisotropy)
649 NODE_SOCKET_API(float, rotation)
650 NODE_SOCKET_API(ClosureType, distribution)
651
652 void attributes(Shader *shader, AttributeRequestSet *attributes);
654 {
655 return true;
656 }
657
658 bool is_isotropic();
659};
660
661class GlassBsdfNode : public BsdfNode {
662 public:
664
666 {
667 return distribution;
668 }
669
670 NODE_SOCKET_API(float, roughness)
671 NODE_SOCKET_API(float, IOR)
672 NODE_SOCKET_API(ClosureType, distribution)
673};
674
676 public:
678
680 {
681 return distribution;
682 }
683
684 NODE_SOCKET_API(float, roughness)
685 NODE_SOCKET_API(float, IOR)
686 NODE_SOCKET_API(ClosureType, distribution)
687};
688
689class ToonBsdfNode : public BsdfNode {
690 public:
692
693 NODE_SOCKET_API(float, smooth)
694 NODE_SOCKET_API(float, size)
695 NODE_SOCKET_API(ClosureType, component)
696};
697
699 public:
702 {
703 return true;
704 }
705 bool has_bssrdf_bump();
707 {
708 return method;
709 }
710
711 NODE_SOCKET_API(float, scale)
712 NODE_SOCKET_API(float3, radius)
713 NODE_SOCKET_API(float, subsurface_ior)
714 NODE_SOCKET_API(float, subsurface_roughness)
715 NODE_SOCKET_API(float, subsurface_anisotropy)
717};
718
719class EmissionNode : public ShaderNode {
720 public:
722 void constant_fold(const ConstantFolder &folder);
723
725 {
726 return true;
727 }
729 {
730 return true;
731 }
732
733 virtual int get_feature()
734 {
736 }
737
738 NODE_SOCKET_API(float3, color)
739 NODE_SOCKET_API(float, strength)
740 NODE_SOCKET_API(float, surface_mix_weight)
741
743};
744
746 public:
748 void constant_fold(const ConstantFolder &folder);
749
750 virtual int get_feature()
751 {
753 }
754
755 NODE_SOCKET_API(float3, color)
756 NODE_SOCKET_API(float, strength)
757 NODE_SOCKET_API(float, surface_mix_weight)
758};
759
760class HoldoutNode : public ShaderNode {
761 public:
763 virtual ClosureType get_closure_type()
764 {
765 return CLOSURE_HOLDOUT_ID;
766 }
767
768 NODE_SOCKET_API(float, surface_mix_weight)
769 NODE_SOCKET_API(float, volume_mix_weight)
770};
771
773 public:
775
776 bool has_spatial_varying()
777 {
778 return true;
779 }
780 virtual int get_feature()
781 {
783 }
784
785 NODE_SOCKET_API(float3, color)
786 NODE_SOCKET_API(float, distance)
787 NODE_SOCKET_API(float3, normal)
788 NODE_SOCKET_API(int, samples)
789
790 NODE_SOCKET_API(bool, only_local)
791 NODE_SOCKET_API(bool, inside)
792};
793
794class VolumeNode : public ShaderNode {
795 public:
796 VolumeNode(const NodeType *node_type);
798
799 void compile(SVMCompiler &compiler,
800 ShaderInput *density,
801 ShaderInput *param1 = nullptr,
802 ShaderInput *param2 = nullptr);
803 virtual int get_feature()
804 {
806 }
808 {
809 return closure;
810 }
811 virtual bool has_volume_support()
812 {
813 return true;
814 }
815
816 NODE_SOCKET_API(float3, color)
817 NODE_SOCKET_API(float, density)
818 NODE_SOCKET_API(float, volume_mix_weight)
819
820 protected:
822
823 public:
824 virtual bool equals(const ShaderNode & /*other*/)
825 {
826 /* TODO(sergey): With some care Volume nodes can be de-duplicated. */
827 return false;
828 }
829};
830
835
837 public:
839
840 NODE_SOCKET_API(float, anisotropy)
841 NODE_SOCKET_API(float, IOR)
842 NODE_SOCKET_API(float, backscatter)
843 NODE_SOCKET_API(float, alpha)
844 NODE_SOCKET_API(float, diameter)
846};
847
849 public:
851 void attributes(Shader *shader, AttributeRequestSet *attributes);
853 {
854 return true;
855 }
856
857 NODE_SOCKET_API(ustring, density_attribute)
858 NODE_SOCKET_API(ustring, color_attribute)
859 NODE_SOCKET_API(ustring, temperature_attribute)
860
861 NODE_SOCKET_API(float, anisotropy)
862 NODE_SOCKET_API(float3, absorption_color)
863 NODE_SOCKET_API(float, emission_strength)
864 NODE_SOCKET_API(float3, emission_color)
865 NODE_SOCKET_API(float, blackbody_intensity)
866 NODE_SOCKET_API(float3, blackbody_tint)
867 NODE_SOCKET_API(float, temperature)
868};
869
870/* Interface between the I/O sockets and the SVM/OSL backend. */
872 public:
874 void attributes(Shader *shader, AttributeRequestSet *attributes);
875
876 /* Longitudinal roughness. */
877 NODE_SOCKET_API(float, roughness)
878 /* Azimuthal roughness. */
879 NODE_SOCKET_API(float, radial_roughness)
880 /* Randomization factor for roughnesses. */
881 NODE_SOCKET_API(float, random_roughness)
882 /* Longitudinal roughness factor for only the diffuse bounce (shiny undercoat). */
883 NODE_SOCKET_API(float, coat)
884 /* Index of reflection. */
885 NODE_SOCKET_API(float, ior)
886 /* Cuticle tilt angle. */
887 NODE_SOCKET_API(float, offset)
888 /* Direct coloring's color. */
889 NODE_SOCKET_API(float3, color)
890 /* Melanin concentration. */
891 NODE_SOCKET_API(float, melanin)
892 /* Melanin redness ratio. */
893 NODE_SOCKET_API(float, melanin_redness)
894 /* Dye color. */
896 /* Randomization factor for melanin quantities. */
897 NODE_SOCKET_API(float, random_color)
898 /* Absorption coefficient (unfiltered). */
899 NODE_SOCKET_API(float3, absorption_coefficient)
900
901 /* Aspect Ratio. */
902 NODE_SOCKET_API(float, aspect_ratio)
903
904 /* Optional modulation factors for the lobes. */
905 NODE_SOCKET_API(float, R)
906 NODE_SOCKET_API(float, TT)
907 NODE_SOCKET_API(float, TRT)
908
909 /* Weight for mix shader. */
910 NODE_SOCKET_API(float, surface_mix_weight)
911 /* If linked, here will be the given random number. */
912 NODE_SOCKET_API(float, random)
913 /* Selected coloring parametrization. */
915 /* Selected scattering model (chiang/huang). */
917
918 virtual int get_feature()
919 {
921 }
922
923 bool has_surface_transparent();
924};
925
926class HairBsdfNode : public BsdfNode {
927 public:
929 ClosureType get_closure_type()
930 {
931 return component;
932 }
933
934 NODE_SOCKET_API(ClosureType, component)
935 NODE_SOCKET_API(float, offset)
936 NODE_SOCKET_API(float, roughness_u)
937 NODE_SOCKET_API(float, roughness_v)
938 NODE_SOCKET_API(float3, tangent)
939};
940
941class GeometryNode : public ShaderNode {
942 public:
944 void attributes(Shader *shader, AttributeRequestSet *attributes);
946 {
947 return true;
948 }
950 {
951 return true;
952 }
954};
955
957 public:
959 void attributes(Shader *shader, AttributeRequestSet *attributes);
961 {
962 return true;
963 }
965 {
966 return true;
967 }
968
969 NODE_SOCKET_API(bool, from_dupli)
970 NODE_SOCKET_API(bool, use_transform)
972};
973
974class UVMapNode : public ShaderNode {
975 public:
977 void attributes(Shader *shader, AttributeRequestSet *attributes);
979 {
980 return true;
981 }
983 {
984 return true;
985 }
986
987 NODE_SOCKET_API(ustring, attribute)
988 NODE_SOCKET_API(bool, from_dupli)
989};
990
991class LightPathNode : public ShaderNode {
992 public:
994};
995
997 public:
999 bool has_spatial_varying()
1000 {
1001 return true;
1002 }
1003
1004 NODE_SOCKET_API(float, strength)
1005 NODE_SOCKET_API(float, smooth)
1006};
1007
1009 public:
1011};
1012
1014 public:
1016 void attributes(Shader *shader, AttributeRequestSet *attributes);
1018 {
1019 return true;
1020 }
1021};
1022
1023class HairInfoNode : public ShaderNode {
1024 public:
1026
1027 void attributes(Shader *shader, AttributeRequestSet *attributes);
1029 {
1030 return true;
1031 }
1033 {
1034 return true;
1035 }
1036};
1037
1039 public:
1041
1042 void attributes(Shader *shader, AttributeRequestSet *attributes);
1044 {
1045 return true;
1046 }
1048 {
1049 return true;
1050 }
1051};
1052
1054 public:
1056 void attributes(Shader *shader, AttributeRequestSet *attributes);
1058 {
1059 return true;
1060 }
1062 {
1063 return true;
1064 }
1065 void expand(ShaderGraph *graph);
1066};
1067
1069 public:
1071 void attributes(Shader *shader, AttributeRequestSet *attributes);
1073 {
1074 return true;
1075 }
1077 {
1078 return true;
1079 }
1080
1081 NODE_SOCKET_API(ustring, layer_name)
1082};
1083
1084class ValueNode : public ShaderNode {
1085 public:
1087
1088 void constant_fold(const ConstantFolder &folder);
1089
1090 NODE_SOCKET_API(float, value)
1091};
1092
1093class ColorNode : public ShaderNode {
1094 public:
1096
1097 void constant_fold(const ConstantFolder &folder);
1098
1099 NODE_SOCKET_API(float3, value)
1100};
1101
1103 public:
1105 void constant_fold(const ConstantFolder &folder);
1106};
1107
1109 public:
1111 void constant_fold(const ConstantFolder &folder);
1112
1113 NODE_SOCKET_API(float, fac)
1114};
1115
1117 public:
1119
1120 NODE_SOCKET_API(float, weight)
1121 NODE_SOCKET_API(float, fac)
1122};
1123
1124class InvertNode : public ShaderNode {
1125 public:
1127 void constant_fold(const ConstantFolder &folder);
1128
1129 NODE_SOCKET_API(float, fac)
1130 NODE_SOCKET_API(float3, color)
1131};
1132
1133class MixNode : public ShaderNode {
1134 public:
1136 void constant_fold(const ConstantFolder &folder);
1137
1138 NODE_SOCKET_API(NodeMix, mix_type)
1139 NODE_SOCKET_API(bool, use_clamp)
1140 NODE_SOCKET_API(float3, color1)
1141 NODE_SOCKET_API(float3, color2)
1142 NODE_SOCKET_API(float, fac)
1143};
1144
1145class MixColorNode : public ShaderNode {
1146 public:
1148 void constant_fold(const ConstantFolder &folder);
1149
1152 NODE_SOCKET_API(float, fac)
1153 NODE_SOCKET_API(bool, use_clamp)
1154 NODE_SOCKET_API(bool, use_clamp_result)
1155 NODE_SOCKET_API(NodeMix, blend_type)
1156};
1157
1158class MixFloatNode : public ShaderNode {
1159 public:
1161 void constant_fold(const ConstantFolder &folder);
1162
1163 NODE_SOCKET_API(float, a)
1164 NODE_SOCKET_API(float, b)
1165 NODE_SOCKET_API(float, fac)
1166 NODE_SOCKET_API(bool, use_clamp)
1167};
1168
1170 public:
1172 void constant_fold(const ConstantFolder &folder);
1173
1176 NODE_SOCKET_API(float, fac)
1177 NODE_SOCKET_API(bool, use_clamp)
1178};
1179
1181 public:
1183 void constant_fold(const ConstantFolder &folder);
1184
1188 NODE_SOCKET_API(bool, use_clamp)
1189};
1190
1192 public:
1194 void constant_fold(const ConstantFolder &folder);
1195
1197 NODE_SOCKET_API(float, r)
1198 NODE_SOCKET_API(float, g)
1199 NODE_SOCKET_API(float, b)
1200};
1201
1203 public:
1205 void constant_fold(const ConstantFolder &folder);
1206
1207 NODE_SOCKET_API(float, r)
1208 NODE_SOCKET_API(float, g)
1209 NODE_SOCKET_API(float, b)
1210};
1211
1213 public:
1215 void constant_fold(const ConstantFolder &folder);
1216
1217 NODE_SOCKET_API(float, h)
1218 NODE_SOCKET_API(float, s)
1219 NODE_SOCKET_API(float, v)
1220};
1221
1223 public:
1225 void constant_fold(const ConstantFolder &folder);
1226
1227 NODE_SOCKET_API(float, x)
1228 NODE_SOCKET_API(float, y)
1229 NODE_SOCKET_API(float, z)
1230};
1231
1232class GammaNode : public ShaderNode {
1233 public:
1235 void constant_fold(const ConstantFolder &folder);
1236
1237 NODE_SOCKET_API(float3, color)
1238 NODE_SOCKET_API(float, gamma)
1239};
1240
1242 public:
1244 void constant_fold(const ConstantFolder &folder);
1245
1246 NODE_SOCKET_API(float3, color)
1247 NODE_SOCKET_API(float, bright)
1248 NODE_SOCKET_API(float, contrast)
1249};
1250
1252 public:
1254 void constant_fold(const ConstantFolder &folder);
1255
1257 NODE_SOCKET_API(float3, color)
1258};
1259
1261 public:
1263 void constant_fold(const ConstantFolder &folder);
1264
1265 NODE_SOCKET_API(float3, color)
1266};
1267
1269 public:
1271 void constant_fold(const ConstantFolder &folder);
1272
1273 NODE_SOCKET_API(float3, color)
1274};
1275
1277 public:
1279 void constant_fold(const ConstantFolder &folder);
1280
1282};
1283
1284class HSVNode : public ShaderNode {
1285 public:
1287
1288 NODE_SOCKET_API(float, hue)
1289 NODE_SOCKET_API(float, saturation)
1290 NODE_SOCKET_API(float, value)
1291 NODE_SOCKET_API(float, fac)
1292 NODE_SOCKET_API(float3, color)
1293};
1294
1296 public:
1298 void attributes(Shader *shader, AttributeRequestSet *attributes);
1300 {
1301 return true;
1302 }
1304 {
1305 return true;
1306 }
1307
1308 NODE_SOCKET_API(ustring, attribute)
1309};
1310
1311class CameraNode : public ShaderNode {
1312 public:
1314 bool has_spatial_varying()
1315 {
1316 return true;
1317 }
1318};
1319
1320class FresnelNode : public ShaderNode {
1321 public:
1323 bool has_spatial_varying()
1324 {
1325 return true;
1326 }
1327
1328 NODE_SOCKET_API(float3, normal)
1329 NODE_SOCKET_API(float, IOR)
1330};
1331
1333 public:
1335 bool has_spatial_varying()
1336 {
1337 return true;
1338 }
1339
1340 NODE_SOCKET_API(float3, normal)
1341 NODE_SOCKET_API(float, blend)
1342};
1343
1345 public:
1347 bool has_spatial_varying()
1348 {
1349 return true;
1350 }
1351
1352 NODE_SOCKET_API(float, size)
1353 NODE_SOCKET_API(bool, use_pixel_size)
1354};
1355
1357 public:
1359
1360 NODE_SOCKET_API(float, wavelength)
1361};
1362
1364 public:
1366 void constant_fold(const ConstantFolder &folder);
1367
1368 NODE_SOCKET_API(float, temperature)
1369};
1370
1372 public:
1374 void expand(ShaderGraph *graph);
1375
1377 NODE_SOCKET_API(float3, from_min)
1378 NODE_SOCKET_API(float3, from_max)
1379 NODE_SOCKET_API(float3, to_min)
1380 NODE_SOCKET_API(float3, to_max)
1383 NODE_SOCKET_API(bool, use_clamp)
1384};
1385
1386class MapRangeNode : public ShaderNode {
1387 public:
1389 void expand(ShaderGraph *graph);
1390
1391 NODE_SOCKET_API(float, value)
1392 NODE_SOCKET_API(float, from_min)
1393 NODE_SOCKET_API(float, from_max)
1394 NODE_SOCKET_API(float, to_min)
1395 NODE_SOCKET_API(float, to_max)
1396 NODE_SOCKET_API(float, steps)
1398 NODE_SOCKET_API(bool, clamp)
1399};
1400
1401class ClampNode : public ShaderNode {
1402 public:
1404 void constant_fold(const ConstantFolder &folder);
1405 NODE_SOCKET_API(float, value)
1406 NODE_SOCKET_API(float, min)
1407 NODE_SOCKET_API(float, max)
1408 NODE_SOCKET_API(NodeClampType, clamp_type)
1409};
1410
1411class MathNode : public ShaderNode {
1412 public:
1414 void expand(ShaderGraph *graph);
1415 void constant_fold(const ConstantFolder &folder);
1416
1417 NODE_SOCKET_API(float, value1)
1418 NODE_SOCKET_API(float, value2)
1419 NODE_SOCKET_API(float, value3)
1420 NODE_SOCKET_API(NodeMathType, math_type)
1421 NODE_SOCKET_API(bool, use_clamp)
1422};
1423
1424class NormalNode : public ShaderNode {
1425 public:
1427
1428 NODE_SOCKET_API(float3, direction)
1429 NODE_SOCKET_API(float3, normal)
1430};
1431
1433 public:
1435 void constant_fold(const ConstantFolder &folder);
1436
1437 NODE_SOCKET_API(float3, vector1)
1438 NODE_SOCKET_API(float3, vector2)
1440 NODE_SOCKET_API(float, scale)
1442};
1443
1445 public:
1447
1449 NODE_SOCKET_API(bool, invert)
1451 NODE_SOCKET_API(float3, center)
1452 NODE_SOCKET_API(float3, axis)
1453 NODE_SOCKET_API(float, angle)
1454 NODE_SOCKET_API(float3, rotation)
1455};
1456
1466
1467class BumpNode : public ShaderNode {
1468 public:
1470 void constant_fold(const ConstantFolder &folder);
1472 {
1473 return true;
1474 }
1475 virtual int get_feature()
1476 {
1478 }
1479
1480 NODE_SOCKET_API(bool, invert)
1481 NODE_SOCKET_API(bool, use_object_space)
1482 NODE_SOCKET_API(float, height)
1483 NODE_SOCKET_API(float, sample_center)
1484 NODE_SOCKET_API(float, sample_x)
1485 NODE_SOCKET_API(float, sample_y)
1486 NODE_SOCKET_API(float3, normal)
1487 NODE_SOCKET_API(float, strength)
1488 NODE_SOCKET_API(float, distance)
1489};
1490
1491class CurvesNode : public ShaderNode {
1492 public:
1493 explicit CurvesNode(const NodeType *node_type);
1495
1497 NODE_SOCKET_API(float, min_x)
1498 NODE_SOCKET_API(float, max_x)
1499 NODE_SOCKET_API(float, fac)
1500 NODE_SOCKET_API(float3, value)
1501 NODE_SOCKET_API(bool, extrapolate)
1502
1503 protected:
1505 void constant_fold(const ConstantFolder &folder, ShaderInput *value_in);
1506 void compile(SVMCompiler &compiler, int type, ShaderInput *value_in, ShaderOutput *value_out);
1507 void compile(OSLCompiler &compiler, const char *name);
1508};
1509
1511 public:
1513 void constant_fold(const ConstantFolder &folder);
1514};
1515
1517 public:
1519 void constant_fold(const ConstantFolder &folder);
1520};
1521
1523 public:
1525 void constant_fold(const ConstantFolder &folder);
1526
1528 NODE_SOCKET_API(float, min_x)
1529 NODE_SOCKET_API(float, max_x)
1530 NODE_SOCKET_API(float, fac)
1531 NODE_SOCKET_API(float, value)
1532 NODE_SOCKET_API(bool, extrapolate)
1533};
1534
1535class RGBRampNode : public ShaderNode {
1536 public:
1538 void constant_fold(const ConstantFolder &folder);
1539
1542 NODE_SOCKET_API(float, fac)
1543 NODE_SOCKET_API(bool, interpolate)
1544};
1545
1547 public:
1549 NODE_SOCKET_API(float3, direction)
1550};
1551
1552class OSLNode final : public ShaderNode {
1553 public:
1554 static OSLNode *create(ShaderGraph *graph, size_t num_inputs, const OSLNode *from = NULL);
1555 ~OSLNode();
1556
1557 static void operator delete(void *ptr)
1558 {
1559 /* Override delete operator to silence new-delete-type-mismatch ASAN warnings
1560 * regarding size mismatch in the destructor. This is intentional as we allocate
1561 * extra space at the end of the node. */
1562 ::operator delete(ptr);
1563 }
1564 static void operator delete(void *, void *)
1565 {
1566 /* Deliberately empty placement delete operator, to avoid MSVC warning C4291. */
1567 }
1568
1569 ShaderNode *clone(ShaderGraph *graph) const;
1570
1571 char *input_default_value();
1572 void add_input(ustring name, SocketType::Type type, const int flags = 0);
1573 void add_output(ustring name, SocketType::Type type);
1574
1576
1577 bool has_surface_emission()
1578 {
1579 return has_emission;
1580 }
1581
1582 /* Ideally we could better detect this, but we can't query this now. */
1584 {
1585 return true;
1586 }
1588 {
1589 return true;
1590 }
1591 virtual int get_feature()
1592 {
1594 }
1595
1596 virtual bool equals(const ShaderNode & /*other*/)
1597 {
1598 return false;
1599 }
1600
1601 string filepath;
1604};
1605
1607 public:
1609 void attributes(Shader *shader, AttributeRequestSet *attributes);
1611 {
1612 return true;
1613 }
1615 {
1616 return true;
1617 }
1618
1620 NODE_SOCKET_API(ustring, attribute)
1621 NODE_SOCKET_API(float, strength)
1622 NODE_SOCKET_API(float3, color)
1623};
1624
1625class TangentNode : public ShaderNode {
1626 public:
1628 void attributes(Shader *shader, AttributeRequestSet *attributes);
1630 {
1631 return true;
1632 }
1634 {
1635 return true;
1636 }
1637
1640 NODE_SOCKET_API(ustring, attribute)
1641};
1642
1643class BevelNode : public ShaderNode {
1644 public:
1646 bool has_spatial_varying()
1647 {
1648 return true;
1649 }
1650 virtual int get_feature()
1651 {
1653 }
1654
1655 NODE_SOCKET_API(float, radius)
1656 NODE_SOCKET_API(float3, normal)
1657 NODE_SOCKET_API(int, samples)
1658};
1659
1661 public:
1663 void constant_fold(const ConstantFolder &folder);
1664 virtual int get_feature()
1665 {
1667 }
1668
1670 NODE_SOCKET_API(float, height)
1671 NODE_SOCKET_API(float, midlevel)
1672 NODE_SOCKET_API(float, scale)
1673 NODE_SOCKET_API(float3, normal)
1674};
1675
1677 public:
1679 void attributes(Shader *shader, AttributeRequestSet *attributes);
1681 {
1682 return true;
1683 }
1684 void constant_fold(const ConstantFolder &folder);
1685 virtual int get_feature()
1686 {
1688 }
1689
1691 NODE_SOCKET_API(ustring, attribute)
1693 NODE_SOCKET_API(float, midlevel)
1694 NODE_SOCKET_API(float, scale)
1695};
1696
1698
1699#endif /* __NODES_H__ */
NodeGaborType
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
virtual int get_feature()
bool has_spatial_varying()
bool has_attribute_dependency()
virtual int get_feature()
virtual int get_feature()
virtual bool equals(const ShaderNode &)
virtual bool has_bump()
virtual int get_feature()
ClosureType closure
virtual ClosureType get_closure_type()
BsdfBaseNode(const NodeType *node_type)
bool has_spatial_varying()
BsdfNode(const NodeType *node_type)
void compile(SVMCompiler &compiler, ShaderInput *bsdf_y, ShaderInput *bsdf_z, ShaderInput *data_y=nullptr, ShaderInput *data_z=nullptr, ShaderInput *data_w=nullptr)
virtual int get_feature()
bool has_spatial_varying()
void constant_fold(const ConstantFolder &folder)
float value_float
float3 value_point
float3 value_normal
float3 value_vector
ConvertNode(SocketType::Type from, SocketType::Type to, bool autoconvert=false)
float3 value_color
virtual int get_feature()
void constant_fold(const ConstantFolder &folder)
bool has_surface_emission()
bool has_volume_support()
virtual int get_feature()
bool from_auto_conversion
ImageParams image_params() const
virtual bool equals(const ShaderNode &other)
ShaderNode * clone(ShaderGraph *graph) const
void attributes(Shader *shader, AttributeRequestSet *attributes)
bool has_spatial_varying()
bool has_attribute_dependency()
ClosureType get_closure_type()
void attributes(Shader *shader, AttributeRequestSet *attributes)
void simplify_settings(Scene *scene)
bool has_attribute_dependency()
ClosureType get_closure_type()
bool has_attribute_dependency()
bool has_spatial_varying()
ShaderNode * clone(ShaderGraph *graph) const
ImageSlotTextureNode(const NodeType *node_type)
virtual bool equals(const ShaderNode &other)
ImageParams image_params() const
void attributes(Shader *shader, AttributeRequestSet *attributes)
void cull_tiles(Scene *scene, ShaderGraph *graph)
bool has_attribute_dependency()
virtual bool equals(const ShaderNode &other)
ShaderNode * clone(ShaderGraph *graph) const
void constant_fold(const ConstantFolder &folder)
bool has_attribute_dependency()
ClosureType get_closure_type()
void attributes(Shader *shader, AttributeRequestSet *attributes)
void simplify_settings(Scene *scene)
bool has_attribute_dependency()
bool has_spatial_varying()
string bytecode_hash
virtual bool equals(const ShaderNode &)
bool has_volume_support()
bool has_emission
bool has_spatial_varying()
string filepath
virtual int get_feature()
virtual void simplify_settings(Scene *scene)
virtual bool equals(const ShaderNode &)
virtual bool equals(const ShaderNode &)
bool has_attribute_dependency()
ImageParams image_params() const
virtual bool equals(const ShaderNode &other)
ShaderNode * clone(ShaderGraph *graph) const
void attributes(Shader *shader, AttributeRequestSet *attributes)
bool has_spatial_varying()
bool has_attribute_dependency()
bool has_attribute_dependency()
void simplify_settings(Scene *scene)
void attributes(Shader *shader, AttributeRequestSet *attributes)
void constant_fold(const ConstantFolder &folder)
bool has_surface_transparent()
ClosureType get_closure_type()
ShaderNodeSpecialType special_type
virtual bool equals(const ShaderNode &other)
virtual int get_feature()
virtual void constant_fold(const ConstantFolder &)
ClosureType get_closure_type()
void simplify_settings(Scene *scene)
float get_sun_size()
float get_sun_average_radiance()
ClosureType get_closure_type()
bool has_attribute_dependency()
bool has_spatial_varying()
int compile(SVMCompiler &compiler, ShaderInput *vector_in)
void compile_end(SVMCompiler &compiler, ShaderInput *vector_in, int vector_offset)
Transform compute_transform()
Projection projection
Mapping x_mapping
Mapping z_mapping
void compile(SVMCompiler &compiler, int offset_in, int offset_out)
Mapping y_mapping
int compile_begin(SVMCompiler &compiler, ShaderInput *vector_in)
TextureMapping tex_mapping
TextureNode(const NodeType *node_type)
bool has_attribute_dependency()
bool has_spatial_varying()
virtual int get_feature()
bool has_spatial_varying()
bool has_attribute_dependency()
bool has_spatial_varying()
bool has_attribute_dependency()
ClosureType closure
virtual bool has_volume_support()
virtual int get_feature()
virtual ClosureType get_closure_type()
virtual bool equals(const ShaderNode &)
virtual int get_feature()
local_group_size(16, 16) .push_constant(Type b
#define CCL_NAMESPACE_END
#define NULL
#define fmaxf(x, y)
#define NODE_SOCKET_API_STRUCT_MEMBER(type_, name, member)
Definition graph/node.h:76
#define NODE_SOCKET_API_ARRAY(type_, name)
Definition graph/node.h:63
#define NODE_SOCKET_API(type_, name)
Definition graph/node.h:55
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
Definition invert.h:9
ccl_gpu_kernel_postfix ccl_global KernelWorkTile * tiles
NodeClampType
NodeEnvironmentProjection
NodeMathType
NodeMapRangeType
NodeWaveBandsDirection
NodeMappingType
NodePrincipledHairModel
NodeNoiseType
NodeVectorTransformConvertSpace
NodeTangentAxis
NodePrincipledHairParametrization
NodeVoronoiFeature
@ NODE_VORONOI_SMOOTH_F1
NodeWaveType
NodeVoronoiDistanceMetric
NodeSkyType
NodeWaveProfile
NodeTexVoxelSpace
ClosureType
@ CLOSURE_HOLDOUT_ID
NodeVectorRotateType
NodeVectorTransformType
NodeImageProjection
NodeCombSepColorType
NodeGradientType
NodeTangentDirectionType
NodeVectorMathType
NodeWaveRingsDirection
NodeNormalMapSpace
#define KERNEL_FEATURE_NODE_BSDF
#define KERNEL_FEATURE_NODE_PRINCIPLED_HAIR
#define KERNEL_FEATURE_NODE_VORONOI_EXTRA
#define KERNEL_FEATURE_NODE_VOLUME
#define KERNEL_FEATURE_NODE_RAYTRACE
#define KERNEL_FEATURE_NODE_EMISSION
#define KERNEL_FEATURE_NODE_BUMP
#define R
#define vector3
#define SHADER_NODE_NO_CLONE_CLASS(type)
@ SHADER_SPECIAL_TYPE_IMAGE_SLOT
#define SHADER_NODE_CLASS(type)
#define SHADER_NODE_BASE_CLASS(type)
static const int steps
#define min(a, b)
Definition sort.c:32
bool equals(const Node &other) const
ImageAlphaType
InterpolationType
ExtensionType
PointerRNA * ptr
Definition wm_files.cc:4126