39#define TEXTURE_MAPPING_DEFINE(TextureNode) \
40 SOCKET_POINT(tex_mapping.translation, "Translation", zero_float3()); \
41 SOCKET_VECTOR(tex_mapping.rotation, "Rotation", zero_float3()); \
42 SOCKET_VECTOR(tex_mapping.scale, "Scale", one_float3()); \
44 SOCKET_VECTOR(tex_mapping.min, "Min", make_float3(-FLT_MAX, -FLT_MAX, -FLT_MAX)); \
45 SOCKET_VECTOR(tex_mapping.max, "Max", make_float3(FLT_MAX, FLT_MAX, FLT_MAX)); \
46 SOCKET_BOOLEAN(tex_mapping.use_minmax, "Use Min Max", false); \
48 static NodeEnum mapping_axis_enum; \
49 mapping_axis_enum.insert("none", TextureMapping::NONE); \
50 mapping_axis_enum.insert("x", TextureMapping::X); \
51 mapping_axis_enum.insert("y", TextureMapping::Y); \
52 mapping_axis_enum.insert("z", TextureMapping::Z); \
53 SOCKET_ENUM(tex_mapping.x_mapping, "x_mapping", mapping_axis_enum, TextureMapping::X); \
54 SOCKET_ENUM(tex_mapping.y_mapping, "y_mapping", mapping_axis_enum, TextureMapping::Y); \
55 SOCKET_ENUM(tex_mapping.z_mapping, "z_mapping", mapping_axis_enum, TextureMapping::Z); \
57 static NodeEnum mapping_type_enum; \
58 mapping_type_enum.insert("point", TextureMapping::POINT); \
59 mapping_type_enum.insert("texture", TextureMapping::TEXTURE); \
60 mapping_type_enum.insert("vector", TextureMapping::VECTOR); \
61 mapping_type_enum.insert("normal", TextureMapping::NORMAL); \
62 SOCKET_ENUM(tex_mapping.type, "Type", mapping_type_enum, TextureMapping::TEXTURE); \
64 static NodeEnum mapping_projection_enum; \
65 mapping_projection_enum.insert("flat", TextureMapping::FLAT); \
66 mapping_projection_enum.insert("cube", TextureMapping::CUBE); \
67 mapping_projection_enum.insert("tube", TextureMapping::TUBE); \
68 mapping_projection_enum.insert("sphere", TextureMapping::SPHERE); \
69 SOCKET_ENUM(tex_mapping.projection, "Projection", mapping_projection_enum, TextureMapping::FLAT);
112 mat = tmat * rmat * smat;
117 mat = tmat * rmat * smat;
160 compiler.
add_node(NODE_TEXTURE_MAPPING, offset_in, offset_out);
168 compiler.
add_node(NODE_MIN_MAX, offset_out, offset_out);
189 compile(compiler, offset_in, offset_out);
199 const int vector_offset)
254 SOCKET_FLOAT(projection_blend,
"Projection Blend", 0.0f);
283 params.animated = animated;
284 params.interpolation = interpolation;
285 params.extension = extension;
286 params.alpha_type = alpha_type;
287 params.colorspace = colorspace;
298 tiles.push_back_slow(1001);
311 if (
tiles.size() == 0) {
317 if (vector_in->
link) {
319 if (node->
type == UVMapNode::get_node_type()) {
321 attribute = uvmap->get_attribute();
323 else if (node->
type == TextureCoordinateNode::get_node_type()) {
333 unordered_set<int> used_tiles;
338 for (
Node *node : geom->get_used_shaders()) {
340 if (shader->
graph.get() == graph) {
348 if (used_tiles.count(
tile)) {
352 tiles.steal_data(new_tiles);
383 const ImageMetaData metadata =
handle.metadata();
386 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
389 if (compress_as_srgb) {
392 if (!alpha_out->
links.empty()) {
397 if (unassociate_alpha) {
405 if (
handle.num_tiles() == 0) {
406 num_nodes = -
handle.svm_slot();
421 for (
int i = 0;
i < num_nodes;
i++) {
425 if (2 *
i + 1 <
tiles.size()) {
427 node.
w =
handle.svm_slot(2 *
i + 1);
439 compiler.
add_node(NODE_TEX_IMAGE_BOX,
448 tex_mapping.compile_end(compiler, vector_in, vector_offset);
453 ShaderOutput *alpha_out =
output(
"Alpha");
462 const ImageMetaData metadata =
handle.metadata();
463 const bool is_float = metadata.
is_float();
465 const ustring known_colorspace = metadata.
colorspace;
467 if (
handle.svm_slot() == -1) {
469 "filename", filename, compress_as_srgb ?
u_colorspace_raw : known_colorspace);
478 const bool is_tiled = (filename.find(
"<UDIM>") != string::npos ||
479 filename.find(
"<UVTILE>") != string::npos) ||
483 compiler.
parameter(
this,
"projection_blend");
484 compiler.
parameter(
"compress_as_srgb", compress_as_srgb);
486 compiler.
parameter(
"unassociate_alpha", !alpha_out->
links.empty() && unassociate_alpha);
487 compiler.
parameter(
"is_float", is_float);
488 compiler.
parameter(
"is_tiled", is_tiled);
489 compiler.
parameter(
this,
"interpolation");
492 compiler.
add(
this,
"node_image_texture");
552 params.animated = animated;
553 params.interpolation = interpolation;
555 params.alpha_type = alpha_type;
556 params.colorspace = colorspace;
584 const ImageMetaData metadata =
handle.metadata();
587 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
590 if (compress_as_srgb) {
594 compiler.
add_node(NODE_TEX_ENVIRONMENT,
602 tex_mapping.compile_end(compiler, vector_in, vector_offset);
614 const ImageMetaData metadata =
handle.metadata();
615 const bool is_float = metadata.
is_float();
617 const ustring known_colorspace = metadata.
colorspace;
619 if (
handle.svm_slot() == -1) {
621 "filename", filename, compress_as_srgb ?
u_colorspace_raw : known_colorspace);
628 compiler.
parameter(
this,
"interpolation");
629 compiler.
parameter(
"compress_as_srgb", compress_as_srgb);
631 compiler.
parameter(
"is_float", is_float);
632 compiler.
add(
this,
"node_environment_texture");
654 return (1.0f + lam[0] *
expf(lam[1] /
cosf(theta))) *
655 (1.0f + lam[2] *
expf(lam[3] * gamma) + lam[4] *
cosf(gamma) *
cosf(gamma));
660 const float turbidity)
669 const float theta = spherical.
x;
670 const float phi = spherical.
y;
672 sunsky->
theta = theta;
675 const float theta2 = theta * theta;
676 const float theta3 = theta2 * theta;
677 const float T = turbidity;
678 const float T2 =
T *
T;
680 const float chi = (4.0f / 9.0f -
T / 120.0f) * (
M_PI_F - 2.0f * theta);
681 sunsky->
radiance_x = (4.0453f *
T - 4.9710f) *
tanf(chi) - 0.2155f *
T + 2.4192f;
684 sunsky->
radiance_y = (0.00166f * theta3 - 0.00375f * theta2 + 0.00209f * theta) *
T2 +
685 (-0.02903f * theta3 + 0.06377f * theta2 - 0.03202f * theta + 0.00394f) *
T +
686 (0.11693f * theta3 - 0.21196f * theta2 + 0.06052f * theta + 0.25886f);
688 sunsky->
radiance_z = (0.00275f * theta3 - 0.00610f * theta2 + 0.00317f * theta) *
T2 +
689 (-0.04214f * theta3 + 0.08970f * theta2 - 0.04153f * theta + 0.00516f) *
T +
690 (0.15346f * theta3 - 0.26756f * theta2 + 0.06670f * theta + 0.26688f);
692 sunsky->
config_x[0] = (0.1787f *
T - 1.4630f);
693 sunsky->
config_x[1] = (-0.3554f *
T + 0.4275f);
694 sunsky->
config_x[2] = (-0.0227f *
T + 5.3251f);
695 sunsky->
config_x[3] = (0.1206f *
T - 2.5771f);
696 sunsky->
config_x[4] = (-0.0670f *
T + 0.3703f);
698 sunsky->
config_y[0] = (-0.0193f *
T - 0.2592f);
699 sunsky->
config_y[1] = (-0.0665f *
T + 0.0008f);
700 sunsky->
config_y[2] = (-0.0004f *
T + 0.2125f);
701 sunsky->
config_y[3] = (-0.0641f *
T - 0.8989f);
702 sunsky->
config_y[4] = (-0.0033f *
T + 0.0452f);
704 sunsky->
config_z[0] = (-0.0167f *
T - 0.2608f);
705 sunsky->
config_z[1] = (-0.0950f *
T + 0.0092f);
706 sunsky->
config_z[2] = (-0.0079f *
T + 0.2102f);
707 sunsky->
config_z[3] = (-0.0441f *
T - 1.6537f);
708 sunsky->
config_z[4] = (-0.0109f *
T + 0.0529f);
711 for (
int i = 5;
i < 9;
i++) {
726 const float ground_albedo)
730 float theta = spherical.
x;
731 const float phi = spherical.
y;
734 turbidity =
clamp(turbidity, 0.0f, 10.0f);
739 sunsky->
theta = theta;
742 const float solarElevation =
M_PI_2_F - theta;
747 (
double)turbidity, (
double)ground_albedo, (
double)solarElevation);
750 for (
int i = 0;
i < 9; ++
i) {
765 bool multiple_scattering,
767 const float sun_size,
768 const float sun_intensity,
769 const float sun_elevation,
770 const float sun_rotation,
771 const float altitude,
772 const float air_density,
773 const float aerosol_density,
774 const float ozone_density)
777 float pixel_bottom[3];
780 if (multiple_scattering) {
792 sun_elevation, sun_size, altitude, air_density, aerosol_density, pixel_bottom, pixel_top);
838 const float3 pixel_bottom =
make_float3(pix_bottom[0], pix_bottom[1], pix_bottom[2]);
840 float3 xyz =
interp(pixel_bottom, pixel_top, 0.5f) * sun_intensity;
845 float sun_contribution =
average(xyz) *
sqr(angular_diameter);
847 const float first_point = 0.8f / 180.0f *
M_PI_F;
848 const float second_point = 1.0f / 180.0f *
M_PI_F;
850 if (angular_diameter < first_point) {
851 sun_contribution *= 1.0f;
853 else if (angular_diameter < second_point) {
854 const float diff = angular_diameter - first_point;
855 const float slope = (0.8f - 1.0f) / (second_point - first_point);
856 sun_contribution *= 1.0f + slope *
diff;
859 const float diff = angular_diameter - 1.0f / 180.0f *
M_PI_F;
860 const float slope = (0.45f - 0.8f) / (third_point - second_point);
861 sun_contribution *= 0.8f + slope *
diff;
864 return sun_contribution;
899SkyTextureNode::SkyTextureNode() :
TextureNode(get_node_type()) {}
905 float new_sun_elevation = sun_elevation;
906 float new_sun_rotation = sun_rotation;
916 new_sun_elevation =
copysignf(
M_PI_F, new_sun_elevation) - new_sun_elevation;
917 new_sun_rotation +=
M_PI_F;
923 if (new_sun_rotation < 0.0f) {
926 new_sun_rotation =
M_2PI_F - new_sun_rotation;
928 sun_elevation = new_sun_elevation;
929 sun_rotation = new_sun_rotation;
964 unique_ptr<SkyLoader> loader = make_unique<SkyLoader>(sky_type ==
975 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
1028 tex_mapping.compile_end(compiler, vector_in, vector_offset);
1062 unique_ptr<SkyLoader> loader = make_unique<SkyLoader>(sky_type ==
1084 compiler.
add(
this,
"node_sky_texture");
1113GradientTextureNode::GradientTextureNode() :
TextureNode(get_node_type()) {}
1117 ShaderInput *vector_in =
input(
"Vector");
1118 ShaderOutput *color_out =
output(
"Color");
1119 ShaderOutput *fac_out =
output(
"Fac");
1121 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
1123 compiler.
add_node(NODE_TEX_GRADIENT,
1129 tex_mapping.compile_end(compiler, vector_in, vector_offset);
1136 compiler.
parameter(
this,
"gradient_type");
1137 compiler.
add(
this,
"node_gradient_texture");
1149 dimensions_enum.
insert(
"1D", 1);
1150 dimensions_enum.
insert(
"2D", 2);
1151 dimensions_enum.
insert(
"3D", 3);
1152 dimensions_enum.
insert(
"4D", 4);
1153 SOCKET_ENUM(dimensions,
"Dimensions", dimensions_enum, 3);
1181NoiseTextureNode::NoiseTextureNode() :
TextureNode(get_node_type()) {}
1185 ShaderInput *vector_in =
input(
"Vector");
1186 ShaderInput *w_in =
input(
"W");
1187 ShaderInput *scale_in =
input(
"Scale");
1188 ShaderInput *detail_in =
input(
"Detail");
1189 ShaderInput *roughness_in =
input(
"Roughness");
1190 ShaderInput *lacunarity_in =
input(
"Lacunarity");
1191 ShaderInput *offset_in =
input(
"Offset");
1192 ShaderInput *gain_in =
input(
"Gain");
1193 ShaderInput *distortion_in =
input(
"Distortion");
1194 ShaderOutput *fac_out =
output(
"Fac");
1195 ShaderOutput *color_out =
output(
"Color");
1197 const int vector_stack_offset =
tex_mapping.compile_begin(compiler, vector_in);
1212 vector_stack_offset, w_stack_offset, scale_stack_offset, detail_stack_offset),
1214 roughness_stack_offset, lacunarity_stack_offset, offset_stack_offset, gain_stack_offset),
1215 compiler.
encode_uchar4(distortion_stack_offset, fac_stack_offset, color_stack_offset));
1226 tex_mapping.compile_end(compiler, vector_in, vector_stack_offset);
1234 compiler.
parameter(
this,
"use_normalize");
1235 compiler.
add(
this,
"node_noise_texture");
1265GaborTextureNode::GaborTextureNode() :
TextureNode(get_node_type()) {}
1269 ShaderInput *vector_in =
input(
"Vector");
1270 ShaderInput *scale_in =
input(
"Scale");
1271 ShaderInput *frequency_in =
input(
"Frequency");
1272 ShaderInput *anisotropy_in =
input(
"Anisotropy");
1273 ShaderInput *orientation_2d_in =
input(
"Orientation 2D");
1274 ShaderInput *orientation_3d_in =
input(
"Orientation 3D");
1276 ShaderOutput *value_out =
output(
"Value");
1277 ShaderOutput *phase_out =
output(
"Phase");
1278 ShaderOutput *intensity_out =
output(
"Intensity");
1280 const int vector_stack_offset =
tex_mapping.compile_begin(compiler, vector_in);
1285 const int orientation_3d_stack_offset = compiler.
stack_assign(orientation_3d_in);
1296 frequency_stack_offset,
1297 anisotropy_stack_offset),
1298 compiler.
encode_uchar4(orientation_2d_stack_offset, orientation_3d_stack_offset));
1301 compiler.
encode_uchar4(value_stack_offset, phase_stack_offset, intensity_stack_offset),
1307 tex_mapping.compile_end(compiler, vector_in, vector_stack_offset);
1314 compiler.
add(
this,
"node_gabor_texture");
1326 dimensions_enum.
insert(
"1D", 1);
1327 dimensions_enum.
insert(
"2D", 2);
1328 dimensions_enum.
insert(
"3D", 3);
1329 dimensions_enum.
insert(
"4D", 4);
1330 SOCKET_ENUM(dimensions,
"Dimensions", dimensions_enum, 3);
1368VoronoiTextureNode::VoronoiTextureNode() :
TextureNode(get_node_type()) {}
1372 ShaderInput *vector_in =
input(
"Vector");
1373 ShaderInput *w_in =
input(
"W");
1374 ShaderInput *scale_in =
input(
"Scale");
1375 ShaderInput *detail_in =
input(
"Detail");
1376 ShaderInput *roughness_in =
input(
"Roughness");
1377 ShaderInput *lacunarity_in =
input(
"Lacunarity");
1378 ShaderInput *smoothness_in =
input(
"Smoothness");
1379 ShaderInput *exponent_in =
input(
"Exponent");
1380 ShaderInput *randomness_in =
input(
"Randomness");
1382 ShaderOutput *distance_out =
output(
"Distance");
1383 ShaderOutput *color_out =
output(
"Color");
1384 ShaderOutput *position_out =
output(
"Position");
1385 ShaderOutput *w_out =
output(
"W");
1386 ShaderOutput *radius_out =
output(
"Radius");
1388 const int vector_stack_offset =
tex_mapping.compile_begin(compiler, vector_in);
1403 compiler.
add_node(NODE_TEX_VORONOI, dimensions, feature, metric);
1406 vector_stack_offset, w_in_stack_offset, scale_stack_offset, detail_stack_offset),
1408 lacunarity_stack_offset,
1409 smoothness_stack_offset,
1410 exponent_stack_offset),
1412 randomness_stack_offset, use_normalize, distance_stack_offset, color_stack_offset),
1413 compiler.
encode_uchar4(position_stack_offset, w_out_stack_offset, radius_stack_offset));
1421 tex_mapping.compile_end(compiler, vector_in, vector_stack_offset);
1431 compiler.
parameter(
this,
"use_normalize");
1432 compiler.
add(
this,
"node_voronoi_texture");
1454IESLightNode::IESLightNode() :
TextureNode(get_node_type())
1456 light_manager =
nullptr;
1464 node->light_manager =
nullptr;
1472 if (light_manager) {
1473 light_manager->remove_ies(slot);
1477void IESLightNode::get_slot()
1486 slot = light_manager->add_ies(ies.string());
1496 ShaderInput *strength_in =
input(
"Strength");
1497 ShaderInput *vector_in =
input(
"Vector");
1498 ShaderOutput *fac_out =
output(
"Fac");
1500 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
1510 tex_mapping.compile_end(compiler, vector_in, vector_offset);
1521 compiler.
add(
this,
"node_ies_light");
1531 dimensions_enum.
insert(
"1D", 1);
1532 dimensions_enum.
insert(
"2D", 2);
1533 dimensions_enum.
insert(
"3D", 3);
1534 dimensions_enum.
insert(
"4D", 4);
1535 SOCKET_ENUM(dimensions,
"Dimensions", dimensions_enum, 3);
1546WhiteNoiseTextureNode::WhiteNoiseTextureNode() :
ShaderNode(get_node_type()) {}
1550 ShaderInput *vector_in =
input(
"Vector");
1551 ShaderInput *w_in =
input(
"W");
1552 ShaderOutput *value_out =
output(
"Value");
1553 ShaderOutput *color_out =
output(
"Color");
1555 const int vector_stack_offset = compiler.
stack_assign(vector_in);
1556 const int w_stack_offset = compiler.
stack_assign(w_in);
1557 const int value_stack_offset = compiler.
stack_assign(value_out);
1558 const int color_stack_offset = compiler.
stack_assign(color_out);
1560 compiler.
add_node(NODE_TEX_WHITE_NOISE,
1562 compiler.
encode_uchar4(vector_stack_offset, w_stack_offset),
1563 compiler.
encode_uchar4(value_stack_offset, color_stack_offset));
1569 compiler.
add(
this,
"node_white_noise_texture");
1585 static NodeEnum bands_direction_enum;
1593 static NodeEnum rings_direction_enum;
1620WaveTextureNode::WaveTextureNode() :
TextureNode(get_node_type()) {}
1624 ShaderInput *vector_in =
input(
"Vector");
1625 ShaderInput *scale_in =
input(
"Scale");
1626 ShaderInput *distortion_in =
input(
"Distortion");
1627 ShaderInput *detail_in =
input(
"Detail");
1628 ShaderInput *dscale_in =
input(
"Detail Scale");
1629 ShaderInput *droughness_in =
input(
"Detail Roughness");
1630 ShaderInput *phase_in =
input(
"Phase Offset");
1631 ShaderOutput *color_out =
output(
"Color");
1632 ShaderOutput *fac_out =
output(
"Fac");
1634 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
1646 compiler.
encode_uchar4(wave_type, bands_direction, rings_direction, profile),
1647 compiler.
encode_uchar4(vector_offset, scale_ofs, distortion_ofs),
1648 compiler.
encode_uchar4(detail_ofs, dscale_ofs, droughness_ofs, phase_ofs));
1660 tex_mapping.compile_end(compiler, vector_in, vector_offset);
1668 compiler.
parameter(
this,
"bands_direction");
1669 compiler.
parameter(
this,
"rings_direction");
1672 compiler.
add(
this,
"node_wave_texture");
1695MagicTextureNode::MagicTextureNode() :
TextureNode(get_node_type()) {}
1699 ShaderInput *vector_in =
input(
"Vector");
1700 ShaderInput *scale_in =
input(
"Scale");
1701 ShaderInput *distortion_in =
input(
"Distortion");
1702 ShaderOutput *color_out =
output(
"Color");
1703 ShaderOutput *fac_out =
output(
"Fac");
1705 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
1716 tex_mapping.compile_end(compiler, vector_in, vector_offset);
1724 compiler.
add(
this,
"node_magic_texture");
1746CheckerTextureNode::CheckerTextureNode() :
TextureNode(get_node_type()) {}
1750 ShaderInput *vector_in =
input(
"Vector");
1751 ShaderInput *color1_in =
input(
"Color1");
1752 ShaderInput *color2_in =
input(
"Color2");
1753 ShaderInput *scale_in =
input(
"Scale");
1755 ShaderOutput *color_out =
output(
"Color");
1756 ShaderOutput *fac_out =
output(
"Fac");
1758 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
1760 compiler.
add_node(NODE_TEX_CHECKER,
1769 tex_mapping.compile_end(compiler, vector_in, vector_offset);
1776 compiler.
add(
this,
"node_checker_texture");
1788 SOCKET_INT(offset_frequency,
"Offset Frequency", 2);
1790 SOCKET_INT(squash_frequency,
"Squash Frequency", 2);
1810BrickTextureNode::BrickTextureNode() :
TextureNode(get_node_type()) {}
1814 ShaderInput *vector_in =
input(
"Vector");
1815 ShaderInput *color1_in =
input(
"Color1");
1816 ShaderInput *color2_in =
input(
"Color2");
1817 ShaderInput *mortar_in =
input(
"Mortar");
1818 ShaderInput *scale_in =
input(
"Scale");
1819 ShaderInput *mortar_size_in =
input(
"Mortar Size");
1820 ShaderInput *mortar_smooth_in =
input(
"Mortar Smooth");
1821 ShaderInput *bias_in =
input(
"Bias");
1822 ShaderInput *brick_width_in =
input(
"Brick Width");
1823 ShaderInput *row_height_in =
input(
"Row Height");
1825 ShaderOutput *color_out =
output(
"Color");
1826 ShaderOutput *fac_out =
output(
"Fac");
1828 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
1857 tex_mapping.compile_end(compiler, vector_in, vector_offset);
1865 compiler.
parameter(
this,
"offset_frequency");
1867 compiler.
parameter(
this,
"squash_frequency");
1868 compiler.
add(
this,
"node_brick_texture");
1887NormalNode::NormalNode() :
ShaderNode(get_node_type()) {}
1891 ShaderInput *normal_in =
input(
"Normal");
1892 ShaderOutput *normal_out =
output(
"Normal");
1893 ShaderOutput *dot_out =
output(
"Dot");
1906 compiler.
add(
this,
"node_normal");
1932MappingNode::MappingNode() :
ShaderNode(get_node_type()) {}
1953 const int vector_stack_offset = compiler.
stack_assign(vector_in);
1954 const int location_stack_offset = compiler.
stack_assign(location_in);
1955 const int rotation_stack_offset = compiler.
stack_assign(rotation_in);
1956 const int scale_stack_offset = compiler.
stack_assign(scale_in);
1957 const int result_stack_offset = compiler.
stack_assign(vector_out);
1963 vector_stack_offset, location_stack_offset, rotation_stack_offset, scale_stack_offset),
1964 result_stack_offset);
1969 compiler.
parameter(
this,
"mapping_type");
1970 compiler.
add(
this,
"node_mapping");
1985RGBToBWNode::RGBToBWNode() :
ShaderNode(get_node_type()) {}
2005 compiler.
add(
this,
"node_rgb_to_bw");
2010const NodeType *ConvertNode::node_types[ConvertNode::MAX_TYPE][ConvertNode::MAX_TYPE];
2011bool ConvertNode::initialized = ConvertNode::register_types();
2015 return make_unique<ConvertNode>(
type->inputs[0].type,
type->outputs[0].type);
2018bool ConvertNode::register_types()
2020 const int num_types = 8;
2030 for (
size_t i = 0;
i < num_types;
i++) {
2033 const ustring from_value_name(
"value_" + from_name.string());
2035 for (
size_t j = 0; j < num_types; j++) {
2038 const ustring to_value_name(
"value_" + to_name.string());
2040 const string node_name =
"convert_" + from_name.string() +
"_to_" + to_name.string();
2043 type->register_input(from_value_name,
2051 type->register_output(to_value_name, to_value_name, to);
2056 node_types[from][to] =
type;
2072 else if (autoconvert) {
2083 value_string(other.value_string)
2136 if (prev->type == node_types[to][from]) {
2224 compiler.
add(
this,
"node_convert_from_float");
2227 compiler.
add(
this,
"node_convert_from_int");
2230 compiler.
add(
this,
"node_convert_from_color");
2233 compiler.
add(
this,
"node_convert_from_vector");
2236 compiler.
add(
this,
"node_convert_from_point");
2239 compiler.
add(
this,
"node_convert_from_normal");
2257 return (normal_in && normal_in->
link &&
2275 if (color_in->
link) {
2279 compiler.
add_node(NODE_CLOSURE_SET_WEIGHT, color);
2288 compiler.
add_node(NODE_CLOSURE_BSDF,
2297 compiler.
add_node(normal_offset, data_y_offset, data_z_offset, data_w_offset);
2302 compile(compiler,
nullptr,
nullptr);
2351MetallicBsdfNode::MetallicBsdfNode() :
BsdfNode(get_node_type())
2361 return (!anisotropy_input->
link &&
fabsf(anisotropy) <= 1e-4f);
2393 const int thin_film_thickness_offset = compiler.
stack_assign(
input(
"Thin Film Thickness"));
2403 compiler.
add_node(NODE_CLOSURE_BSDF,
2413 base_color_ior_offset, edge_tint_k_offset, rotation_offset, tangent_offset),
2414 compiler.
encode_uchar4(distribution, thin_film_thickness_offset, thin_film_ior_offset));
2419 compiler.
parameter(
this,
"distribution");
2420 compiler.
parameter(
this,
"fresnel_type");
2421 compiler.
add(
this,
"node_metallic_bsdf");
2452GlossyBsdfNode::GlossyBsdfNode() :
BsdfNode(get_node_type())
2462 return (!anisotropy_input->
link &&
fabsf(anisotropy) <= 1e-4f);
2490 tangent = compiler.
is_linked(tangent) ? tangent :
nullptr;
2496 input(
"Anisotropy"),
2503 compiler,
input(
"Roughness"),
input(
"Anisotropy"),
input(
"Rotation"),
nullptr, tangent);
2509 compiler.
parameter(
this,
"distribution");
2510 compiler.
add(
this,
"node_glossy_bsdf");
2540GlassBsdfNode::GlassBsdfNode() :
BsdfNode(get_node_type())
2552 input(
"Thin Film Thickness"),
2553 input(
"Thin Film IOR"));
2558 compiler.
parameter(
this,
"distribution");
2559 compiler.
add(
this,
"node_glass_bsdf");
2586RefractionBsdfNode::RefractionBsdfNode() :
BsdfNode(get_node_type())
2600 compiler.
parameter(
this,
"distribution");
2601 compiler.
add(
this,
"node_refraction_bsdf");
2626ToonBsdfNode::ToonBsdfNode() :
BsdfNode(get_node_type())
2641 compiler.
add(
this,
"node_toon_bsdf");
2665SheenBsdfNode::SheenBsdfNode() :
BsdfNode(get_node_type())
2678 compiler.
parameter(
this,
"distribution");
2679 compiler.
add(
this,
"node_sheen_bsdf");
2698DiffuseBsdfNode::DiffuseBsdfNode() :
BsdfNode(get_node_type())
2710 compiler.
add(
this,
"node_diffuse_bsdf");
2724 static NodeEnum subsurface_method_enum;
2729 "Subsurface Method",
2730 subsurface_method_enum,
2746 SOCKET_IN_FLOAT(subsurface_anisotropy,
"Subsurface Anisotropy", 0.0f);
2779PrincipledBsdfNode::PrincipledBsdfNode() :
BsdfBaseNode(get_node_type())
2836 return (emission_color_in->
link !=
nullptr ||
2846 (subsurface_scale_in->
link !=
nullptr || subsurface_scale != 0.0f);
2852 if (weight_in ==
nullptr) {
2855 if (weight_in->
link !=
nullptr) {
2866 if (!tangent_in->
link) {
2887 input(
"Transmission Weight"), 0.0f);
2889 input(
"Diffuse Roughness"), 0.0f);
2891 input(
"Specular IOR Level"), 0.5f);
2915 input(
"Subsurface Anisotropy"), 0.0f);
2955 thin_film_thickness_offset = compiler.
stack_assign(
input(
"Thin Film Thickness"));
2968 compiler.
encode_uchar4(base_color_offset, metallic_offset, alpha_offset, coat_normal_offset),
2970 distribution, diffuse_roughness_offset, specular_ior_level_offset, specular_tint_offset),
2972 emission_color_offset,
2974 thin_film_thickness_offset));
2979 sheen_weight_offset,
2980 transmission_weight_offset),
2982 coat_roughness_offset, coat_ior_offset, coat_tint_offset, subsurface_method),
2984 subsurface_scale_offset,
2985 subsurface_ior_offset,
2986 subsurface_anisotropy_offset),
2988 sheen_roughness_offset, sheen_tint_offset, anisotropic_rotation_offset, tangent_offset));
2991 compiler.
add_node(thin_film_ior_offset,
2999 compiler.
parameter(
this,
"distribution");
3000 compiler.
parameter(
this,
"subsurface_method");
3001 compiler.
add(
this,
"node_principled_bsdf");
3024TranslucentBsdfNode::TranslucentBsdfNode() :
BsdfNode(get_node_type())
3036 compiler.
add(
this,
"node_translucent_bsdf");
3053TransparentBsdfNode::TransparentBsdfNode() :
BsdfNode(get_node_type())
3065 compiler.
add(
this,
"node_transparent_bsdf");
3085RayPortalBsdfNode::RayPortalBsdfNode() :
BsdfNode(get_node_type())
3097 compiler.
add(
this,
"node_ray_portal_bsdf");
3128SubsurfaceScatteringNode::SubsurfaceScatteringNode() :
BsdfNode(get_node_type())
3140 input(
"Anisotropy"),
3141 input(
"Roughness"));
3148 compiler.
add(
this,
"node_subsurface_scattering");
3155 return (normal_in->
link &&
3175EmissionNode::EmissionNode() :
ShaderNode(get_node_type()) {}
3179 ShaderInput *color_in =
input(
"Color");
3180 ShaderInput *strength_in =
input(
"Strength");
3184 if (color_in->
link || strength_in->
link) {
3185 compiler.
add_node(NODE_EMISSION_WEIGHT,
3191 compiler.
add_node(NODE_CLOSURE_SET_WEIGHT, color * strength);
3199 compiler.
add(
this,
"node_emission");
3207 if ((!color_in->
link && color ==
zero_float3()) || (!strength_in->
link && strength == 0.0f)) {
3227BackgroundNode::BackgroundNode() :
ShaderNode(get_node_type()) {}
3231 ShaderInput *color_in =
input(
"Color");
3232 ShaderInput *strength_in =
input(
"Strength");
3236 if (color_in->
link || strength_in->
link) {
3237 compiler.
add_node(NODE_EMISSION_WEIGHT,
3243 compiler.
add_node(NODE_CLOSURE_SET_WEIGHT, color * strength);
3251 compiler.
add(
this,
"node_background");
3259 if ((!color_in->
link && color ==
zero_float3()) || (!strength_in->
link && strength == 0.0f)) {
3278HoldoutNode::HoldoutNode() :
ShaderNode(get_node_type()) {}
3284 compiler.
add_node(NODE_CLOSURE_SET_WEIGHT, value);
3290 compiler.
add(
this,
"node_holdout");
3314AmbientOcclusionNode::AmbientOcclusionNode() :
ShaderNode(get_node_type()) {}
3318 ShaderInput *color_in =
input(
"Color");
3319 ShaderInput *distance_in =
input(
"Distance");
3320 ShaderInput *normal_in =
input(
"Normal");
3321 ShaderOutput *color_out =
output(
"Color");
3322 ShaderOutput *ao_out =
output(
"AO");
3330 compiler.
add_node(NODE_AMBIENT_OCCLUSION,
3346 compiler.
add(
this,
"node_ambient_occlusion");
3363 if (color_in->
link) {
3367 compiler.
add_node(NODE_CLOSURE_SET_WEIGHT, color);
3376 if (param2 ==
nullptr) {
3379 compiler.
add_node(NODE_CLOSURE_VOLUME,
3387 compiler.
add_node(NODE_CLOSURE_VOLUME,
3396 compile(compiler,
nullptr,
nullptr,
nullptr);
3419AbsorptionVolumeNode::AbsorptionVolumeNode() :
VolumeNode(get_node_type())
3431 compiler.
add(
this,
"node_absorption_volume");
3502 compiler.
add(
this,
"node_scatter_volume");
3535VolumeCoefficientsNode::VolumeCoefficientsNode() :
ScatterVolumeNode(get_node_type())
3543 ShaderInput *param1 =
nullptr;
3544 ShaderInput *param2 =
nullptr;
3548 param1 =
input(
"Anisotropy");
3551 param1 =
input(
"IOR");
3552 param2 =
input(
"Backscatter");
3557 param1 =
input(
"Anisotropy");
3558 param2 =
input(
"Alpha");
3561 param1 =
input(
"Diameter");
3567 ShaderInput *coeffs_in =
input(
"Scatter Coefficients");
3568 ShaderInput *absorption_coeffs_in =
input(
"Absorption Coefficients");
3569 ShaderInput *emission_coeffs_in =
input(
"Emission Coefficients");
3571 if (coeffs_in->
link) {
3575 compiler.
add_node(NODE_CLOSURE_SET_WEIGHT, scatter_coeffs);
3580 if (param2 ==
nullptr) {
3583 compiler.
add_node(NODE_VOLUME_COEFFICIENTS,
3594 compiler.
add_node(NODE_VOLUME_COEFFICIENTS,
3607 compiler.
add(
this,
"node_volume_coefficients");
3618 SOCKET_IN_STRING(temperature_attribute,
"Temperature Attribute", ustring());
3636PrincipledVolumeNode::PrincipledVolumeNode() :
VolumeNode(get_node_type())
3639 density_attribute = ustring(
"density");
3640 temperature_attribute = ustring(
"temperature");
3649 if (density_in->
link || density > 0.0f) {
3654 if (blackbody_in->
link || blackbody_intensity > 0.0f) {
3655 attributes->add_standard(temperature_attribute);
3676 if (color_in->
link) {
3680 compiler.
add_node(NODE_CLOSURE_SET_WEIGHT, color);
3683 compiler.
add_node(NODE_PRINCIPLED_VOLUME,
3703 compiler.
add_node(attr_density, attr_color, attr_temperature);
3709 density_attribute = ustring(
"geom:" + density_attribute.string());
3712 color_attribute = ustring(
"geom:" + color_attribute.string());
3715 temperature_attribute = ustring(
"geom:" + temperature_attribute.string());
3718 compiler.
add(
this,
"node_principled_volume");
3734 static NodeEnum parametrization_enum;
3747 absorption_coefficient,
"Absorption Coefficient",
make_float3(0.245531f, 0.52f, 1.365f));
3772PrincipledHairBsdfNode::PrincipledHairBsdfNode() :
BsdfBaseNode(get_node_type())
3781 if (aspect_ratio != 1.0f ||
input(
"Aspect Ratio")->link) {
3795 if (!
input(
"Random")->link) {
3829 const int absorption_coefficient_ofs = compiler.
stack_assign(
input(
"Absorption Coefficient"));
3861 compiler.
encode_uchar4(offset_ofs, ior_ofs, color_ofs, parametrization),
3867 tint_ofs, melanin_ofs, melanin_redness_ofs, absorption_coefficient_ofs),
3884 compiler.
encode_uchar4(coat_ofs, random_in_ofs, random_color_ofs, radial_roughness_ofs),
3904 compiler.
parameter(
this,
"parametrization");
3905 compiler.
add(
this,
"node_principled_hair_bsdf");
3931HairBsdfNode::HairBsdfNode() :
BsdfNode(get_node_type())
3940 ShaderInput *tangent =
input(
"Tangent");
3941 tangent = compiler.
is_linked(tangent) ? tangent :
nullptr;
3944 compiler,
input(
"RoughnessU"),
input(
"RoughnessV"),
input(
"Offset"),
nullptr, tangent);
3950 compiler.
add(
this,
"node_hair_bsdf");
3972GeometryNode::GeometryNode() :
ShaderNode(get_node_type())
3980 if (!
output(
"Tangent")->links.empty()) {
3983 if (!
output(
"Pointiness")->links.empty()) {
3986 if (!
output(
"Random Per Island")->links.empty()) {
4001 geom_node = NODE_GEOMETRY_BUMP_DX;
4002 attr_node = NODE_ATTR_BUMP_DX;
4005 geom_node = NODE_GEOMETRY_BUMP_DY;
4006 attr_node = NODE_ATTR_BUMP_DY;
4010 if (!
out->links.empty()) {
4016 if (!
out->links.empty()) {
4022 if (!
out->links.empty()) {
4028 if (!
out->links.empty()) {
4034 if (!
out->links.empty()) {
4040 if (!
out->links.empty()) {
4046 if (!
out->links.empty()) {
4051 if (!
out->links.empty()) {
4064 if (!
out->links.empty()) {
4080 compiler.
parameter(
"bump_offset",
"dx");
4083 compiler.
parameter(
"bump_offset",
"dy");
4086 compiler.
parameter(
"bump_offset",
"center");
4090 compiler.
add(
this,
"node_geometry");
4114TextureCoordinateNode::TextureCoordinateNode() :
ShaderNode(get_node_type()) {}
4120 if (!
output(
"Generated")->links.empty()) {
4123 if (!
output(
"UV")->links.empty()) {
4131 if (!
output(
"Generated")->links.empty()) {
4148 texco_node = NODE_TEX_COORD_BUMP_DX;
4149 attr_node = NODE_ATTR_BUMP_DX;
4150 geom_node = NODE_GEOMETRY_BUMP_DX;
4153 texco_node = NODE_TEX_COORD_BUMP_DY;
4154 attr_node = NODE_ATTR_BUMP_DY;
4155 geom_node = NODE_GEOMETRY_BUMP_DY;
4159 if (!
out->links.empty()) {
4189 if (!
out->links.empty()) {
4197 if (!
out->links.empty()) {
4215 if (!
out->links.empty()) {
4220 if (use_transform) {
4229 if (!
out->links.empty()) {
4237 if (!
out->links.empty()) {
4245 if (!
out->links.empty()) {
4262 compiler.
parameter(
"bump_offset",
"dx");
4265 compiler.
parameter(
"bump_offset",
"dy");
4268 compiler.
parameter(
"bump_offset",
"center");
4273 compiler.
parameter(
"is_background",
true);
4278 compiler.
parameter(
this,
"use_transform");
4280 compiler.
parameter(
"object_itfm", ob_itfm);
4284 compiler.
add(
this,
"node_texture_coordinate");
4301UVMapNode::UVMapNode() :
ShaderNode(get_node_type()) {}
4307 if (!
output(
"UV")->links.empty()) {
4308 if (!attribute.empty()) {
4329 texco_node = NODE_TEX_COORD_BUMP_DX;
4330 attr_node = NODE_ATTR_BUMP_DX;
4333 texco_node = NODE_TEX_COORD_BUMP_DY;
4334 attr_node = NODE_ATTR_BUMP_DY;
4337 if (!
out->links.empty()) {
4345 if (!attribute.empty()) {
4364 compiler.
parameter(
"bump_offset",
"dx");
4367 compiler.
parameter(
"bump_offset",
"dy");
4370 compiler.
parameter(
"bump_offset",
"center");
4376 compiler.
add(
this,
"node_uv_map");
4404LightPathNode::LightPathNode() :
ShaderNode(get_node_type())
4414 if (!
out->links.empty()) {
4419 if (!
out->links.empty()) {
4424 if (!
out->links.empty()) {
4429 if (!
out->links.empty()) {
4434 if (!
out->links.empty()) {
4439 if (!
out->links.empty()) {
4444 if (!
out->links.empty()) {
4449 if (!
out->links.empty()) {
4454 if (!
out->links.empty()) {
4459 if (!
out->links.empty()) {
4464 if (!
out->links.empty()) {
4469 if (!
out->links.empty()) {
4474 if (!
out->links.empty()) {
4479 if (!
out->links.empty()) {
4484 if (!
out->links.empty()) {
4491 compiler.
add(
this,
"node_light_path");
4510LightFalloffNode::LightFalloffNode() :
ShaderNode(get_node_type()) {}
4514 ShaderInput *strength_in =
input(
"Strength");
4515 ShaderInput *smooth_in =
input(
"Smooth");
4517 ShaderOutput *
out =
output(
"Quadratic");
4518 if (!
out->links.empty()) {
4519 compiler.
add_node(NODE_LIGHT_FALLOFF,
4527 if (!
out->links.empty()) {
4528 compiler.
add_node(NODE_LIGHT_FALLOFF,
4536 if (!
out->links.empty()) {
4537 compiler.
add_node(NODE_LIGHT_FALLOFF,
4547 compiler.
add(
this,
"node_light_falloff");
4566ObjectInfoNode::ObjectInfoNode() :
ShaderNode(get_node_type()) {}
4571 if (!
out->links.empty()) {
4576 if (!
out->links.empty()) {
4581 if (!
out->links.empty()) {
4586 if (!
out->links.empty()) {
4591 if (!
out->links.empty()) {
4596 if (!
out->links.empty()) {
4603 compiler.
add(
this,
"node_object_info");
4618 SOCKET_OUT_QUATERNION(rotation,
"Rotation");
4627ParticleInfoNode::ParticleInfoNode() :
ShaderNode(get_node_type()) {}
4631 if (!
output(
"Index")->links.empty()) {
4634 if (!
output(
"Random")->links.empty()) {
4637 if (!
output(
"Age")->links.empty()) {
4640 if (!
output(
"Lifetime")->links.empty()) {
4643 if (!
output(
"Location")->links.empty()) {
4647 if (!
output(
"Rotation")->links.empty()) {
4651 if (!
output(
"Size")->links.empty()) {
4654 if (!
output(
"Velocity")->links.empty()) {
4657 if (!
output(
"Angular Velocity")->links.empty()) {
4669 if (!
out->links.empty()) {
4674 if (!
out->links.empty()) {
4679 if (!
out->links.empty()) {
4684 if (!
out->links.empty()) {
4689 if (!
out->links.empty()) {
4696 if (!
out->links.empty()) {
4702 if (!
out->links.empty()) {
4707 if (!
out->links.empty()) {
4712 if (!
out->links.empty()) {
4720 compiler.
add(
this,
"node_particle_info");
4739HairInfoNode::HairInfoNode() :
ShaderNode(get_node_type()) {}
4746 if (!intercept_out->
links.empty()) {
4750 if (!
output(
"Length")->links.empty()) {
4754 if (!
output(
"Random")->links.empty()) {
4767 if (!
out->links.empty()) {
4772 if (!
out->links.empty()) {
4781 if (!
out->links.empty()) {
4790 if (!
out->links.empty()) {
4795 if (!
out->links.empty()) {
4800 if (!
out->links.empty()) {
4811 compiler.
add(
this,
"node_hair_info");
4827PointInfoNode::PointInfoNode() :
ShaderNode(get_node_type()) {}
4832 if (!
output(
"Random")->links.empty()) {
4845 if (!
out->links.empty()) {
4850 if (!
out->links.empty()) {
4855 if (!
out->links.empty()) {
4866 compiler.
add(
this,
"node_point_info");
4883VolumeInfoNode::VolumeInfoNode() :
ShaderNode(get_node_type()) {}
4891 if (!
output(
"Color")->links.empty()) {
4894 if (!
output(
"Density")->links.empty()) {
4897 if (!
output(
"Flame")->links.empty()) {
4900 if (!
output(
"Temperature")->links.empty()) {
4911 if (!color_out->
links.empty()) {
4913 attr->set_attribute(ustring(
"color"));
4918 if (!density_out->
links.empty()) {
4920 attr->set_attribute(ustring(
"density"));
4925 if (!flame_out->
links.empty()) {
4927 attr->set_attribute(ustring(
"flame"));
4932 if (!temperature_out->
links.empty()) {
4934 attr->set_attribute(ustring(
"temperature"));
4954VertexColorNode::VertexColorNode() :
ShaderNode(get_node_type()) {}
4958 if (!(
output(
"Color")->links.empty() &&
output(
"Alpha")->links.empty())) {
4959 if (!layer_name.empty()) {
4975 if (!layer_name.empty()) {
4976 layer_id = compiler.
attribute(layer_name);
4985 node = NODE_VERTEX_COLOR_BUMP_DX;
4988 node = NODE_VERTEX_COLOR_BUMP_DY;
4991 node = NODE_VERTEX_COLOR;
5004 compiler.
parameter(
"bump_offset",
"dx");
5007 compiler.
parameter(
"bump_offset",
"dy");
5010 compiler.
parameter(
"bump_offset",
"center");
5014 if (layer_name.empty()) {
5015 compiler.
parameter(
"layer_name", ustring(
"geom:vertex_color"));
5019 compiler.
parameter(
"name", (
string(
"geom:") + layer_name.c_str()).c_str());
5022 compiler.
parameter(
"layer_name", layer_name.c_str());
5026 compiler.
add(
this,
"node_vertex_color");
5041ValueNode::ValueNode() :
ShaderNode(get_node_type()) {}
5057 compiler.
parameter(
"value_value", value);
5058 compiler.
add(
this,
"node_value");
5073ColorNode::ColorNode() :
ShaderNode(get_node_type()) {}
5084 if (!color_out->
links.empty()) {
5086 compiler.
add_node(NODE_VALUE_V, value);
5094 compiler.
add(
this,
"node_value");
5110AddClosureNode::AddClosureNode() :
ShaderNode(get_node_type())
5122 compiler.
add(
this,
"node_add_closure");
5131 if (!closure1_in->
link) {
5134 else if (!closure2_in->
link) {
5154MixClosureNode::MixClosureNode() :
ShaderNode(get_node_type())
5166 compiler.
add(
this,
"node_mix_closure");
5176 if (closure1_in->
link == closure2_in->
link) {
5181 else if (!fac_in->
link) {
5187 else if (fac >= 1.0f) {
5208MixClosureWeightNode::MixClosureWeightNode() :
ShaderNode(get_node_type()) {}
5212 ShaderInput *weight_in =
input(
"Weight");
5213 ShaderInput *fac_in =
input(
"Fac");
5214 ShaderOutput *weight1_out =
output(
"Weight1");
5215 ShaderOutput *weight2_out =
output(
"Weight2");
5217 compiler.
add_node(NODE_MIX_CLOSURE,
5243InvertNode::InvertNode() :
ShaderNode(get_node_type()) {}
5250 if (!fac_in->
link) {
5252 if (!color_in->
link) {
5256 else if (fac == 0.0f) {
5276 compiler.
add(
this,
"node_invert");
5318MixNode::MixNode() :
ShaderNode(get_node_type()) {}
5322 ShaderInput *fac_in =
input(
"Fac");
5323 ShaderInput *color1_in =
input(
"Color1");
5324 ShaderInput *color2_in =
input(
"Color2");
5325 ShaderOutput *color_out =
output(
"Color");
5343 compiler.
add(
this,
"node_mix");
5352 folder.
fold_mix(mix_type, use_clamp);
5367 return use_clamp ==
false &&
input(
"Factor")->link ==
nullptr;
5409MixColorNode::MixColorNode() :
ShaderNode(get_node_type()) {}
5413 ShaderInput *fac_in =
input(
"Factor");
5414 ShaderInput *a_in =
input(
"A");
5415 ShaderInput *b_in =
input(
"B");
5416 ShaderOutput *result_out =
output(
"Result");
5418 const int fac_in_stack_offset = compiler.
stack_assign(fac_in);
5419 const int a_in_stack_offset = compiler.
stack_assign(a_in);
5420 const int b_in_stack_offset = compiler.
stack_assign(b_in);
5424 compiler.
encode_uchar4(use_clamp, blend_type, use_clamp_result),
5425 compiler.
encode_uchar4(fac_in_stack_offset, a_in_stack_offset, b_in_stack_offset),
5433 compiler.
parameter(
this,
"use_clamp_result");
5434 compiler.
add(
this,
"node_mix_color");
5441 fac =
clamp(fac, 0.0f, 1.0f);
5452 switch (blend_type) {
5461 return use_clamp ==
false && use_clamp_result ==
false &&
input(
"Factor")->link ==
nullptr;
5479MixFloatNode::MixFloatNode() :
ShaderNode(get_node_type()) {}
5483 ShaderInput *fac_in =
input(
"Factor");
5484 ShaderInput *a_in =
input(
"A");
5485 ShaderInput *b_in =
input(
"B");
5486 ShaderOutput *result_out =
output(
"Result");
5488 const int fac_in_stack_offset = compiler.
stack_assign(fac_in);
5489 const int a_in_stack_offset = compiler.
stack_assign(a_in);
5490 const int b_in_stack_offset = compiler.
stack_assign(b_in);
5495 compiler.
encode_uchar4(fac_in_stack_offset, a_in_stack_offset, b_in_stack_offset),
5502 compiler.
add(
this,
"node_mix_float");
5509 fac =
clamp(fac, 0.0f, 1.0f);
5520 return use_clamp ==
false &&
input(
"Factor")->link ==
nullptr;
5539MixVectorNode::MixVectorNode() :
ShaderNode(get_node_type()) {}
5543 ShaderInput *fac_in =
input(
"Factor");
5544 ShaderInput *a_in =
input(
"A");
5545 ShaderInput *b_in =
input(
"B");
5546 ShaderOutput *result_out =
output(
"Result");
5548 const int fac_in_stack_offset = compiler.
stack_assign(fac_in);
5549 const int a_in_stack_offset = compiler.
stack_assign(a_in);
5550 const int b_in_stack_offset = compiler.
stack_assign(b_in);
5554 compiler.
encode_uchar4(use_clamp, fac_in_stack_offset, a_in_stack_offset, b_in_stack_offset),
5561 compiler.
add(
this,
"node_mix_vector");
5568 fac =
clamp(fac, 0.0f, 1.0f);
5579 return use_clamp ==
false &&
input(
"Factor")->link ==
nullptr;
5598MixVectorNonUniformNode::MixVectorNonUniformNode() :
ShaderNode(get_node_type()) {}
5602 ShaderInput *fac_in =
input(
"Factor");
5603 ShaderInput *a_in =
input(
"A");
5604 ShaderInput *b_in =
input(
"B");
5605 ShaderOutput *result_out =
output(
"Result");
5607 const int fac_in_stack_offset = compiler.
stack_assign(fac_in);
5608 const int a_in_stack_offset = compiler.
stack_assign(a_in);
5609 const int b_in_stack_offset = compiler.
stack_assign(b_in);
5612 NODE_MIX_VECTOR_NON_UNIFORM,
5613 compiler.
encode_uchar4(use_clamp, fac_in_stack_offset, a_in_stack_offset, b_in_stack_offset),
5620 compiler.
add(
this,
"node_mix_vector_non_uniform");
5635 return use_clamp ==
false &&
input(
"Factor")->link ==
nullptr;
5659CombineColorNode::CombineColorNode() :
ShaderNode(get_node_type()) {}
5675 const int red_stack_offset = compiler.
stack_assign(red_in);
5676 const int green_stack_offset = compiler.
stack_assign(green_in);
5677 const int blue_stack_offset = compiler.
stack_assign(blue_in);
5678 const int color_stack_offset = compiler.
stack_assign(color_out);
5683 compiler.
encode_uchar4(red_stack_offset, green_stack_offset, blue_stack_offset),
5684 color_stack_offset);
5690 compiler.
add(
this,
"node_combine_color");
5708CombineXYZNode::CombineXYZNode() :
ShaderNode(get_node_type()) {}
5736 compiler.
add(
this,
"node_combine_xyz");
5752GammaNode::GammaNode() :
ShaderNode(get_node_type()) {}
5768 else if (folder.
is_one(gamma_in)) {
5788 compiler.
add(
this,
"node_gamma");
5806BrightContrastNode::BrightContrastNode() :
ShaderNode(get_node_type()) {}
5822 compiler.
add_node(NODE_BRIGHTCONTRAST,
5831 compiler.
add(
this,
"node_brightness");
5855SeparateColorNode::SeparateColorNode() :
ShaderNode(get_node_type()) {}
5862 for (
int channel = 0; channel < 3; channel++) {
5878 const int color_stack_offset = compiler.
stack_assign(color_in);
5879 const int red_stack_offset = compiler.
stack_assign(red_out);
5880 const int green_stack_offset = compiler.
stack_assign(green_out);
5881 const int blue_stack_offset = compiler.
stack_assign(blue_out);
5884 NODE_SEPARATE_COLOR,
5887 compiler.
encode_uchar4(red_stack_offset, green_stack_offset, blue_stack_offset));
5893 compiler.
add(
this,
"node_separate_color");
5911SeparateXYZNode::SeparateXYZNode() :
ShaderNode(get_node_type()) {}
5916 for (
int channel = 0; channel < 3; channel++) {
5944 compiler.
add(
this,
"node_separate_xyz");
5964HSVNode::HSVNode() :
ShaderNode(get_node_type()) {}
5968 ShaderInput *hue_in =
input(
"Hue");
5969 ShaderInput *saturation_in =
input(
"Saturation");
5970 ShaderInput *value_in =
input(
"Value");
5971 ShaderInput *fac_in =
input(
"Fac");
5972 ShaderInput *color_in =
input(
"Color");
5973 ShaderOutput *color_out =
output(
"Color");
5986 compiler.
add(
this,
"node_hsv");
6005AttributeNode::AttributeNode() :
ShaderNode(get_node_type()) {}
6014 if (!color_out->
links.empty() || !vector_out->
links.empty() || !fac_out->
links.empty() ||
6015 !alpha_out->
links.empty())
6028 const char *suffixes[] = {
6029 ".tangent_sign",
".tangent",
".undisplaced_tangent",
".undisplaced_tangent_sign"};
6030 for (
const char *suffix : suffixes) {
6032 attributes->add(attribute.substr(0, attribute.size() - strlen(suffix)));
6058 attr_node = NODE_ATTR_BUMP_DX;
6061 attr_node = NODE_ATTR_BUMP_DY;
6064 if (!color_out->
links.empty() || !vector_out->
links.empty()) {
6065 if (!color_out->
links.empty()) {
6070 bump_filter_or_stochastic);
6072 if (!vector_out->
links.empty()) {
6077 bump_filter_or_stochastic);
6081 if (!fac_out->
links.empty()) {
6086 bump_filter_or_stochastic);
6089 if (!alpha_out->
links.empty()) {
6094 bump_filter_or_stochastic);
6101 compiler.
parameter(
"bump_offset",
"dx");
6104 compiler.
parameter(
"bump_offset",
"dy");
6107 compiler.
parameter(
"bump_offset",
"center");
6112 compiler.
parameter(
"name", (
string(
"geom:") + attribute.c_str()).c_str());
6115 compiler.
parameter(
"name", attribute.c_str());
6118 compiler.
add(
this,
"node_attribute");
6134CameraNode::CameraNode() :
ShaderNode(get_node_type()) {}
6138 ShaderOutput *vector_out =
output(
"View Vector");
6139 ShaderOutput *z_depth_out =
output(
"View Z Depth");
6140 ShaderOutput *distance_out =
output(
"View Distance");
6150 compiler.
add(
this,
"node_camera");
6168FresnelNode::FresnelNode() :
ShaderNode(get_node_type()) {}
6172 ShaderInput *normal_in =
input(
"Normal");
6173 ShaderInput *IOR_in =
input(
"IOR");
6174 ShaderOutput *fac_out =
output(
"Fac");
6185 compiler.
add(
this,
"node_fresnel");
6204LayerWeightNode::LayerWeightNode() :
ShaderNode(get_node_type()) {}
6208 ShaderInput *normal_in =
input(
"Normal");
6209 ShaderInput *blend_in =
input(
"Blend");
6210 ShaderOutput *fresnel_out =
output(
"Fresnel");
6211 ShaderOutput *facing_out =
output(
"Facing");
6213 if (!fresnel_out->
links.empty()) {
6214 compiler.
add_node(NODE_LAYER_WEIGHT,
6222 if (!facing_out->
links.empty()) {
6223 compiler.
add_node(NODE_LAYER_WEIGHT,
6234 compiler.
add(
this,
"node_layer_weight");
6250WireframeNode::WireframeNode() :
ShaderNode(get_node_type()) {}
6254 ShaderInput *size_in =
input(
"Size");
6255 ShaderOutput *fac_out =
output(
"Fac");
6273 compiler.
parameter(
"bump_offset",
"dx");
6276 compiler.
parameter(
"bump_offset",
"dy");
6279 compiler.
parameter(
"bump_offset",
"center");
6283 compiler.
parameter(
this,
"use_pixel_size");
6284 compiler.
add(
this,
"node_wireframe");
6299WavelengthNode::WavelengthNode() :
ShaderNode(get_node_type()) {}
6303 ShaderInput *wavelength_in =
input(
"Wavelength");
6304 ShaderOutput *color_out =
output(
"Color");
6312 compiler.
add(
this,
"node_wavelength");
6327BlackbodyNode::BlackbodyNode() :
ShaderNode(get_node_type()) {}
6349 compiler.
add(
this,
"node_blackbody");
6366OutputNode::OutputNode() :
ShaderNode(get_node_type())
6374 ShaderInput *displacement_in =
input(
"Displacement");
6376 if (displacement_in->
link) {
6385 compiler.
add(
this,
"node_output_surface");
6388 compiler.
add(
this,
"node_output_volume");
6391 compiler.
add(
this,
"node_output_displacement");
6421MapRangeNode::MapRangeNode() :
ShaderNode(get_node_type()) {}
6427 if (!result_out->
links.empty()) {
6430 graph->
relink(result_out, clamp_node->
output(
"Result"));
6431 graph->
connect(result_out, clamp_node->
input(
"Value"));
6432 if (
input(
"To Min")->link) {
6436 clamp_node->set_min(to_min);
6438 if (
input(
"To Max")->link) {
6442 clamp_node->set_max(to_max);
6458 return from_min_in->
link ==
nullptr && from_max_in->
link ==
nullptr &&
6459 to_min_in->
link ==
nullptr && to_max_in->
link ==
nullptr;
6472 const int value_stack_offset = compiler.
stack_assign(value_in);
6477 const int steps_stack_offset = compiler.
stack_assign(steps_in);
6478 const int result_stack_offset = compiler.
stack_assign(result_out);
6484 from_min_stack_offset, from_max_stack_offset, to_min_stack_offset, to_max_stack_offset),
6485 compiler.
encode_uchar4(range_type, steps_stack_offset, result_stack_offset));
6497 compiler.
add(
this,
"node_map_range");
6526VectorMapRangeNode::VectorMapRangeNode() :
ShaderNode(get_node_type()) {}
6540 return from_min_in->
link ==
nullptr && from_max_in->
link ==
nullptr &&
6541 to_min_in->
link ==
nullptr && to_max_in->
link ==
nullptr;
6554 const int value_stack_offset = compiler.
stack_assign(vector_in);
6555 const int from_min_stack_offset = compiler.
stack_assign(from_min_in);
6556 const int from_max_stack_offset = compiler.
stack_assign(from_max_in);
6557 const int to_min_stack_offset = compiler.
stack_assign(to_min_in);
6558 const int to_max_stack_offset = compiler.
stack_assign(to_max_in);
6559 const int steps_stack_offset = compiler.
stack_assign(steps_in);
6560 const int result_stack_offset = compiler.
stack_assign(vector_out);
6563 NODE_VECTOR_MAP_RANGE,
6566 from_min_stack_offset, from_max_stack_offset, to_min_stack_offset, to_max_stack_offset),
6567 compiler.
encode_uchar4(steps_stack_offset, use_clamp, range_type, result_stack_offset));
6574 compiler.
add(
this,
"node_vector_map_range");
6597ClampNode::ClampNode() :
ShaderNode(get_node_type()) {}
6618 const int value_stack_offset = compiler.
stack_assign(value_in);
6619 const int min_stack_offset = compiler.
stack_assign(min_in);
6620 const int max_stack_offset = compiler.
stack_assign(max_in);
6621 const int result_stack_offset = compiler.
stack_assign(result_out);
6625 compiler.
encode_uchar4(min_stack_offset, max_stack_offset, clamp_type),
6626 result_stack_offset);
6633 compiler.
add(
this,
"node_clamp");
6650OutputAOVNode::OutputAOVNode() :
ShaderNode(get_node_type())
6664 input(
"Value")->disconnect();
6667 input(
"Color")->disconnect();
6749MathNode::MathNode() :
ShaderNode(get_node_type()) {}
6755 if (!result_out->
links.empty()) {
6758 clamp_node->set_min(0.0f);
6759 clamp_node->set_max(1.0f);
6760 graph->
relink(result_out, clamp_node->
output(
"Result"));
6761 graph->
connect(result_out, clamp_node->
input(
"Value"));
6778 switch (math_type) {
6785 return input(
"Value2")->link ==
nullptr;
6790 int num_variable_inputs = 0;
6792 num_variable_inputs += (
input->link) ? 1 : 0;
6794 return num_variable_inputs <= 1;
6804 const int value1_stack_offset = compiler.
stack_assign(value1_in);
6805 const int value2_stack_offset = compiler.
stack_assign(value2_in);
6806 const int value3_stack_offset = compiler.
stack_assign(value3_in);
6807 const int value_stack_offset = compiler.
stack_assign(value_out);
6812 compiler.
encode_uchar4(value1_stack_offset, value2_stack_offset, value3_stack_offset),
6813 value_stack_offset);
6819 compiler.
add(
this,
"node_math");
6876VectorMathNode::VectorMathNode() :
ShaderNode(get_node_type()) {}
6899 switch (math_type) {
6906 return input(
"Vector2")->link ==
nullptr;
6911 int num_variable_inputs = 0;
6913 num_variable_inputs += (
input->link) ? 1 : 0;
6915 return num_variable_inputs <= 1;
6926 const int vector1_stack_offset = compiler.
stack_assign(vector1_in);
6927 const int vector2_stack_offset = compiler.
stack_assign(vector2_in);
6928 const int param1_stack_offset = compiler.
stack_assign(param1_in);
6937 const int vector3_stack_offset = compiler.
stack_assign(vector3_in);
6941 compiler.
encode_uchar4(vector1_stack_offset, vector2_stack_offset, param1_stack_offset),
6942 compiler.
encode_uchar4(value_stack_offset, vector_stack_offset));
6943 compiler.
add_node(vector3_stack_offset);
6949 compiler.
encode_uchar4(vector1_stack_offset, vector2_stack_offset, param1_stack_offset),
6950 compiler.
encode_uchar4(value_stack_offset, vector_stack_offset));
6957 compiler.
add(
this,
"node_vector_math");
6986VectorRotateNode::VectorRotateNode() :
ShaderNode(get_node_type()) {}
6990 ShaderInput *vector_in =
input(
"Vector");
6991 ShaderInput *rotation_in =
input(
"Rotation");
6992 ShaderInput *center_in =
input(
"Center");
6993 ShaderInput *axis_in =
input(
"Axis");
6994 ShaderInput *angle_in =
input(
"Angle");
6995 ShaderOutput *vector_out =
output(
"Vector");
6997 compiler.
add_node(NODE_VECTOR_ROTATE,
7010 compiler.
parameter(
this,
"rotate_type");
7012 compiler.
add(
this,
"node_vector_rotate");
7040VectorTransformNode::VectorTransformNode() :
ShaderNode(get_node_type()) {}
7044 ShaderInput *vector_in =
input(
"Vector");
7045 ShaderOutput *vector_out =
output(
"Vector");
7048 NODE_VECTOR_TRANSFORM,
7049 compiler.
encode_uchar4(transform_type, convert_from, convert_to),
7055 compiler.
parameter(
this,
"transform_type");
7056 compiler.
parameter(
this,
"convert_from");
7058 compiler.
add(
this,
"node_vector_transform");
7087BumpNode::BumpNode() :
ShaderNode(get_node_type())
7094 ShaderInput *center_in =
input(
"SampleCenter");
7095 ShaderInput *dx_in =
input(
"SampleX");
7096 ShaderInput *dy_in =
input(
"SampleY");
7097 ShaderInput *normal_in =
input(
"Normal");
7098 ShaderInput *strength_in =
input(
"Strength");
7099 ShaderInput *distance_in =
input(
"Distance");
7100 ShaderOutput *normal_out =
output(
"Normal");
7120 compiler.
parameter(
this,
"use_object_space");
7121 compiler.
add(
this,
"node_bump");
7129 if (height_in->
link ==
nullptr) {
7130 if (normal_in->
link ==
nullptr) {
7152 if (curves.size() == 0) {
7166 else if (!fac_in->
link && fac == 0.0f) {
7177 if (curves.size() == 0) {
7192 for (
int i = 0;
i < curves.size();
i++) {
7199 if (curves.size() == 0) {
7206 compiler.
parameter(
this,
"extrapolate");
7239RGBCurvesNode::RGBCurvesNode() :
CurvesNode(get_node_type()) {}
7275VectorCurvesNode::VectorCurvesNode() :
CurvesNode(get_node_type()) {}
7311FloatCurveNode::FloatCurveNode() :
ShaderNode(get_node_type()) {}
7320 if (curve.size() == 0) {
7324 const float pos = (value - min_x) / (max_x - min_x);
7330 else if (!fac_in->
link && fac == 0.0f) {
7338 if (curve.size() == 0) {
7342 ShaderInput *value_in =
input(
"Value");
7343 ShaderInput *fac_in =
input(
"Factor");
7344 ShaderOutput *value_out =
output(
"Value");
7346 compiler.
add_node(NODE_FLOAT_CURVE,
7355 for (
int i = 0;
i < curve.size();
i++) {
7362 if (curve.size() == 0) {
7369 compiler.
parameter(
this,
"extrapolate");
7370 compiler.
add(
this,
"node_float_curve");
7391RGBRampNode::RGBRampNode() :
ShaderNode(get_node_type()) {}
7395 if (ramp.size() == 0 || ramp.size() != ramp_alpha.size()) {
7400 const float f =
clamp(fac, 0.0f, 1.0f) * (ramp.size() - 1);
7403 const int i =
clamp((
int)f, 0, ramp.size() - 1);
7404 const float t = f - (
float)
i;
7406 const bool use_lerp = interpolate && t > 0.0f;
7414 ramp_alpha.data(), fac, use_lerp,
false, ramp_alpha.size());
7422 if (ramp.size() == 0 || ramp.size() != ramp_alpha.size()) {
7426 ShaderInput *fac_in =
input(
"Fac");
7427 ShaderOutput *color_out =
output(
"Color");
7428 ShaderOutput *alpha_out =
output(
"Alpha");
7437 for (
int i = 0;
i < ramp.size();
i++) {
7444 if (ramp.size() == 0 || ramp.size() != ramp_alpha.size()) {
7449 compiler.
parameter_array(
"ramp_alpha", ramp_alpha.data(), ramp_alpha.size());
7450 compiler.
parameter(
this,
"interpolate");
7452 compiler.
add(
this,
"node_rgb_ramp");
7467SetNormalNode::SetNormalNode() :
ShaderNode(get_node_type()) {}
7471 ShaderInput *direction_in =
input(
"Direction");
7472 ShaderOutput *normal_out =
output(
"Normal");
7474 compiler.
add_node(NODE_CLOSURE_SET_NORMAL,
7481 compiler.
add(
this,
"node_set_normal");
7489 has_emission =
false;
7529 char *node_memory = (
char *)
operator new(node_size + inputs_size);
7530 memset(node_memory, 0, node_size + inputs_size);
7536 memcpy(node_memory + node_size, (
char *)from + node_size, inputs_size);
7546 const size_t num_inputs =
type->inputs.size();
7554 const size_t offset = memory - (
char *)
this;
7603NormalMapNode::NormalMapNode() :
ShaderNode(get_node_type()) {}
7608 if (attribute.empty()) {
7616 attributes->add(ustring((
string(attribute.c_str()) +
".undisplaced_tangent").c_str()));
7617 attributes->add(ustring((
string(attribute.c_str()) +
".undisplaced_tangent_sign").c_str()));
7635 if (attribute.empty()) {
7641 ustring((
string(attribute.c_str()) +
".undisplaced_tangent").c_str()));
7643 ustring((
string(attribute.c_str()) +
".undisplaced_tangent_sign").c_str()));
7659 if (attribute.empty()) {
7660 compiler.
parameter(
"attr_name", ustring(
"geom:undisplaced_tangent"));
7661 compiler.
parameter(
"attr_sign_name", ustring(
"geom:undisplaced_tangent_sign"));
7665 ustring((
string(attribute.c_str()) +
".undisplaced_tangent").c_str()));
7668 ustring((
string(attribute.c_str()) +
".undisplaced_tangent_sign").c_str()));
7673 compiler.
add(
this,
"node_normal_map");
7695RadialTilingNode::RadialTilingNode() :
ShaderNode(get_node_type()) {}
7699 ShaderInput *vector_in =
input(
"Vector");
7700 ShaderInput *r_gon_sides_in =
input(
"Sides");
7701 ShaderInput *r_gon_roundness_in =
input(
"Roundness");
7703 ShaderOutput *segment_coordinates_out =
output(
"Segment Coordinates");
7704 ShaderOutput *segment_id_out =
output(
"Segment ID");
7705 ShaderOutput *max_unit_parameter_out =
output(
"Segment Width");
7706 ShaderOutput *x_axis_A_angle_bisector_out =
output(
"Segment Rotation");
7708 compiler.
add_node(NODE_RADIAL_TILING,
7721 compiler.
parameter(
this,
"use_normalize");
7722 compiler.
add(
this,
"node_radial_tiling");
7731 static NodeEnum direction_type_enum;
7749TangentNode::TangentNode() :
ShaderNode(get_node_type()) {}
7755 if (attribute.empty()) {
7762 attributes->add(ustring((
string(attribute.c_str()) +
".tangent").c_str()));
7779 if (attribute.empty()) {
7783 attr = compiler.
attribute(ustring((
string(attribute.c_str()) +
".tangent").c_str()));
7799 if (attribute.empty()) {
7800 compiler.
parameter(
"attr_name", ustring(
"geom:tangent"));
7803 compiler.
parameter(
"attr_name", ustring((
string(attribute.c_str()) +
".tangent").c_str()));
7807 compiler.
parameter(
this,
"direction_type");
7809 compiler.
add(
this,
"node_tangent");
7828BevelNode::BevelNode() :
ShaderNode(get_node_type()) {}
7832 ShaderInput *radius_in =
input(
"Radius");
7833 ShaderInput *normal_in =
input(
"Normal");
7834 ShaderOutput *normal_out =
output(
"Normal");
7846 compiler.
add(
this,
"node_bevel");
7871DisplacementNode::DisplacementNode() :
ShaderNode(get_node_type()) {}
7876 if ((height - midlevel == 0.0f) || (scale == 0.0f)) {
7890 compiler.
add_node(NODE_DISPLACEMENT,
7902 compiler.
add(
this,
"node_displacement");
7928VectorDisplacementNode::VectorDisplacementNode() :
ShaderNode(get_node_type()) {}
7942 if (attribute.empty()) {
7949 attributes->add(ustring((
string(attribute.c_str()) +
".undisplaced_tangent").c_str()));
7950 attributes->add(ustring((
string(attribute.c_str()) +
".undisplaced_tangent_sign").c_str()));
7967 if (attribute.empty()) {
7973 ustring((
string(attribute.c_str()) +
".undisplaced_tangent").c_str()));
7975 ustring((
string(attribute.c_str()) +
".undisplaced_tangent_sign").c_str()));
7979 compiler.
add_node(NODE_VECTOR_DISPLACEMENT,
7993 if (attribute.empty()) {
7994 compiler.
parameter(
"attr_name", ustring(
"geom:undisplaced_tangent"));
7995 compiler.
parameter(
"attr_sign_name", ustring(
"geom:undisplaced_tangent_sign"));
7999 ustring((
string(attribute.c_str()) +
".undisplaced_tangent").c_str()));
8002 ustring((
string(attribute.c_str()) +
".undisplaced_tangent_sign").c_str()));
8007 compiler.
add(
this,
"node_vector_displacement");
KDTree *BLI_kdtree_nd_ new(unsigned int nodes_len_capacity)
MINLINE float signf(float f)
@ NODE_VECTOR_MATH_NORMALIZE
@ NODE_VECTOR_MATH_LENGTH
@ NODE_VECTOR_MATH_CROSS_PRODUCT
@ NODE_VECTOR_MATH_MODULO
@ NODE_VECTOR_MATH_COSINE
@ NODE_VECTOR_MATH_REFLECT
@ NODE_VECTOR_MATH_REFRACT
@ NODE_VECTOR_MATH_DOT_PRODUCT
@ NODE_VECTOR_MATH_ABSOLUTE
@ NODE_VECTOR_MATH_DIVIDE
@ NODE_VECTOR_MATH_TANGENT
@ NODE_VECTOR_MATH_DISTANCE
@ NODE_VECTOR_MATH_FRACTION
@ NODE_VECTOR_MATH_PROJECT
@ NODE_VECTOR_MATH_MULTIPLY
@ NODE_VECTOR_MATH_MAXIMUM
@ NODE_VECTOR_MATH_FACEFORWARD
@ NODE_VECTOR_MATH_SUBTRACT
@ NODE_VECTOR_MATH_MULTIPLY_ADD
@ NODE_VECTOR_MATH_MINIMUM
@ NODE_MATH_FLOORED_MODULO
@ NODE_VECTOR_ROTATE_TYPE_AXIS
@ NODE_VECTOR_ROTATE_TYPE_AXIS_Z
@ NODE_VECTOR_ROTATE_TYPE_AXIS_X
@ NODE_VECTOR_ROTATE_TYPE_EULER_XYZ
@ NODE_VECTOR_ROTATE_TYPE_AXIS_Y
@ NODE_MAP_RANGE_SMOOTHERSTEP
@ NODE_MAP_RANGE_SMOOTHSTEP
@ NODE_MAPPING_TYPE_POINT
@ NODE_MAPPING_TYPE_VECTOR
@ NODE_MAPPING_TYPE_TEXTURE
@ NODE_MAPPING_TYPE_NORMAL
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void constant_fold(const ConstantFolder &folder) override
void attributes(Shader *shader, AttributeRequestSet *attributes) override
void constant_fold(const ConstantFolder &folder) override
void constant_fold(const ConstantFolder &folder) override
void constant_fold(const ConstantFolder &folder) override
BsdfBaseNode(const NodeType *node_type)
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)
void constant_fold(const ConstantFolder &folder) override
void constant_fold(const ConstantFolder &folder) override
void constant_fold(const ConstantFolder &folder) override
static bool colorspace_is_data(ustring colorspace)
void constant_fold(const ConstantFolder &folder) override
void constant_fold(const ConstantFolder &folder) override
void bypass(ShaderOutput *output) const
void bypass_or_discard(ShaderInput *input) const
void fold_mapping(NodeMappingType type) const
void fold_mix_float(bool clamp_factor, bool clamp) const
bool all_inputs_constant() const
bool try_bypass_or_make_constant(ShaderInput *input, bool clamp=false) const
bool is_zero(ShaderInput *input) const
bool is_one(ShaderInput *input) const
void fold_math(NodeMathType type) const
void make_constant(const float value) const
ShaderOutput *const output
void fold_mix(NodeMix type, bool clamp) const
void make_constant_clamp(const float value, bool clamp) const
void fold_vector_math(NodeVectorMathType type) const
void fold_mix_color(NodeMix type, bool clamp_factor, bool clamp) const
void constant_fold(const ConstantFolder &folder) override
ConvertNode(SocketType::Type from, SocketType::Type to, bool autoconvert=false)
void compile(SVMCompiler &compiler, const int type, ShaderInput *value_in, ShaderOutput *value_out)
CurvesNode(const NodeType *node_type)
void constant_fold(const ConstantFolder &folder, ShaderInput *value_in)
void constant_fold(const ConstantFolder &folder) override
void constant_fold(const ConstantFolder &folder) override
ShaderNode * clone(ShaderGraph *graph) const override
void attributes(Shader *shader, AttributeRequestSet *attributes) override
ImageParams image_params() const
int get_aov_offset(Scene *scene, string name, bool &is_color)
void constant_fold(const ConstantFolder &folder) override
void constant_fold(const ConstantFolder &folder) override
void attributes(Shader *shader, AttributeRequestSet *attributes) override
virtual void get_uv_tiles(ustring map, unordered_set< int > &tiles)=0
void attributes(Shader *shader, AttributeRequestSet *attributes) override
void simplify_settings(Scene *scene) override
void attributes(Shader *shader, AttributeRequestSet *attributes) override
ShaderNode * clone(ShaderGraph *graph) const override
ImageHandle add_image(const string &filename, const ImageParams ¶ms)
InterpolationType interpolation
ImageParams image_params() const
void cull_tiles(Scene *scene, ShaderGraph *graph)
ShaderNode * clone(ShaderGraph *graph) const override
void attributes(Shader *shader, AttributeRequestSet *attributes) override
void constant_fold(const ConstantFolder &folder) override
int add_ies_from_file(const string &filename)
bool is_linear_operation() override
void expand(ShaderGraph *graph) override
void constant_fold(const ConstantFolder &folder) override
void expand(ShaderGraph *graph) override
void constant_fold(const ConstantFolder &folder) override
bool is_linear_operation() override
void constant_fold(const ConstantFolder &folder) override
bool is_linear_operation() override
void constant_fold(const ConstantFolder &folder) override
bool is_linear_operation() override
void constant_fold(const ConstantFolder &folder) override
bool is_linear_operation() override
void constant_fold(const ConstantFolder &folder) override
void constant_fold(const ConstantFolder &folder) override
bool is_linear_operation() override
void attributes(Shader *shader, AttributeRequestSet *attributes) override
void parameter_array(const char *name, const float f[], int arraylen)
void add(ShaderNode *node, const char *name, bool isfilepath=false)
void parameter_texture(const char *name, ustring filename, ustring colorspace)
void parameter(ShaderNode *node, const char *name)
void parameter_color_array(const char *name, const array< float3 > &f)
void parameter_texture_ies(const char *name, const int svm_slot)
void parameter_color(const char *name, const float3 f)
void add_input(ustring name, SocketType::Type type, const int flags=0)
static OSLNode * create(ShaderGraph *graph, const size_t num_inputs, const OSLNode *from=nullptr)
void add_output(ustring name, SocketType::Type type)
ShaderNode * clone(ShaderGraph *graph) const override
char * input_default_value()
void attributes(Shader *shader, AttributeRequestSet *attributes) override
void simplify_settings(Scene *scene) override
void attributes(Shader *shader, AttributeRequestSet *attributes) override
void attributes(Shader *shader, AttributeRequestSet *attributes) override
void attributes(Shader *shader, AttributeRequestSet *attributes) override
bool has_surface_bssrdf() override
void simplify_settings(Scene *scene) override
bool has_nonzero_weight(const char *name)
bool has_surface_transparent() override
bool has_bssrdf_bump() override
bool has_surface_emission() override
void attributes(Shader *shader, AttributeRequestSet *attributes) override
bool has_surface_transparent() override
void attributes(Shader *shader, AttributeRequestSet *attributes) override
void constant_fold(const ConstantFolder &folder) override
void constant_fold(const ConstantFolder &folder) override
void constant_fold(const ConstantFolder &folder) override
ShaderGraph * current_graph
int stack_assign_if_not_equal(ShaderInput *input, const float value)
int stack_find_offset(const int size)
uint encode_uchar4(const uint x, const uint y=0, const uint z=0, const uint w=0)
int stack_assign_if_linked(ShaderInput *input)
uint attribute_standard(ustring name)
void add_node(ShaderNodeType type, const int a=0, const int b=0, const int c=0)
void stack_link(ShaderInput *input, ShaderOutput *output)
uint closure_mix_weight_offset()
bool is_linked(ShaderInput *input)
uint get_bump_state_offset()
uint attribute(ustring name)
void stack_clear_offset(SocketType::Type type, const int offset)
int stack_assign(ShaderOutput *output)
ScatterVolumeNode(const NodeType *node_type)
void constant_fold(const ConstantFolder &folder) override
void constant_fold(const ConstantFolder &folder) override
T * create_node(Args &&...args)
void connect(ShaderOutput *from, ShaderInput *to)
void relink(ShaderInput *from, ShaderInput *to)
T * create_osl_node(void *node_memory, Args &&...args)
ShaderInput * input(const char *name)
ShaderNodeSpecialType special_type
void disconnect_unused_input(const char *name)
ShaderNode(const NodeType *type)
unique_ptr_vector< ShaderInput > inputs
ShaderOutput * output(const char *name)
virtual void compile(SVMCompiler &compiler)=0
virtual void attributes(Shader *shader, AttributeRequestSet *attributes)
unique_ptr_vector< ShaderOutput > outputs
vector< ShaderInput * > links
bool has_surface_link() const
NODE_DECLARE unique_ptr< ShaderGraph > graph
void simplify_settings(Scene *scene) override
float get_sun_average_radiance()
bool has_bssrdf_bump() override
void attributes(Shader *shader, AttributeRequestSet *attributes) override
void attributes(Shader *shader, AttributeRequestSet *attributes) override
Transform compute_transform()
void compile(SVMCompiler &compiler, const int offset_in, const int offset_out)
void compile_end(SVMCompiler &compiler, ShaderInput *vector_in, const int vector_offset)
int compile_begin(SVMCompiler &compiler, ShaderInput *vector_in)
TextureMapping tex_mapping
void attributes(Shader *shader, AttributeRequestSet *attributes) override
void constant_fold(const ConstantFolder &folder) override
void constant_fold(const ConstantFolder &folder) override
void attributes(Shader *shader, AttributeRequestSet *attributes) override
void constant_fold(const ConstantFolder &folder) override
bool is_linear_operation() override
void expand(ShaderGraph *graph) override
void constant_fold(const ConstantFolder &folder) override
bool is_linear_operation() override
void attributes(Shader *shader, AttributeRequestSet *attributes) override
void attributes(Shader *shader, AttributeRequestSet *attributes) override
void expand(ShaderGraph *graph) override
void compile(SVMCompiler &compiler, ShaderInput *density, ShaderInput *param1=nullptr, ShaderInput *param2=nullptr)
VolumeNode(const NodeType *node_type)
void push_back_slow(const T &t)
ccl_device float3 svm_separate_color(NodeCombSepColorType type, const float3 color)
ccl_device_noinline_cpu float3 svm_mix(NodeMix type, const float t, const float3 c1, const float3 c2)
ccl_device float3 svm_combine_color(NodeCombSepColorType type, const float3 color)
ccl_device_noinline_cpu float3 svm_mix_clamped_factor(NodeMix type, const float t, const float3 c1, const float3 c2)
ccl_device_inline float3 svm_brightness_contrast(float3 color, const float brightness, const float contrast)
CCL_NAMESPACE_BEGIN ustring u_colorspace_auto
reduce_max(value.rgb)") DEFINE_VALUE("REDUCE(lhs
dot(value.rgb, luminance_coefficients)") DEFINE_VALUE("REDUCE(lhs
static float get_float(PointerRNA &ptr, const char *name)
#define SVM_STACK_INVALID
#define CCL_NAMESPACE_END
#define CLOSURE_WEIGHT_CUTOFF
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt)
IMETHOD void random(Vector &a)
addDelta operator for displacement rotational velocity.
#define assert(assertion)
constexpr T clamp(T, U, U) RET
float distance(VecOp< float, D >, VecOp< float, D >) RET
VecBase< float, 3 > float3
CCL_NAMESPACE_BEGIN ccl_device float invert(const float color, const float factor)
ccl_gpu_kernel_postfix ccl_global KernelWorkTile * tiles
const ccl_global KernelWorkTile * tile
@ NODE_ENVIRONMENT_MIRROR_BALL
@ NODE_ENVIRONMENT_EQUIRECTANGULAR
@ NODE_ATTR_OUTPUT_FLOAT_ALPHA
@ NODE_ATTR_OUTPUT_FLOAT3
@ NODE_BUMP_OFFSET_CENTER
@ NODE_WAVE_BANDS_DIRECTION_Z
@ NODE_WAVE_BANDS_DIRECTION_DIAGONAL
@ NODE_WAVE_BANDS_DIRECTION_Y
@ NODE_WAVE_BANDS_DIRECTION_X
@ NODE_INFO_CURVE_IS_STRAND
@ NODE_INFO_CURVE_TANGENT_NORMAL
@ NODE_INFO_CURVE_THICKNESS
@ NODE_PRINCIPLED_HAIR_CHIANG
@ NODE_PRINCIPLED_HAIR_HUANG
@ NODE_NOISE_HYBRID_MULTIFRACTAL
@ NODE_NOISE_RIDGED_MULTIFRACTAL
@ NODE_NOISE_HETERO_TERRAIN
@ NODE_NOISE_MULTIFRACTAL
@ NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT
@ NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD
@ NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA
@ NODE_PRINCIPLED_HAIR_REFLECTANCE
@ NODE_PRINCIPLED_HAIR_DIRECT_ABSORPTION
@ NODE_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION
@ NODE_TEXCO_VOLUME_GENERATED
@ NODE_TEXCO_OBJECT_WITH_TRANSFORM
@ NODE_TEXCO_DUPLI_GENERATED
@ SHADER_TYPE_DISPLACEMENT
@ NODE_VORONOI_N_SPHERE_RADIUS
@ NODE_VORONOI_DISTANCE_TO_EDGE
@ NODE_INFO_PAR_ANGULAR_VELOCITY
@ NODE_IMAGE_COMPRESS_AS_SRGB
@ NODE_IMAGE_ALPHA_UNASSOCIATE
@ NODE_SKY_SINGLE_SCATTERING
@ NODE_SKY_MULTIPLE_SCATTERING
@ NODE_LP_ray_transmission
@ NODE_LP_ray_transparent
@ CLOSURE_VOLUME_RAYLEIGH_ID
@ CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID
@ CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID
@ CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID
@ CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID
@ CLOSURE_BSDF_DIFFUSE_ID
@ CLOSURE_BSSRDF_BURLEY_ID
@ CLOSURE_BSDF_PRINCIPLED_ID
@ CLOSURE_BSDF_TRANSPARENT_ID
@ CLOSURE_BSDF_DIFFUSE_TOON_ID
@ CLOSURE_VOLUME_DRAINE_ID
@ CLOSURE_BSDF_MICROFACET_GGX_ID
@ CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID
@ CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID
@ CLOSURE_BSDF_HAIR_TRANSMISSION_ID
@ CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID
@ CLOSURE_VOLUME_FOURNIER_FORAND_ID
@ CLOSURE_BSSRDF_RANDOM_WALK_ID
@ CLOSURE_BSDF_PHYSICAL_CONDUCTOR
@ CLOSURE_BSDF_HAIR_HUANG_ID
@ CLOSURE_BSDF_MICROFACET_BECKMANN_ID
@ CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID
@ CLOSURE_BSDF_F82_CONDUCTOR
@ CLOSURE_BSDF_RAY_PORTAL_ID
@ CLOSURE_BSDF_GLOSSY_TOON_ID
@ CLOSURE_BSDF_HAIR_CHIANG_ID
@ CLOSURE_VOLUME_ABSORPTION_ID
@ CLOSURE_BSDF_HAIR_REFLECTION_ID
@ CLOSURE_BSSRDF_RANDOM_WALK_SKIN_ID
@ CLOSURE_BSDF_TRANSLUCENT_ID
@ CLOSURE_BSDF_ASHIKHMIN_VELVET_ID
@ NODE_INFO_POINT_POSITION
@ NODE_VECTOR_TRANSFORM_TYPE_NORMAL
@ NODE_VECTOR_TRANSFORM_TYPE_VECTOR
@ NODE_VECTOR_TRANSFORM_TYPE_POINT
@ NODE_BLEND_QUADRATIC_SPHERE
@ NODE_WAVE_RINGS_DIRECTION_Y
@ NODE_WAVE_RINGS_DIRECTION_SPHERICAL
@ NODE_WAVE_RINGS_DIRECTION_X
@ NODE_WAVE_RINGS_DIRECTION_Z
@ NODE_LAYER_WEIGHT_FACING
@ NODE_LAYER_WEIGHT_FRESNEL
@ NODE_NORMAL_MAP_TANGENT
@ NODE_NORMAL_MAP_BLENDER_WORLD
@ NODE_NORMAL_MAP_BLENDER_OBJECT
@ NODE_LIGHT_FALLOFF_QUADRATIC
@ NODE_LIGHT_FALLOFF_LINEAR
@ NODE_LIGHT_FALLOFF_CONSTANT
@ ATTR_STD_CURVE_INTERCEPT
@ ATTR_STD_GENERATED_TRANSFORM
@ ATTR_STD_VOLUME_TEMPERATURE
@ ATTR_STD_VOLUME_DENSITY
@ ATTR_STD_NORMAL_UNDISPLACED
@ ATTR_STD_UV_TANGENT_SIGN
@ ATTR_STD_UV_TANGENT_SIGN_UNDISPLACED
@ ATTR_STD_UV_TANGENT_UNDISPLACED
@ ATTR_STD_RANDOM_PER_ISLAND
CCL_NAMESPACE_BEGIN ccl_device float3 svm_mapping(NodeMappingType type, const float3 vector, const float3 location, const float3 rotation, const float3 scale)
ccl_device_inline float interp(const float a, const float b, const float t)
ccl_device_inline float3 one_float3()
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
CCL_NAMESPACE_BEGIN ccl_device void svm_vector_math(ccl_private float *value, ccl_private float3 *vector, NodeVectorMathType type, const float3 a, const float3 b, const float3 c, float param1)
ccl_device float svm_math(NodeMathType type, const float a, float b, const float c)
ccl_device float3 svm_math_blackbody_color_rec709(const float t)
ccl_device_inline float3 svm_math_gamma_color(float3 color, const float gamma)
color rgb_ramp_lookup(color ramp[], float at, int interpolate, int extrapolate)
static blender::bke::bNodeSocketTemplate outputs[]
static blender::bke::bNodeSocketTemplate inputs[]
#define SOCKET_IN_NORMAL(name, ui_name, default_value,...)
#define SOCKET_OUT_POINT(name, ui_name)
#define SOCKET_OUT_FLOAT(name, ui_name)
#define SOCKET_OUT_COLOR(name, ui_name)
#define SOCKET_FLOAT(name, ui_name, default_value,...)
#define SOCKET_INT(name, ui_name, default_value,...)
#define SOCKET_IN_COLOR(name, ui_name, default_value,...)
#define SOCKET_FLOAT_ARRAY(name, ui_name, default_value,...)
#define SOCKET_TRANSFORM(name, ui_name, default_value,...)
#define SOCKET_OUT_NORMAL(name, ui_name)
#define SOCKET_IN_FLOAT(name, ui_name, default_value,...)
#define SOCKET_IN_CLOSURE(name, ui_name,...)
#define SOCKET_OFFSETOF(T, name)
#define SOCKET_INT_ARRAY(name, ui_name, default_value,...)
#define SOCKET_VECTOR_ARRAY(name, ui_name, default_value,...)
#define SOCKET_IN_VECTOR(name, ui_name, default_value,...)
#define NODE_DEFINE(structname)
#define SOCKET_VECTOR(name, ui_name, default_value,...)
#define SOCKET_IN_POINT(name, ui_name, default_value,...)
#define SOCKET_COLOR_ARRAY(name, ui_name, default_value,...)
#define SOCKET_COLOR(name, ui_name, default_value,...)
#define SOCKET_OUT_VECTOR(name, ui_name)
#define SOCKET_IN_STRING(name, ui_name, default_value,...)
#define SOCKET_BOOLEAN(name, ui_name, default_value,...)
#define SOCKET_IN_BOOLEAN(name, ui_name, default_value,...)
#define SOCKET_STRING(name, ui_name, default_value,...)
#define SOCKET_ENUM(name, ui_name, values, default_value,...)
#define SOCKET_OUT_CLOSURE(name, ui_name)
ccl_device_inline float float_ramp_lookup(KernelGlobals kg, const int offset, float f, bool interpolate, bool extrapolate, const int table_size)
@ SHADER_SPECIAL_TYPE_LIGHT_PATH
@ SHADER_SPECIAL_TYPE_PROXY
@ SHADER_SPECIAL_TYPE_GEOMETRY
@ SHADER_SPECIAL_TYPE_OUTPUT_AOV
@ SHADER_SPECIAL_TYPE_COMBINE_CLOSURE
@ SHADER_SPECIAL_TYPE_BUMP
@ SHADER_SPECIAL_TYPE_AUTOCONVERT
@ SHADER_SPECIAL_TYPE_OUTPUT
@ SHADER_SPECIAL_TYPE_CLOSURE
@ SHADER_SPECIAL_TYPE_OSL
static float2 sky_spherical_coordinates(const float3 dir)
static void sky_texture_precompute_hosek(SunSky *sunsky, const float3 dir, float turbidity, const float ground_albedo)
static void sky_texture_precompute_preetham(SunSky *sunsky, const float3 dir, const float turbidity)
static void sky_texture_precompute_nishita(SunSky *sunsky, bool multiple_scattering, bool sun_disc, const float sun_size, const float sun_intensity, const float sun_elevation, const float sun_rotation, const float altitude, const float air_density, const float aerosol_density, const float ozone_density)
static float sky_perez_function(const float lam[6], float theta, const float gamma)
#define TEXTURE_MAPPING_DEFINE(TextureNode)
void SKY_arhosekskymodelstate_free(SKY_ArHosekSkyModelState *state)
SKY_ArHosekSkyModelState * SKY_arhosek_xyz_skymodelstate_alloc_init(const double turbidity, const double albedo, const double elevation)
float3 sun_direction(float sun_cos_theta)
void SKY_single_scattering_precompute_sun(float sun_elevation, float angular_diameter, float altitude, float air_density, float aerosol_density, float r_pixel_bottom[3], float r_pixel_top[3])
void SKY_multiple_scattering_precompute_sun(float sun_elevation, float angular_diameter, float altitude, float air_density, float aerosol_density, float ozone_density, float r_pixel_bottom[3], float r_pixel_top[3])
float SKY_earth_intersection_angle(float altitude)
bool string_endswith(const string_view s, const string_view end)
static AttributeStandard name_standard(const char *name)
void insert(const char *x, const int y)
static NodeType * add(const char *name, CreateFunc create, Type type=NONE, const NodeType *base=nullptr)
float get_float(const SocketType &input) const
float3 get_float3(const SocketType &input) const
SKY_ArHosekSkyModelConfiguration configs[11]
unique_ptr< LightManager > light_manager
unique_ptr_vector< Geometry > geometry
unique_ptr< ShaderManager > shader_manager
unique_ptr< ImageManager > image_manager
static bool is_float3(Type type)
static ustring type_name(Type type)
static void * zero_default_value()
@ IMAGE_ALPHA_CHANNEL_PACKED
@ IMAGE_ALPHA_UNASSOCIATED
static int blend(const Tex *tex, const float texvec[3], TexResult *texres)
ccl_device_inline size_t divide_up(const size_t x, const size_t y)
ccl_device_inline size_t align_up(const size_t offset, const size_t alignment)