36#define TEXTURE_MAPPING_DEFINE(TextureNode) \
37 SOCKET_POINT(tex_mapping.translation, "Translation", zero_float3()); \
38 SOCKET_VECTOR(tex_mapping.rotation, "Rotation", zero_float3()); \
39 SOCKET_VECTOR(tex_mapping.scale, "Scale", one_float3()); \
41 SOCKET_VECTOR(tex_mapping.min, "Min", make_float3(-FLT_MAX, -FLT_MAX, -FLT_MAX)); \
42 SOCKET_VECTOR(tex_mapping.max, "Max", make_float3(FLT_MAX, FLT_MAX, FLT_MAX)); \
43 SOCKET_BOOLEAN(tex_mapping.use_minmax, "Use Min Max", false); \
45 static NodeEnum mapping_axis_enum; \
46 mapping_axis_enum.insert("none", TextureMapping::NONE); \
47 mapping_axis_enum.insert("x", TextureMapping::X); \
48 mapping_axis_enum.insert("y", TextureMapping::Y); \
49 mapping_axis_enum.insert("z", TextureMapping::Z); \
50 SOCKET_ENUM(tex_mapping.x_mapping, "x_mapping", mapping_axis_enum, TextureMapping::X); \
51 SOCKET_ENUM(tex_mapping.y_mapping, "y_mapping", mapping_axis_enum, TextureMapping::Y); \
52 SOCKET_ENUM(tex_mapping.z_mapping, "z_mapping", mapping_axis_enum, TextureMapping::Z); \
54 static NodeEnum mapping_type_enum; \
55 mapping_type_enum.insert("point", TextureMapping::POINT); \
56 mapping_type_enum.insert("texture", TextureMapping::TEXTURE); \
57 mapping_type_enum.insert("vector", TextureMapping::VECTOR); \
58 mapping_type_enum.insert("normal", TextureMapping::NORMAL); \
59 SOCKET_ENUM(tex_mapping.type, "Type", mapping_type_enum, TextureMapping::TEXTURE); \
61 static NodeEnum mapping_projection_enum; \
62 mapping_projection_enum.insert("flat", TextureMapping::FLAT); \
63 mapping_projection_enum.insert("cube", TextureMapping::CUBE); \
64 mapping_projection_enum.insert("tube", TextureMapping::TUBE); \
65 mapping_projection_enum.insert("sphere", TextureMapping::SPHERE); \
66 SOCKET_ENUM(tex_mapping.projection, "Projection", mapping_projection_enum, TextureMapping::FLAT);
109 mat = tmat * rmat * smat;
114 mat = tmat * rmat * smat;
157 compiler.
add_node(NODE_TEXTURE_MAPPING, offset_in, offset_out);
165 compiler.
add_node(NODE_MIN_MAX, offset_out, offset_out);
186 compile(compiler, offset_in, offset_out);
196 const int vector_offset)
251 SOCKET_FLOAT(projection_blend,
"Projection Blend", 0.0f);
280 params.animated = animated;
281 params.interpolation = interpolation;
282 params.extension = extension;
283 params.alpha_type = alpha_type;
284 params.colorspace = colorspace;
295 tiles.push_back_slow(1001);
308 if (
tiles.size() == 0) {
314 if (vector_in->
link) {
316 if (node->
type == UVMapNode::get_node_type()) {
318 attribute = uvmap->get_attribute();
320 else if (node->
type == TextureCoordinateNode::get_node_type()) {
330 unordered_set<int> used_tiles;
335 for (
Node *node : geom->get_used_shaders()) {
337 if (shader->
graph.get() == graph) {
345 if (used_tiles.count(
tile)) {
349 tiles.steal_data(new_tiles);
380 const ImageMetaData metadata =
handle.metadata();
383 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
386 if (compress_as_srgb) {
389 if (!alpha_out->
links.empty()) {
394 if (unassociate_alpha) {
402 if (
handle.num_tiles() == 0) {
403 num_nodes = -
handle.svm_slot();
418 for (
int i = 0;
i < num_nodes;
i++) {
422 if (2 *
i + 1 <
tiles.size()) {
424 node.
w =
handle.svm_slot(2 *
i + 1);
436 compiler.
add_node(NODE_TEX_IMAGE_BOX,
445 tex_mapping.compile_end(compiler, vector_in, vector_offset);
450 ShaderOutput *alpha_out =
output(
"Alpha");
459 const ImageMetaData metadata =
handle.metadata();
460 const bool is_float = metadata.
is_float();
462 const ustring known_colorspace = metadata.
colorspace;
464 if (
handle.svm_slot() == -1) {
466 "filename", filename, compress_as_srgb ?
u_colorspace_raw : known_colorspace);
475 const bool is_tiled = (filename.find(
"<UDIM>") != string::npos ||
476 filename.find(
"<UVTILE>") != string::npos) ||
480 compiler.
parameter(
this,
"projection_blend");
481 compiler.
parameter(
"compress_as_srgb", compress_as_srgb);
483 compiler.
parameter(
"unassociate_alpha", !alpha_out->
links.empty() && unassociate_alpha);
484 compiler.
parameter(
"is_float", is_float);
485 compiler.
parameter(
"is_tiled", is_tiled);
486 compiler.
parameter(
this,
"interpolation");
489 compiler.
add(
this,
"node_image_texture");
549 params.animated = animated;
550 params.interpolation = interpolation;
552 params.alpha_type = alpha_type;
553 params.colorspace = colorspace;
581 const ImageMetaData metadata =
handle.metadata();
584 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
587 if (compress_as_srgb) {
591 compiler.
add_node(NODE_TEX_ENVIRONMENT,
599 tex_mapping.compile_end(compiler, vector_in, vector_offset);
611 const ImageMetaData metadata =
handle.metadata();
612 const bool is_float = metadata.
is_float();
614 const ustring known_colorspace = metadata.
colorspace;
616 if (
handle.svm_slot() == -1) {
618 "filename", filename, compress_as_srgb ?
u_colorspace_raw : known_colorspace);
625 compiler.
parameter(
this,
"interpolation");
626 compiler.
parameter(
"compress_as_srgb", compress_as_srgb);
628 compiler.
parameter(
"is_float", is_float);
629 compiler.
add(
this,
"node_environment_texture");
651 return (1.0f + lam[0] *
expf(lam[1] /
cosf(theta))) *
652 (1.0f + lam[2] *
expf(lam[3] * gamma) + lam[4] *
cosf(gamma) *
cosf(gamma));
657 const float turbidity)
666 const float theta = spherical.
x;
667 const float phi = spherical.
y;
669 sunsky->
theta = theta;
672 const float theta2 = theta * theta;
673 const float theta3 = theta2 * theta;
674 const float T = turbidity;
675 const float T2 =
T *
T;
677 const float chi = (4.0f / 9.0f -
T / 120.0f) * (
M_PI_F - 2.0f * theta);
678 sunsky->
radiance_x = (4.0453f *
T - 4.9710f) *
tanf(chi) - 0.2155f *
T + 2.4192f;
681 sunsky->
radiance_y = (0.00166f * theta3 - 0.00375f * theta2 + 0.00209f * theta) *
T2 +
682 (-0.02903f * theta3 + 0.06377f * theta2 - 0.03202f * theta + 0.00394f) *
T +
683 (0.11693f * theta3 - 0.21196f * theta2 + 0.06052f * theta + 0.25886f);
685 sunsky->
radiance_z = (0.00275f * theta3 - 0.00610f * theta2 + 0.00317f * theta) *
T2 +
686 (-0.04214f * theta3 + 0.08970f * theta2 - 0.04153f * theta + 0.00516f) *
T +
687 (0.15346f * theta3 - 0.26756f * theta2 + 0.06670f * theta + 0.26688f);
689 sunsky->
config_x[0] = (0.1787f *
T - 1.4630f);
690 sunsky->
config_x[1] = (-0.3554f *
T + 0.4275f);
691 sunsky->
config_x[2] = (-0.0227f *
T + 5.3251f);
692 sunsky->
config_x[3] = (0.1206f *
T - 2.5771f);
693 sunsky->
config_x[4] = (-0.0670f *
T + 0.3703f);
695 sunsky->
config_y[0] = (-0.0193f *
T - 0.2592f);
696 sunsky->
config_y[1] = (-0.0665f *
T + 0.0008f);
697 sunsky->
config_y[2] = (-0.0004f *
T + 0.2125f);
698 sunsky->
config_y[3] = (-0.0641f *
T - 0.8989f);
699 sunsky->
config_y[4] = (-0.0033f *
T + 0.0452f);
701 sunsky->
config_z[0] = (-0.0167f *
T - 0.2608f);
702 sunsky->
config_z[1] = (-0.0950f *
T + 0.0092f);
703 sunsky->
config_z[2] = (-0.0079f *
T + 0.2102f);
704 sunsky->
config_z[3] = (-0.0441f *
T - 1.6537f);
705 sunsky->
config_z[4] = (-0.0109f *
T + 0.0529f);
708 for (
int i = 5;
i < 9;
i++) {
723 const float ground_albedo)
727 float theta = spherical.
x;
728 const float phi = spherical.
y;
731 turbidity =
clamp(turbidity, 0.0f, 10.0f);
736 sunsky->
theta = theta;
739 const float solarElevation =
M_PI_2_F - theta;
744 (
double)turbidity, (
double)ground_albedo, (
double)solarElevation);
747 for (
int i = 0;
i < 9; ++
i) {
763 const float sun_size,
764 const float sun_intensity,
765 const float sun_elevation,
766 const float sun_rotation,
767 const float altitude,
768 const float air_density,
769 const float dust_density)
772 float pixel_bottom[3];
775 sun_elevation, sun_size, altitude, air_density, dust_density, pixel_bottom, pixel_top);
792 const float clamped_altitude =
clamp(altitude, 1.0f, 59999.0f);
806 const float dir_elevation = sun_elevation;
807 const float half_angular = angular_diameter / 2.0f;
808 const float3 pixel_bottom =
make_float3(pix_bottom[0], pix_bottom[1], pix_bottom[2]);
814 if (sun_elevation - half_angular > 0.0f) {
815 if (sun_elevation + half_angular > 0.0f) {
816 y = ((dir_elevation - sun_elevation) / angular_diameter) + 0.5f;
817 xyz =
interp(pixel_bottom, pixel_top,
y) * sun_intensity;
821 if (sun_elevation + half_angular > 0.0f) {
822 y = dir_elevation / (sun_elevation + half_angular);
823 xyz =
interp(pixel_bottom, pixel_top,
y) * sun_intensity;
830 float sun_contribution =
average(xyz) *
sqr(angular_diameter);
832 const float first_point = 0.8f / 180.0f *
M_PI_F;
833 const float second_point = 1.0f / 180.0f *
M_PI_F;
835 if (angular_diameter < first_point) {
836 sun_contribution *= 1.0f;
838 else if (angular_diameter < second_point) {
839 const float diff = angular_diameter - first_point;
840 const float slope = (0.8f - 1.0f) / (second_point - first_point);
841 sun_contribution *= 1.0f + slope *
diff;
844 const float diff = angular_diameter - 1.0f / 180.0f *
M_PI_F;
845 const float slope = (0.45f - 0.8f) / (third_point - second_point);
846 sun_contribution *= 0.8f + slope *
diff;
849 return sun_contribution;
884SkyTextureNode::SkyTextureNode() :
TextureNode(get_node_type()) {}
890 float new_sun_elevation = sun_elevation;
891 float new_sun_rotation = sun_rotation;
901 new_sun_elevation =
copysignf(
M_PI_F, new_sun_elevation) - new_sun_elevation;
902 new_sun_rotation +=
M_PI_F;
908 if (new_sun_rotation < 0.0f) {
911 new_sun_rotation =
M_2PI_F - new_sun_rotation;
913 sun_elevation = new_sun_elevation;
914 sun_rotation = new_sun_rotation;
932 const float clamped_altitude =
clamp(altitude, 1.0f, 59999.0f);
951 unique_ptr<SkyLoader> loader = make_unique<SkyLoader>(
952 sun_elevation, clamped_altitude, air_density, dust_density, ozone_density);
960 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
1014 tex_mapping.compile_end(compiler, vector_in, vector_offset);
1031 const float clamped_altitude =
clamp(altitude, 1.0f, 59999.0f);
1050 unique_ptr<SkyLoader> loader = make_unique<SkyLoader>(
1051 sun_elevation, clamped_altitude, air_density, dust_density, ozone_density);
1072 compiler.
add(
this,
"node_sky_texture");
1101GradientTextureNode::GradientTextureNode() :
TextureNode(get_node_type()) {}
1105 ShaderInput *vector_in =
input(
"Vector");
1106 ShaderOutput *color_out =
output(
"Color");
1107 ShaderOutput *fac_out =
output(
"Fac");
1109 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
1111 compiler.
add_node(NODE_TEX_GRADIENT,
1117 tex_mapping.compile_end(compiler, vector_in, vector_offset);
1124 compiler.
parameter(
this,
"gradient_type");
1125 compiler.
add(
this,
"node_gradient_texture");
1137 dimensions_enum.
insert(
"1D", 1);
1138 dimensions_enum.
insert(
"2D", 2);
1139 dimensions_enum.
insert(
"3D", 3);
1140 dimensions_enum.
insert(
"4D", 4);
1141 SOCKET_ENUM(dimensions,
"Dimensions", dimensions_enum, 3);
1169NoiseTextureNode::NoiseTextureNode() :
TextureNode(get_node_type()) {}
1173 ShaderInput *vector_in =
input(
"Vector");
1174 ShaderInput *w_in =
input(
"W");
1175 ShaderInput *scale_in =
input(
"Scale");
1176 ShaderInput *detail_in =
input(
"Detail");
1177 ShaderInput *roughness_in =
input(
"Roughness");
1178 ShaderInput *lacunarity_in =
input(
"Lacunarity");
1179 ShaderInput *offset_in =
input(
"Offset");
1180 ShaderInput *gain_in =
input(
"Gain");
1181 ShaderInput *distortion_in =
input(
"Distortion");
1182 ShaderOutput *fac_out =
output(
"Fac");
1183 ShaderOutput *color_out =
output(
"Color");
1185 const int vector_stack_offset =
tex_mapping.compile_begin(compiler, vector_in);
1200 vector_stack_offset, w_stack_offset, scale_stack_offset, detail_stack_offset),
1202 roughness_stack_offset, lacunarity_stack_offset, offset_stack_offset, gain_stack_offset),
1203 compiler.
encode_uchar4(distortion_stack_offset, fac_stack_offset, color_stack_offset));
1214 tex_mapping.compile_end(compiler, vector_in, vector_stack_offset);
1222 compiler.
parameter(
this,
"use_normalize");
1223 compiler.
add(
this,
"node_noise_texture");
1253GaborTextureNode::GaborTextureNode() :
TextureNode(get_node_type()) {}
1257 ShaderInput *vector_in =
input(
"Vector");
1258 ShaderInput *scale_in =
input(
"Scale");
1259 ShaderInput *frequency_in =
input(
"Frequency");
1260 ShaderInput *anisotropy_in =
input(
"Anisotropy");
1261 ShaderInput *orientation_2d_in =
input(
"Orientation 2D");
1262 ShaderInput *orientation_3d_in =
input(
"Orientation 3D");
1264 ShaderOutput *value_out =
output(
"Value");
1265 ShaderOutput *phase_out =
output(
"Phase");
1266 ShaderOutput *intensity_out =
output(
"Intensity");
1268 const int vector_stack_offset =
tex_mapping.compile_begin(compiler, vector_in);
1273 const int orientation_3d_stack_offset = compiler.
stack_assign(orientation_3d_in);
1284 frequency_stack_offset,
1285 anisotropy_stack_offset),
1286 compiler.
encode_uchar4(orientation_2d_stack_offset, orientation_3d_stack_offset));
1289 compiler.
encode_uchar4(value_stack_offset, phase_stack_offset, intensity_stack_offset),
1295 tex_mapping.compile_end(compiler, vector_in, vector_stack_offset);
1302 compiler.
add(
this,
"node_gabor_texture");
1314 dimensions_enum.
insert(
"1D", 1);
1315 dimensions_enum.
insert(
"2D", 2);
1316 dimensions_enum.
insert(
"3D", 3);
1317 dimensions_enum.
insert(
"4D", 4);
1318 SOCKET_ENUM(dimensions,
"Dimensions", dimensions_enum, 3);
1356VoronoiTextureNode::VoronoiTextureNode() :
TextureNode(get_node_type()) {}
1360 ShaderInput *vector_in =
input(
"Vector");
1361 ShaderInput *w_in =
input(
"W");
1362 ShaderInput *scale_in =
input(
"Scale");
1363 ShaderInput *detail_in =
input(
"Detail");
1364 ShaderInput *roughness_in =
input(
"Roughness");
1365 ShaderInput *lacunarity_in =
input(
"Lacunarity");
1366 ShaderInput *smoothness_in =
input(
"Smoothness");
1367 ShaderInput *exponent_in =
input(
"Exponent");
1368 ShaderInput *randomness_in =
input(
"Randomness");
1370 ShaderOutput *distance_out =
output(
"Distance");
1371 ShaderOutput *color_out =
output(
"Color");
1372 ShaderOutput *position_out =
output(
"Position");
1373 ShaderOutput *w_out =
output(
"W");
1374 ShaderOutput *radius_out =
output(
"Radius");
1376 const int vector_stack_offset =
tex_mapping.compile_begin(compiler, vector_in);
1391 compiler.
add_node(NODE_TEX_VORONOI, dimensions, feature, metric);
1394 vector_stack_offset, w_in_stack_offset, scale_stack_offset, detail_stack_offset),
1396 lacunarity_stack_offset,
1397 smoothness_stack_offset,
1398 exponent_stack_offset),
1400 randomness_stack_offset, use_normalize, distance_stack_offset, color_stack_offset),
1401 compiler.
encode_uchar4(position_stack_offset, w_out_stack_offset, radius_stack_offset));
1409 tex_mapping.compile_end(compiler, vector_in, vector_stack_offset);
1419 compiler.
parameter(
this,
"use_normalize");
1420 compiler.
add(
this,
"node_voronoi_texture");
1442IESLightNode::IESLightNode() :
TextureNode(get_node_type())
1444 light_manager =
nullptr;
1452 node->light_manager =
nullptr;
1460 if (light_manager) {
1461 light_manager->remove_ies(slot);
1465void IESLightNode::get_slot()
1474 slot = light_manager->add_ies(ies.string());
1484 ShaderInput *strength_in =
input(
"Strength");
1485 ShaderInput *vector_in =
input(
"Vector");
1486 ShaderOutput *fac_out =
output(
"Fac");
1488 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
1498 tex_mapping.compile_end(compiler, vector_in, vector_offset);
1509 compiler.
add(
this,
"node_ies_light");
1519 dimensions_enum.
insert(
"1D", 1);
1520 dimensions_enum.
insert(
"2D", 2);
1521 dimensions_enum.
insert(
"3D", 3);
1522 dimensions_enum.
insert(
"4D", 4);
1523 SOCKET_ENUM(dimensions,
"Dimensions", dimensions_enum, 3);
1534WhiteNoiseTextureNode::WhiteNoiseTextureNode() :
ShaderNode(get_node_type()) {}
1538 ShaderInput *vector_in =
input(
"Vector");
1539 ShaderInput *w_in =
input(
"W");
1540 ShaderOutput *value_out =
output(
"Value");
1541 ShaderOutput *color_out =
output(
"Color");
1543 const int vector_stack_offset = compiler.
stack_assign(vector_in);
1544 const int w_stack_offset = compiler.
stack_assign(w_in);
1545 const int value_stack_offset = compiler.
stack_assign(value_out);
1546 const int color_stack_offset = compiler.
stack_assign(color_out);
1548 compiler.
add_node(NODE_TEX_WHITE_NOISE,
1550 compiler.
encode_uchar4(vector_stack_offset, w_stack_offset),
1551 compiler.
encode_uchar4(value_stack_offset, color_stack_offset));
1557 compiler.
add(
this,
"node_white_noise_texture");
1573 static NodeEnum bands_direction_enum;
1581 static NodeEnum rings_direction_enum;
1608WaveTextureNode::WaveTextureNode() :
TextureNode(get_node_type()) {}
1612 ShaderInput *vector_in =
input(
"Vector");
1613 ShaderInput *scale_in =
input(
"Scale");
1614 ShaderInput *distortion_in =
input(
"Distortion");
1615 ShaderInput *detail_in =
input(
"Detail");
1616 ShaderInput *dscale_in =
input(
"Detail Scale");
1617 ShaderInput *droughness_in =
input(
"Detail Roughness");
1618 ShaderInput *phase_in =
input(
"Phase Offset");
1619 ShaderOutput *color_out =
output(
"Color");
1620 ShaderOutput *fac_out =
output(
"Fac");
1622 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
1634 compiler.
encode_uchar4(wave_type, bands_direction, rings_direction, profile),
1635 compiler.
encode_uchar4(vector_offset, scale_ofs, distortion_ofs),
1636 compiler.
encode_uchar4(detail_ofs, dscale_ofs, droughness_ofs, phase_ofs));
1648 tex_mapping.compile_end(compiler, vector_in, vector_offset);
1656 compiler.
parameter(
this,
"bands_direction");
1657 compiler.
parameter(
this,
"rings_direction");
1660 compiler.
add(
this,
"node_wave_texture");
1683MagicTextureNode::MagicTextureNode() :
TextureNode(get_node_type()) {}
1687 ShaderInput *vector_in =
input(
"Vector");
1688 ShaderInput *scale_in =
input(
"Scale");
1689 ShaderInput *distortion_in =
input(
"Distortion");
1690 ShaderOutput *color_out =
output(
"Color");
1691 ShaderOutput *fac_out =
output(
"Fac");
1693 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
1704 tex_mapping.compile_end(compiler, vector_in, vector_offset);
1712 compiler.
add(
this,
"node_magic_texture");
1734CheckerTextureNode::CheckerTextureNode() :
TextureNode(get_node_type()) {}
1738 ShaderInput *vector_in =
input(
"Vector");
1739 ShaderInput *color1_in =
input(
"Color1");
1740 ShaderInput *color2_in =
input(
"Color2");
1741 ShaderInput *scale_in =
input(
"Scale");
1743 ShaderOutput *color_out =
output(
"Color");
1744 ShaderOutput *fac_out =
output(
"Fac");
1746 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
1748 compiler.
add_node(NODE_TEX_CHECKER,
1757 tex_mapping.compile_end(compiler, vector_in, vector_offset);
1764 compiler.
add(
this,
"node_checker_texture");
1776 SOCKET_INT(offset_frequency,
"Offset Frequency", 2);
1778 SOCKET_INT(squash_frequency,
"Squash Frequency", 2);
1798BrickTextureNode::BrickTextureNode() :
TextureNode(get_node_type()) {}
1802 ShaderInput *vector_in =
input(
"Vector");
1803 ShaderInput *color1_in =
input(
"Color1");
1804 ShaderInput *color2_in =
input(
"Color2");
1805 ShaderInput *mortar_in =
input(
"Mortar");
1806 ShaderInput *scale_in =
input(
"Scale");
1807 ShaderInput *mortar_size_in =
input(
"Mortar Size");
1808 ShaderInput *mortar_smooth_in =
input(
"Mortar Smooth");
1809 ShaderInput *bias_in =
input(
"Bias");
1810 ShaderInput *brick_width_in =
input(
"Brick Width");
1811 ShaderInput *row_height_in =
input(
"Row Height");
1813 ShaderOutput *color_out =
output(
"Color");
1814 ShaderOutput *fac_out =
output(
"Fac");
1816 const int vector_offset =
tex_mapping.compile_begin(compiler, vector_in);
1845 tex_mapping.compile_end(compiler, vector_in, vector_offset);
1853 compiler.
parameter(
this,
"offset_frequency");
1855 compiler.
parameter(
this,
"squash_frequency");
1856 compiler.
add(
this,
"node_brick_texture");
1872 static NodeEnum interpolation_enum;
1889PointDensityTextureNode::PointDensityTextureNode() :
ShaderNode(get_node_type()) {}
1915 params.interpolation = interpolation;
1925 const bool use_density = !density_out->
links.empty();
1926 const bool use_color = !color_out->
links.empty();
1928 if (!(use_density || use_color)) {
1949 const int slot =
handle.svm_slot();
1979 ShaderOutput *density_out =
output(
"Density");
1980 ShaderOutput *color_out =
output(
"Color");
1982 const bool use_density = !density_out->
links.empty();
1983 const bool use_color = !color_out->
links.empty();
1985 if (!(use_density || use_color)) {
1991 compiler.
add(
this,
"node_voxel_texture_zero");
2005 compiler.
parameter(
this,
"interpolation");
2006 compiler.
add(
this,
"node_voxel_texture");
2025NormalNode::NormalNode() :
ShaderNode(get_node_type()) {}
2029 ShaderInput *normal_in =
input(
"Normal");
2030 ShaderOutput *normal_out =
output(
"Normal");
2031 ShaderOutput *dot_out =
output(
"Dot");
2044 compiler.
add(
this,
"node_normal");
2070MappingNode::MappingNode() :
ShaderNode(get_node_type()) {}
2091 const int vector_stack_offset = compiler.
stack_assign(vector_in);
2092 const int location_stack_offset = compiler.
stack_assign(location_in);
2093 const int rotation_stack_offset = compiler.
stack_assign(rotation_in);
2094 const int scale_stack_offset = compiler.
stack_assign(scale_in);
2095 const int result_stack_offset = compiler.
stack_assign(vector_out);
2101 vector_stack_offset, location_stack_offset, rotation_stack_offset, scale_stack_offset),
2102 result_stack_offset);
2107 compiler.
parameter(
this,
"mapping_type");
2108 compiler.
add(
this,
"node_mapping");
2123RGBToBWNode::RGBToBWNode() :
ShaderNode(get_node_type()) {}
2143 compiler.
add(
this,
"node_rgb_to_bw");
2148const NodeType *ConvertNode::node_types[ConvertNode::MAX_TYPE][ConvertNode::MAX_TYPE];
2149bool ConvertNode::initialized = ConvertNode::register_types();
2153 return make_unique<ConvertNode>(
type->inputs[0].type,
type->outputs[0].type);
2156bool ConvertNode::register_types()
2158 const int num_types = 8;
2168 for (
size_t i = 0;
i < num_types;
i++) {
2171 const ustring from_value_name(
"value_" + from_name.string());
2173 for (
size_t j = 0; j < num_types; j++) {
2176 const ustring to_value_name(
"value_" + to_name.string());
2178 const string node_name =
"convert_" + from_name.string() +
"_to_" + to_name.string();
2181 type->register_input(from_value_name,
2189 type->register_output(to_value_name, to_value_name, to);
2194 node_types[from][to] =
type;
2210 else if (autoconvert) {
2221 value_string(other.value_string)
2274 if (prev->type == node_types[to][from]) {
2362 compiler.
add(
this,
"node_convert_from_float");
2365 compiler.
add(
this,
"node_convert_from_int");
2368 compiler.
add(
this,
"node_convert_from_color");
2371 compiler.
add(
this,
"node_convert_from_vector");
2374 compiler.
add(
this,
"node_convert_from_point");
2377 compiler.
add(
this,
"node_convert_from_normal");
2395 return (normal_in && normal_in->
link &&
2413 if (color_in->
link) {
2417 compiler.
add_node(NODE_CLOSURE_SET_WEIGHT, color);
2435 compiler.
add_node(normal_offset, data_y_offset, data_z_offset, data_w_offset);
2440 compile(compiler,
nullptr,
nullptr);
2486MetallicBsdfNode::MetallicBsdfNode() :
BsdfNode(get_node_type())
2496 return (!anisotropy_input->
link &&
fabsf(anisotropy) <= 1e-4f);
2543 compiler.
add_node(NODE_CLOSURE_BSDF,
2558 compiler.
parameter(
this,
"distribution");
2559 compiler.
parameter(
this,
"fresnel_type");
2560 compiler.
add(
this,
"node_metallic_bsdf");
2591GlossyBsdfNode::GlossyBsdfNode() :
BsdfNode(get_node_type())
2600 return (!anisotropy_input->
link &&
fabsf(anisotropy) <= 1e-4f);
2629 tangent = compiler.
is_linked(tangent) ? tangent :
nullptr;
2635 input(
"Anisotropy"),
2642 compiler,
input(
"Roughness"),
input(
"Anisotropy"),
input(
"Rotation"),
nullptr, tangent);
2648 compiler.
parameter(
this,
"distribution");
2649 compiler.
add(
this,
"node_glossy_bsdf");
2676GlassBsdfNode::GlassBsdfNode() :
BsdfNode(get_node_type())
2689 compiler.
parameter(
this,
"distribution");
2690 compiler.
add(
this,
"node_glass_bsdf");
2717RefractionBsdfNode::RefractionBsdfNode() :
BsdfNode(get_node_type())
2731 compiler.
parameter(
this,
"distribution");
2732 compiler.
add(
this,
"node_refraction_bsdf");
2757ToonBsdfNode::ToonBsdfNode() :
BsdfNode(get_node_type())
2772 compiler.
add(
this,
"node_toon_bsdf");
2796SheenBsdfNode::SheenBsdfNode() :
BsdfNode(get_node_type())
2809 compiler.
parameter(
this,
"distribution");
2810 compiler.
add(
this,
"node_sheen_bsdf");
2829DiffuseBsdfNode::DiffuseBsdfNode() :
BsdfNode(get_node_type())
2841 compiler.
add(
this,
"node_diffuse_bsdf");
2855 static NodeEnum subsurface_method_enum;
2860 "Subsurface Method",
2861 subsurface_method_enum,
2877 SOCKET_IN_FLOAT(subsurface_anisotropy,
"Subsurface Anisotropy", 0.0f);
2910PrincipledBsdfNode::PrincipledBsdfNode() :
BsdfBaseNode(get_node_type())
2922 if (emission_in->
link) {
2925 if (strength_in->
link) {
2941 return (emission_color_in->
link !=
nullptr ||
2951 (subsurface_scale_in->
link !=
nullptr || subsurface_scale != 0.0f);
2959 if (!tangent_in->
link) {
2979 compiler.
add_node(NODE_CLOSURE_SET_WEIGHT, weight);
2984 const int specular_ior_level_offset = compiler.
stack_assign(
input(
"Specular IOR Level"));
2986 const int diffuse_roughness_offset = compiler.
stack_assign(
input(
"Diffuse Roughness"));
2990 const int sheen_roughness_offset = compiler.
stack_assign(
input(
"Sheen Roughness"));
2993 const int coat_roughness_offset = compiler.
stack_assign(
input(
"Coat Roughness"));
2997 const int transmission_weight_offset = compiler.
stack_assign(
input(
"Transmission Weight"));
2998 const int anisotropic_rotation_offset = compiler.
stack_assign(
input(
"Anisotropic Rotation"));
2999 const int subsurface_radius_offset = compiler.
stack_assign(
input(
"Subsurface Radius"));
3000 const int subsurface_scale_offset = compiler.
stack_assign(
input(
"Subsurface Scale"));
3001 const int subsurface_ior_offset = compiler.
stack_assign(
input(
"Subsurface IOR"));
3002 const int subsurface_anisotropy_offset = compiler.
stack_assign(
input(
"Subsurface Anisotropy"));
3005 const int emission_color_offset = compiler.
stack_assign(
input(
"Emission Color"));
3006 const int thin_film_thickness_offset = compiler.
stack_assign(
input(
"Thin Film Thickness"));
3022 specular_ior_level_offset, roughness_offset, specular_tint_offset, anisotropic_offset),
3025 sheen_roughness_offset,
3026 diffuse_roughness_offset));
3030 ior_offset, transmission_weight_offset, anisotropic_rotation_offset, coat_normal_offset),
3034 coat_weight_offset, coat_roughness_offset, coat_ior_offset, coat_tint_offset));
3044 compiler.
add_node(subsurface_ior_offset,
3045 subsurface_radius_offset,
3046 subsurface_scale_offset,
3047 subsurface_anisotropy_offset);
3050 emission_strength_offset,
3051 emission_color_offset,
3052 thin_film_thickness_offset),
3055 thin_film_ior_offset);
3060 compiler.
parameter(
this,
"distribution");
3061 compiler.
parameter(
this,
"subsurface_method");
3062 compiler.
add(
this,
"node_principled_bsdf");
3085TranslucentBsdfNode::TranslucentBsdfNode() :
BsdfNode(get_node_type())
3097 compiler.
add(
this,
"node_translucent_bsdf");
3114TransparentBsdfNode::TransparentBsdfNode() :
BsdfNode(get_node_type())
3126 compiler.
add(
this,
"node_transparent_bsdf");
3146RayPortalBsdfNode::RayPortalBsdfNode() :
BsdfNode(get_node_type())
3158 compiler.
add(
this,
"node_ray_portal_bsdf");
3189SubsurfaceScatteringNode::SubsurfaceScatteringNode() :
BsdfNode(get_node_type())
3201 input(
"Anisotropy"),
3202 input(
"Roughness"));
3209 compiler.
add(
this,
"node_subsurface_scattering");
3216 return (normal_in->
link &&
3236EmissionNode::EmissionNode() :
ShaderNode(get_node_type()) {}
3240 ShaderInput *color_in =
input(
"Color");
3241 ShaderInput *strength_in =
input(
"Strength");
3243 if (color_in->
link || strength_in->
link) {
3248 compiler.
add_node(NODE_CLOSURE_SET_WEIGHT, color * strength);
3256 compiler.
add(
this,
"node_emission");
3264 if ((!color_in->
link && color ==
zero_float3()) || (!strength_in->
link && strength == 0.0f)) {
3284BackgroundNode::BackgroundNode() :
ShaderNode(get_node_type()) {}
3288 ShaderInput *color_in =
input(
"Color");
3289 ShaderInput *strength_in =
input(
"Strength");
3291 if (color_in->
link || strength_in->
link) {
3296 compiler.
add_node(NODE_CLOSURE_SET_WEIGHT, color * strength);
3304 compiler.
add(
this,
"node_background");
3312 if ((!color_in->
link && color ==
zero_float3()) || (!strength_in->
link && strength == 0.0f)) {
3331HoldoutNode::HoldoutNode() :
ShaderNode(get_node_type()) {}
3337 compiler.
add_node(NODE_CLOSURE_SET_WEIGHT, value);
3343 compiler.
add(
this,
"node_holdout");
3367AmbientOcclusionNode::AmbientOcclusionNode() :
ShaderNode(get_node_type()) {}
3371 ShaderInput *color_in =
input(
"Color");
3372 ShaderInput *distance_in =
input(
"Distance");
3373 ShaderInput *normal_in =
input(
"Normal");
3374 ShaderOutput *color_out =
output(
"Color");
3375 ShaderOutput *ao_out =
output(
"AO");
3383 compiler.
add_node(NODE_AMBIENT_OCCLUSION,
3399 compiler.
add(
this,
"node_ambient_occlusion");
3416 if (color_in->
link) {
3420 compiler.
add_node(NODE_CLOSURE_SET_WEIGHT, color);
3429 if (param2 ==
nullptr) {
3432 compiler.
add_node(NODE_CLOSURE_VOLUME,
3440 compiler.
add_node(NODE_CLOSURE_VOLUME,
3449 compile(compiler,
nullptr,
nullptr,
nullptr);
3472AbsorptionVolumeNode::AbsorptionVolumeNode() :
VolumeNode(get_node_type())
3484 compiler.
add(
this,
"node_absorption_volume");
3555 compiler.
add(
this,
"node_scatter_volume");
3588VolumeCoefficientsNode::VolumeCoefficientsNode() :
ScatterVolumeNode(get_node_type())
3596 ShaderInput *param1 =
nullptr;
3597 ShaderInput *param2 =
nullptr;
3601 param1 =
input(
"Anisotropy");
3604 param1 =
input(
"IOR");
3605 param2 =
input(
"Backscatter");
3610 param1 =
input(
"Anisotropy");
3611 param2 =
input(
"Alpha");
3614 param1 =
input(
"Diameter");
3620 ShaderInput *coeffs_in =
input(
"Scatter Coefficients");
3621 ShaderInput *absorption_coeffs_in =
input(
"Absorption Coefficients");
3622 ShaderInput *emission_coeffs_in =
input(
"Emission Coefficients");
3624 if (coeffs_in->
link) {
3628 compiler.
add_node(NODE_CLOSURE_SET_WEIGHT, scatter_coeffs);
3633 if (param2 ==
nullptr) {
3636 compiler.
add_node(NODE_VOLUME_COEFFICIENTS,
3647 compiler.
add_node(NODE_VOLUME_COEFFICIENTS,
3660 compiler.
add(
this,
"node_volume_coefficients");
3671 SOCKET_IN_STRING(temperature_attribute,
"Temperature Attribute", ustring());
3689PrincipledVolumeNode::PrincipledVolumeNode() :
VolumeNode(get_node_type())
3692 density_attribute = ustring(
"density");
3693 temperature_attribute = ustring(
"temperature");
3702 if (density_in->
link || density > 0.0f) {
3707 if (blackbody_in->
link || blackbody_intensity > 0.0f) {
3708 attributes->add_standard(temperature_attribute);
3729 if (color_in->
link) {
3733 compiler.
add_node(NODE_CLOSURE_SET_WEIGHT, color);
3736 compiler.
add_node(NODE_PRINCIPLED_VOLUME,
3756 compiler.
add_node(attr_density, attr_color, attr_temperature);
3762 density_attribute = ustring(
"geom:" + density_attribute.string());
3765 color_attribute = ustring(
"geom:" + color_attribute.string());
3768 temperature_attribute = ustring(
"geom:" + temperature_attribute.string());
3771 compiler.
add(
this,
"node_principled_volume");
3787 static NodeEnum parametrization_enum;
3800 absorption_coefficient,
"Absorption Coefficient",
make_float3(0.245531f, 0.52f, 1.365f));
3825PrincipledHairBsdfNode::PrincipledHairBsdfNode() :
BsdfBaseNode(get_node_type())
3834 if (aspect_ratio != 1.0f ||
input(
"Aspect Ratio")->link) {
3848 if (!
input(
"Random")->link) {
3882 const int absorption_coefficient_ofs = compiler.
stack_assign(
input(
"Absorption Coefficient"));
3914 compiler.
encode_uchar4(offset_ofs, ior_ofs, color_ofs, parametrization),
3920 tint_ofs, melanin_ofs, melanin_redness_ofs, absorption_coefficient_ofs),
3937 compiler.
encode_uchar4(coat_ofs, random_in_ofs, random_color_ofs, radial_roughness_ofs),
3957 compiler.
parameter(
this,
"parametrization");
3958 compiler.
add(
this,
"node_principled_hair_bsdf");
3984HairBsdfNode::HairBsdfNode() :
BsdfNode(get_node_type())
3993 ShaderInput *tangent =
input(
"Tangent");
3994 tangent = compiler.
is_linked(tangent) ? tangent :
nullptr;
3997 compiler,
input(
"RoughnessU"),
input(
"RoughnessV"),
input(
"Offset"),
nullptr, tangent);
4003 compiler.
add(
this,
"node_hair_bsdf");
4025GeometryNode::GeometryNode() :
ShaderNode(get_node_type())
4033 if (!
output(
"Tangent")->links.empty()) {
4036 if (!
output(
"Pointiness")->links.empty()) {
4039 if (!
output(
"Random Per Island")->links.empty()) {
4054 geom_node = NODE_GEOMETRY_BUMP_DX;
4055 attr_node = NODE_ATTR_BUMP_DX;
4058 geom_node = NODE_GEOMETRY_BUMP_DY;
4059 attr_node = NODE_ATTR_BUMP_DY;
4063 if (!
out->links.empty()) {
4069 if (!
out->links.empty()) {
4075 if (!
out->links.empty()) {
4081 if (!
out->links.empty()) {
4087 if (!
out->links.empty()) {
4093 if (!
out->links.empty()) {
4099 if (!
out->links.empty()) {
4104 if (!
out->links.empty()) {
4117 if (!
out->links.empty()) {
4133 compiler.
parameter(
"bump_offset",
"dx");
4136 compiler.
parameter(
"bump_offset",
"dy");
4139 compiler.
parameter(
"bump_offset",
"center");
4143 compiler.
add(
this,
"node_geometry");
4167TextureCoordinateNode::TextureCoordinateNode() :
ShaderNode(get_node_type()) {}
4173 if (!
output(
"Generated")->links.empty()) {
4176 if (!
output(
"UV")->links.empty()) {
4184 if (!
output(
"Generated")->links.empty()) {
4201 texco_node = NODE_TEX_COORD_BUMP_DX;
4202 attr_node = NODE_ATTR_BUMP_DX;
4203 geom_node = NODE_GEOMETRY_BUMP_DX;
4206 texco_node = NODE_TEX_COORD_BUMP_DY;
4207 attr_node = NODE_ATTR_BUMP_DY;
4208 geom_node = NODE_GEOMETRY_BUMP_DY;
4212 if (!
out->links.empty()) {
4242 if (!
out->links.empty()) {
4250 if (!
out->links.empty()) {
4268 if (!
out->links.empty()) {
4273 if (use_transform) {
4282 if (!
out->links.empty()) {
4290 if (!
out->links.empty()) {
4298 if (!
out->links.empty()) {
4315 compiler.
parameter(
"bump_offset",
"dx");
4318 compiler.
parameter(
"bump_offset",
"dy");
4321 compiler.
parameter(
"bump_offset",
"center");
4326 compiler.
parameter(
"is_background",
true);
4331 compiler.
parameter(
this,
"use_transform");
4333 compiler.
parameter(
"object_itfm", ob_itfm);
4337 compiler.
add(
this,
"node_texture_coordinate");
4354UVMapNode::UVMapNode() :
ShaderNode(get_node_type()) {}
4360 if (!
output(
"UV")->links.empty()) {
4361 if (!attribute.empty()) {
4382 texco_node = NODE_TEX_COORD_BUMP_DX;
4383 attr_node = NODE_ATTR_BUMP_DX;
4386 texco_node = NODE_TEX_COORD_BUMP_DY;
4387 attr_node = NODE_ATTR_BUMP_DY;
4390 if (!
out->links.empty()) {
4398 if (!attribute.empty()) {
4417 compiler.
parameter(
"bump_offset",
"dx");
4420 compiler.
parameter(
"bump_offset",
"dy");
4423 compiler.
parameter(
"bump_offset",
"center");
4429 compiler.
add(
this,
"node_uv_map");
4456LightPathNode::LightPathNode() :
ShaderNode(get_node_type()) {}
4463 if (!
out->links.empty()) {
4468 if (!
out->links.empty()) {
4473 if (!
out->links.empty()) {
4478 if (!
out->links.empty()) {
4483 if (!
out->links.empty()) {
4488 if (!
out->links.empty()) {
4493 if (!
out->links.empty()) {
4498 if (!
out->links.empty()) {
4503 if (!
out->links.empty()) {
4508 if (!
out->links.empty()) {
4513 if (!
out->links.empty()) {
4518 if (!
out->links.empty()) {
4523 if (!
out->links.empty()) {
4528 if (!
out->links.empty()) {
4535 compiler.
add(
this,
"node_light_path");
4554LightFalloffNode::LightFalloffNode() :
ShaderNode(get_node_type()) {}
4558 ShaderInput *strength_in =
input(
"Strength");
4559 ShaderInput *smooth_in =
input(
"Smooth");
4561 ShaderOutput *
out =
output(
"Quadratic");
4562 if (!
out->links.empty()) {
4563 compiler.
add_node(NODE_LIGHT_FALLOFF,
4571 if (!
out->links.empty()) {
4572 compiler.
add_node(NODE_LIGHT_FALLOFF,
4580 if (!
out->links.empty()) {
4581 compiler.
add_node(NODE_LIGHT_FALLOFF,
4591 compiler.
add(
this,
"node_light_falloff");
4610ObjectInfoNode::ObjectInfoNode() :
ShaderNode(get_node_type()) {}
4615 if (!
out->links.empty()) {
4620 if (!
out->links.empty()) {
4625 if (!
out->links.empty()) {
4630 if (!
out->links.empty()) {
4635 if (!
out->links.empty()) {
4640 if (!
out->links.empty()) {
4647 compiler.
add(
this,
"node_object_info");
4662 SOCKET_OUT_QUATERNION(rotation,
"Rotation");
4671ParticleInfoNode::ParticleInfoNode() :
ShaderNode(get_node_type()) {}
4675 if (!
output(
"Index")->links.empty()) {
4678 if (!
output(
"Random")->links.empty()) {
4681 if (!
output(
"Age")->links.empty()) {
4684 if (!
output(
"Lifetime")->links.empty()) {
4687 if (!
output(
"Location")->links.empty()) {
4691 if (!
output(
"Rotation")->links.empty())
4694 if (!
output(
"Size")->links.empty()) {
4697 if (!
output(
"Velocity")->links.empty()) {
4700 if (!
output(
"Angular Velocity")->links.empty()) {
4712 if (!
out->links.empty()) {
4717 if (!
out->links.empty()) {
4722 if (!
out->links.empty()) {
4727 if (!
out->links.empty()) {
4732 if (!
out->links.empty()) {
4739 if (!
out->links.empty()) {
4745 if (!
out->links.empty()) {
4750 if (!
out->links.empty()) {
4755 if (!
out->links.empty()) {
4763 compiler.
add(
this,
"node_particle_info");
4782HairInfoNode::HairInfoNode() :
ShaderNode(get_node_type()) {}
4789 if (!intercept_out->
links.empty()) {
4793 if (!
output(
"Length")->links.empty()) {
4797 if (!
output(
"Random")->links.empty()) {
4810 if (!
out->links.empty()) {
4815 if (!
out->links.empty()) {
4824 if (!
out->links.empty()) {
4833 if (!
out->links.empty()) {
4838 if (!
out->links.empty()) {
4843 if (!
out->links.empty()) {
4854 compiler.
add(
this,
"node_hair_info");
4870PointInfoNode::PointInfoNode() :
ShaderNode(get_node_type()) {}
4875 if (!
output(
"Random")->links.empty()) {
4888 if (!
out->links.empty()) {
4893 if (!
out->links.empty()) {
4898 if (!
out->links.empty()) {
4909 compiler.
add(
this,
"node_point_info");
4926VolumeInfoNode::VolumeInfoNode() :
ShaderNode(get_node_type()) {}
4934 if (!
output(
"Color")->links.empty()) {
4937 if (!
output(
"Density")->links.empty()) {
4940 if (!
output(
"Flame")->links.empty()) {
4943 if (!
output(
"Temperature")->links.empty()) {
4954 if (!color_out->
links.empty()) {
4956 attr->set_attribute(ustring(
"color"));
4961 if (!density_out->
links.empty()) {
4963 attr->set_attribute(ustring(
"density"));
4968 if (!flame_out->
links.empty()) {
4970 attr->set_attribute(ustring(
"flame"));
4975 if (!temperature_out->
links.empty()) {
4977 attr->set_attribute(ustring(
"temperature"));
4997VertexColorNode::VertexColorNode() :
ShaderNode(get_node_type()) {}
5001 if (!(
output(
"Color")->links.empty() &&
output(
"Alpha")->links.empty())) {
5002 if (!layer_name.empty()) {
5018 if (!layer_name.empty()) {
5019 layer_id = compiler.
attribute(layer_name);
5028 node = NODE_VERTEX_COLOR_BUMP_DX;
5031 node = NODE_VERTEX_COLOR_BUMP_DY;
5034 node = NODE_VERTEX_COLOR;
5047 compiler.
parameter(
"bump_offset",
"dx");
5050 compiler.
parameter(
"bump_offset",
"dy");
5053 compiler.
parameter(
"bump_offset",
"center");
5057 if (layer_name.empty()) {
5058 compiler.
parameter(
"layer_name", ustring(
"geom:vertex_color"));
5062 compiler.
parameter(
"name", (
string(
"geom:") + layer_name.c_str()).c_str());
5065 compiler.
parameter(
"layer_name", layer_name.c_str());
5069 compiler.
add(
this,
"node_vertex_color");
5084ValueNode::ValueNode() :
ShaderNode(get_node_type()) {}
5100 compiler.
parameter(
"value_value", value);
5101 compiler.
add(
this,
"node_value");
5116ColorNode::ColorNode() :
ShaderNode(get_node_type()) {}
5127 if (!color_out->
links.empty()) {
5129 compiler.
add_node(NODE_VALUE_V, value);
5137 compiler.
add(
this,
"node_value");
5153AddClosureNode::AddClosureNode() :
ShaderNode(get_node_type())
5165 compiler.
add(
this,
"node_add_closure");
5174 if (!closure1_in->
link) {
5177 else if (!closure2_in->
link) {
5197MixClosureNode::MixClosureNode() :
ShaderNode(get_node_type())
5209 compiler.
add(
this,
"node_mix_closure");
5219 if (closure1_in->
link == closure2_in->
link) {
5224 else if (!fac_in->
link) {
5230 else if (fac >= 1.0f) {
5251MixClosureWeightNode::MixClosureWeightNode() :
ShaderNode(get_node_type()) {}
5255 ShaderInput *weight_in =
input(
"Weight");
5256 ShaderInput *fac_in =
input(
"Fac");
5257 ShaderOutput *weight1_out =
output(
"Weight1");
5258 ShaderOutput *weight2_out =
output(
"Weight2");
5260 compiler.
add_node(NODE_MIX_CLOSURE,
5286InvertNode::InvertNode() :
ShaderNode(get_node_type()) {}
5293 if (!fac_in->
link) {
5295 if (!color_in->
link) {
5299 else if (fac == 0.0f) {
5319 compiler.
add(
this,
"node_invert");
5361MixNode::MixNode() :
ShaderNode(get_node_type()) {}
5365 ShaderInput *fac_in =
input(
"Fac");
5366 ShaderInput *color1_in =
input(
"Color1");
5367 ShaderInput *color2_in =
input(
"Color2");
5368 ShaderOutput *color_out =
output(
"Color");
5386 compiler.
add(
this,
"node_mix");
5395 folder.
fold_mix(mix_type, use_clamp);
5438MixColorNode::MixColorNode() :
ShaderNode(get_node_type()) {}
5442 ShaderInput *fac_in =
input(
"Factor");
5443 ShaderInput *a_in =
input(
"A");
5444 ShaderInput *b_in =
input(
"B");
5445 ShaderOutput *result_out =
output(
"Result");
5447 const int fac_in_stack_offset = compiler.
stack_assign(fac_in);
5448 const int a_in_stack_offset = compiler.
stack_assign(a_in);
5449 const int b_in_stack_offset = compiler.
stack_assign(b_in);
5453 compiler.
encode_uchar4(use_clamp, blend_type, use_clamp_result),
5454 compiler.
encode_uchar4(fac_in_stack_offset, a_in_stack_offset, b_in_stack_offset),
5462 compiler.
parameter(
this,
"use_clamp_result");
5463 compiler.
add(
this,
"node_mix_color");
5470 fac =
clamp(fac, 0.0f, 1.0f);
5494MixFloatNode::MixFloatNode() :
ShaderNode(get_node_type()) {}
5498 ShaderInput *fac_in =
input(
"Factor");
5499 ShaderInput *a_in =
input(
"A");
5500 ShaderInput *b_in =
input(
"B");
5501 ShaderOutput *result_out =
output(
"Result");
5503 const int fac_in_stack_offset = compiler.
stack_assign(fac_in);
5504 const int a_in_stack_offset = compiler.
stack_assign(a_in);
5505 const int b_in_stack_offset = compiler.
stack_assign(b_in);
5510 compiler.
encode_uchar4(fac_in_stack_offset, a_in_stack_offset, b_in_stack_offset),
5517 compiler.
add(
this,
"node_mix_float");
5524 fac =
clamp(fac, 0.0f, 1.0f);
5549MixVectorNode::MixVectorNode() :
ShaderNode(get_node_type()) {}
5553 ShaderInput *fac_in =
input(
"Factor");
5554 ShaderInput *a_in =
input(
"A");
5555 ShaderInput *b_in =
input(
"B");
5556 ShaderOutput *result_out =
output(
"Result");
5558 const int fac_in_stack_offset = compiler.
stack_assign(fac_in);
5559 const int a_in_stack_offset = compiler.
stack_assign(a_in);
5560 const int b_in_stack_offset = compiler.
stack_assign(b_in);
5564 compiler.
encode_uchar4(use_clamp, fac_in_stack_offset, a_in_stack_offset, b_in_stack_offset),
5571 compiler.
add(
this,
"node_mix_vector");
5578 fac =
clamp(fac, 0.0f, 1.0f);
5603MixVectorNonUniformNode::MixVectorNonUniformNode() :
ShaderNode(get_node_type()) {}
5607 ShaderInput *fac_in =
input(
"Factor");
5608 ShaderInput *a_in =
input(
"A");
5609 ShaderInput *b_in =
input(
"B");
5610 ShaderOutput *result_out =
output(
"Result");
5612 const int fac_in_stack_offset = compiler.
stack_assign(fac_in);
5613 const int a_in_stack_offset = compiler.
stack_assign(a_in);
5614 const int b_in_stack_offset = compiler.
stack_assign(b_in);
5617 NODE_MIX_VECTOR_NON_UNIFORM,
5618 compiler.
encode_uchar4(use_clamp, fac_in_stack_offset, a_in_stack_offset, b_in_stack_offset),
5625 compiler.
add(
this,
"node_mix_vector_non_uniform");
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");
5708CombineRGBNode::CombineRGBNode() :
ShaderNode(get_node_type()) {}
5736 compiler.
add(
this,
"node_combine_rgb");
5754CombineXYZNode::CombineXYZNode() :
ShaderNode(get_node_type()) {}
5782 compiler.
add(
this,
"node_combine_xyz");
5800CombineHSVNode::CombineHSVNode() :
ShaderNode(get_node_type()) {}
5816 compiler.
add_node(NODE_COMBINE_HSV,
5825 compiler.
add(
this,
"node_combine_hsv");
5841GammaNode::GammaNode() :
ShaderNode(get_node_type()) {}
5857 else if (folder.
is_one(gamma_in)) {
5877 compiler.
add(
this,
"node_gamma");
5895BrightContrastNode::BrightContrastNode() :
ShaderNode(get_node_type()) {}
5911 compiler.
add_node(NODE_BRIGHTCONTRAST,
5920 compiler.
add(
this,
"node_brightness");
5944SeparateColorNode::SeparateColorNode() :
ShaderNode(get_node_type()) {}
5951 for (
int channel = 0; channel < 3; channel++) {
5967 const int color_stack_offset = compiler.
stack_assign(color_in);
5968 const int red_stack_offset = compiler.
stack_assign(red_out);
5969 const int green_stack_offset = compiler.
stack_assign(green_out);
5970 const int blue_stack_offset = compiler.
stack_assign(blue_out);
5973 NODE_SEPARATE_COLOR,
5976 compiler.
encode_uchar4(red_stack_offset, green_stack_offset, blue_stack_offset));
5982 compiler.
add(
this,
"node_separate_color");
6000SeparateRGBNode::SeparateRGBNode() :
ShaderNode(get_node_type()) {}
6005 for (
int channel = 0; channel < 3; channel++) {
6033 compiler.
add(
this,
"node_separate_rgb");
6051SeparateXYZNode::SeparateXYZNode() :
ShaderNode(get_node_type()) {}
6056 for (
int channel = 0; channel < 3; channel++) {
6084 compiler.
add(
this,
"node_separate_xyz");
6102SeparateHSVNode::SeparateHSVNode() :
ShaderNode(get_node_type()) {}
6109 for (
int channel = 0; channel < 3; channel++) {
6125 compiler.
add_node(NODE_SEPARATE_HSV,
6134 compiler.
add(
this,
"node_separate_hsv");
6154HSVNode::HSVNode() :
ShaderNode(get_node_type()) {}
6158 ShaderInput *hue_in =
input(
"Hue");
6159 ShaderInput *saturation_in =
input(
"Saturation");
6160 ShaderInput *value_in =
input(
"Value");
6161 ShaderInput *fac_in =
input(
"Fac");
6162 ShaderInput *color_in =
input(
"Color");
6163 ShaderOutput *color_out =
output(
"Color");
6176 compiler.
add(
this,
"node_hsv");
6195AttributeNode::AttributeNode() :
ShaderNode(get_node_type()) {}
6204 if (!color_out->
links.empty() || !vector_out->
links.empty() || !fac_out->
links.empty() ||
6205 !alpha_out->
links.empty())
6227 attr_node = NODE_ATTR_BUMP_DX;
6230 attr_node = NODE_ATTR_BUMP_DY;
6233 if (!color_out->
links.empty() || !vector_out->
links.empty()) {
6234 if (!color_out->
links.empty()) {
6241 if (!vector_out->
links.empty()) {
6250 if (!fac_out->
links.empty()) {
6258 if (!alpha_out->
links.empty()) {
6270 compiler.
parameter(
"bump_offset",
"dx");
6273 compiler.
parameter(
"bump_offset",
"dy");
6276 compiler.
parameter(
"bump_offset",
"center");
6281 compiler.
parameter(
"name", (
string(
"geom:") + attribute.c_str()).c_str());
6284 compiler.
parameter(
"name", attribute.c_str());
6287 compiler.
add(
this,
"node_attribute");
6303CameraNode::CameraNode() :
ShaderNode(get_node_type()) {}
6307 ShaderOutput *vector_out =
output(
"View Vector");
6308 ShaderOutput *z_depth_out =
output(
"View Z Depth");
6309 ShaderOutput *distance_out =
output(
"View Distance");
6319 compiler.
add(
this,
"node_camera");
6337FresnelNode::FresnelNode() :
ShaderNode(get_node_type()) {}
6341 ShaderInput *normal_in =
input(
"Normal");
6342 ShaderInput *IOR_in =
input(
"IOR");
6343 ShaderOutput *fac_out =
output(
"Fac");
6354 compiler.
add(
this,
"node_fresnel");
6373LayerWeightNode::LayerWeightNode() :
ShaderNode(get_node_type()) {}
6377 ShaderInput *normal_in =
input(
"Normal");
6378 ShaderInput *blend_in =
input(
"Blend");
6379 ShaderOutput *fresnel_out =
output(
"Fresnel");
6380 ShaderOutput *facing_out =
output(
"Facing");
6382 if (!fresnel_out->
links.empty()) {
6383 compiler.
add_node(NODE_LAYER_WEIGHT,
6391 if (!facing_out->
links.empty()) {
6392 compiler.
add_node(NODE_LAYER_WEIGHT,
6403 compiler.
add(
this,
"node_layer_weight");
6419WireframeNode::WireframeNode() :
ShaderNode(get_node_type()) {}
6423 ShaderInput *size_in =
input(
"Size");
6424 ShaderOutput *fac_out =
output(
"Fac");
6442 compiler.
parameter(
"bump_offset",
"dx");
6445 compiler.
parameter(
"bump_offset",
"dy");
6448 compiler.
parameter(
"bump_offset",
"center");
6452 compiler.
parameter(
this,
"use_pixel_size");
6453 compiler.
add(
this,
"node_wireframe");
6468WavelengthNode::WavelengthNode() :
ShaderNode(get_node_type()) {}
6472 ShaderInput *wavelength_in =
input(
"Wavelength");
6473 ShaderOutput *color_out =
output(
"Color");
6481 compiler.
add(
this,
"node_wavelength");
6496BlackbodyNode::BlackbodyNode() :
ShaderNode(get_node_type()) {}
6518 compiler.
add(
this,
"node_blackbody");
6535OutputNode::OutputNode() :
ShaderNode(get_node_type())
6543 ShaderInput *displacement_in =
input(
"Displacement");
6545 if (displacement_in->
link) {
6554 compiler.
add(
this,
"node_output_surface");
6557 compiler.
add(
this,
"node_output_volume");
6560 compiler.
add(
this,
"node_output_displacement");
6590MapRangeNode::MapRangeNode() :
ShaderNode(get_node_type()) {}
6596 if (!result_out->
links.empty()) {
6599 graph->
relink(result_out, clamp_node->
output(
"Result"));
6600 graph->
connect(result_out, clamp_node->
input(
"Value"));
6601 if (
input(
"To Min")->link) {
6605 clamp_node->set_min(to_min);
6607 if (
input(
"To Max")->link) {
6611 clamp_node->set_max(to_max);
6627 const int value_stack_offset = compiler.
stack_assign(value_in);
6632 const int steps_stack_offset = compiler.
stack_assign(steps_in);
6633 const int result_stack_offset = compiler.
stack_assign(result_out);
6639 from_min_stack_offset, from_max_stack_offset, to_min_stack_offset, to_max_stack_offset),
6640 compiler.
encode_uchar4(range_type, steps_stack_offset, result_stack_offset));
6652 compiler.
add(
this,
"node_map_range");
6681VectorMapRangeNode::VectorMapRangeNode() :
ShaderNode(get_node_type()) {}
6695 const int value_stack_offset = compiler.
stack_assign(vector_in);
6696 const int from_min_stack_offset = compiler.
stack_assign(from_min_in);
6697 const int from_max_stack_offset = compiler.
stack_assign(from_max_in);
6698 const int to_min_stack_offset = compiler.
stack_assign(to_min_in);
6699 const int to_max_stack_offset = compiler.
stack_assign(to_max_in);
6700 const int steps_stack_offset = compiler.
stack_assign(steps_in);
6701 const int result_stack_offset = compiler.
stack_assign(vector_out);
6704 NODE_VECTOR_MAP_RANGE,
6707 from_min_stack_offset, from_max_stack_offset, to_min_stack_offset, to_max_stack_offset),
6708 compiler.
encode_uchar4(steps_stack_offset, use_clamp, range_type, result_stack_offset));
6715 compiler.
add(
this,
"node_vector_map_range");
6738ClampNode::ClampNode() :
ShaderNode(get_node_type()) {}
6759 const int value_stack_offset = compiler.
stack_assign(value_in);
6760 const int min_stack_offset = compiler.
stack_assign(min_in);
6761 const int max_stack_offset = compiler.
stack_assign(max_in);
6762 const int result_stack_offset = compiler.
stack_assign(result_out);
6766 compiler.
encode_uchar4(min_stack_offset, max_stack_offset, clamp_type),
6767 result_stack_offset);
6774 compiler.
add(
this,
"node_clamp");
6791OutputAOVNode::OutputAOVNode() :
ShaderNode(get_node_type())
6805 input(
"Value")->disconnect();
6808 input(
"Color")->disconnect();
6890MathNode::MathNode() :
ShaderNode(get_node_type()) {}
6896 if (!result_out->
links.empty()) {
6899 clamp_node->set_min(0.0f);
6900 clamp_node->set_max(1.0f);
6901 graph->
relink(result_out, clamp_node->
output(
"Result"));
6902 graph->
connect(result_out, clamp_node->
input(
"Value"));
6924 const int value1_stack_offset = compiler.
stack_assign(value1_in);
6925 const int value2_stack_offset = compiler.
stack_assign(value2_in);
6926 const int value3_stack_offset = compiler.
stack_assign(value3_in);
6927 const int value_stack_offset = compiler.
stack_assign(value_out);
6932 compiler.
encode_uchar4(value1_stack_offset, value2_stack_offset, value3_stack_offset),
6933 value_stack_offset);
6939 compiler.
add(
this,
"node_math");
6996VectorMathNode::VectorMathNode() :
ShaderNode(get_node_type()) {}
7025 const int vector1_stack_offset = compiler.
stack_assign(vector1_in);
7026 const int vector2_stack_offset = compiler.
stack_assign(vector2_in);
7027 const int param1_stack_offset = compiler.
stack_assign(param1_in);
7036 const int vector3_stack_offset = compiler.
stack_assign(vector3_in);
7040 compiler.
encode_uchar4(vector1_stack_offset, vector2_stack_offset, param1_stack_offset),
7041 compiler.
encode_uchar4(value_stack_offset, vector_stack_offset));
7042 compiler.
add_node(vector3_stack_offset);
7048 compiler.
encode_uchar4(vector1_stack_offset, vector2_stack_offset, param1_stack_offset),
7049 compiler.
encode_uchar4(value_stack_offset, vector_stack_offset));
7056 compiler.
add(
this,
"node_vector_math");
7085VectorRotateNode::VectorRotateNode() :
ShaderNode(get_node_type()) {}
7089 ShaderInput *vector_in =
input(
"Vector");
7090 ShaderInput *rotation_in =
input(
"Rotation");
7091 ShaderInput *center_in =
input(
"Center");
7092 ShaderInput *axis_in =
input(
"Axis");
7093 ShaderInput *angle_in =
input(
"Angle");
7094 ShaderOutput *vector_out =
output(
"Vector");
7096 compiler.
add_node(NODE_VECTOR_ROTATE,
7109 compiler.
parameter(
this,
"rotate_type");
7111 compiler.
add(
this,
"node_vector_rotate");
7139VectorTransformNode::VectorTransformNode() :
ShaderNode(get_node_type()) {}
7143 ShaderInput *vector_in =
input(
"Vector");
7144 ShaderOutput *vector_out =
output(
"Vector");
7147 NODE_VECTOR_TRANSFORM,
7148 compiler.
encode_uchar4(transform_type, convert_from, convert_to),
7154 compiler.
parameter(
this,
"transform_type");
7155 compiler.
parameter(
this,
"convert_from");
7157 compiler.
add(
this,
"node_vector_transform");
7186BumpNode::BumpNode() :
ShaderNode(get_node_type())
7193 ShaderInput *center_in =
input(
"SampleCenter");
7194 ShaderInput *dx_in =
input(
"SampleX");
7195 ShaderInput *dy_in =
input(
"SampleY");
7196 ShaderInput *normal_in =
input(
"Normal");
7197 ShaderInput *strength_in =
input(
"Strength");
7198 ShaderInput *distance_in =
input(
"Distance");
7199 ShaderOutput *normal_out =
output(
"Normal");
7219 compiler.
parameter(
this,
"use_object_space");
7220 compiler.
add(
this,
"node_bump");
7228 if (height_in->
link ==
nullptr) {
7229 if (normal_in->
link ==
nullptr) {
7251 if (curves.size() == 0) {
7265 else if (!fac_in->
link && fac == 0.0f) {
7276 if (curves.size() == 0) {
7291 for (
int i = 0;
i < curves.size();
i++) {
7298 if (curves.size() == 0) {
7305 compiler.
parameter(
this,
"extrapolate");
7338RGBCurvesNode::RGBCurvesNode() :
CurvesNode(get_node_type()) {}
7374VectorCurvesNode::VectorCurvesNode() :
CurvesNode(get_node_type()) {}
7410FloatCurveNode::FloatCurveNode() :
ShaderNode(get_node_type()) {}
7419 if (curve.size() == 0) {
7423 const float pos = (value - min_x) / (max_x - min_x);
7429 else if (!fac_in->
link && fac == 0.0f) {
7437 if (curve.size() == 0) {
7441 ShaderInput *value_in =
input(
"Value");
7442 ShaderInput *fac_in =
input(
"Factor");
7443 ShaderOutput *value_out =
output(
"Value");
7445 compiler.
add_node(NODE_FLOAT_CURVE,
7454 for (
int i = 0;
i < curve.size();
i++) {
7461 if (curve.size() == 0) {
7468 compiler.
parameter(
this,
"extrapolate");
7469 compiler.
add(
this,
"node_float_curve");
7490RGBRampNode::RGBRampNode() :
ShaderNode(get_node_type()) {}
7494 if (ramp.size() == 0 || ramp.size() != ramp_alpha.size()) {
7499 const float f =
clamp(fac, 0.0f, 1.0f) * (ramp.size() - 1);
7502 const int i =
clamp((
int)f, 0, ramp.size() - 1);
7503 const float t = f - (float)
i;
7505 const bool use_lerp = interpolate && t > 0.0f;
7513 ramp_alpha.data(), fac, use_lerp,
false, ramp_alpha.size());
7521 if (ramp.size() == 0 || ramp.size() != ramp_alpha.size()) {
7525 ShaderInput *fac_in =
input(
"Fac");
7526 ShaderOutput *color_out =
output(
"Color");
7527 ShaderOutput *alpha_out =
output(
"Alpha");
7536 for (
int i = 0;
i < ramp.size();
i++) {
7543 if (ramp.size() == 0 || ramp.size() != ramp_alpha.size()) {
7548 compiler.
parameter_array(
"ramp_alpha", ramp_alpha.data(), ramp_alpha.size());
7549 compiler.
parameter(
this,
"interpolate");
7551 compiler.
add(
this,
"node_rgb_ramp");
7566SetNormalNode::SetNormalNode() :
ShaderNode(get_node_type()) {}
7570 ShaderInput *direction_in =
input(
"Direction");
7571 ShaderOutput *normal_out =
output(
"Normal");
7573 compiler.
add_node(NODE_CLOSURE_SET_NORMAL,
7580 compiler.
add(
this,
"node_set_normal");
7588 has_emission =
false;
7628 char *node_memory = (
char *)
operator new(node_size + inputs_size);
7629 memset(node_memory, 0, node_size + inputs_size);
7635 memcpy(node_memory + node_size, (
char *)from + node_size, inputs_size);
7645 const size_t num_inputs =
type->inputs.size();
7653 const size_t offset = memory - (
char *)
this;
7702NormalMapNode::NormalMapNode() :
ShaderNode(get_node_type()) {}
7707 if (attribute.empty()) {
7712 attributes->add(ustring((
string(attribute.c_str()) +
".tangent").c_str()));
7713 attributes->add(ustring((
string(attribute.c_str()) +
".tangent_sign").c_str()));
7729 if (attribute.empty()) {
7734 attr = compiler.
attribute(ustring((
string(attribute.c_str()) +
".tangent").c_str()));
7736 ustring((
string(attribute.c_str()) +
".tangent_sign").c_str()));
7752 if (attribute.empty()) {
7753 compiler.
parameter(
"attr_name", ustring(
"geom:tangent"));
7754 compiler.
parameter(
"attr_sign_name", ustring(
"geom:tangent_sign"));
7757 compiler.
parameter(
"attr_name", ustring((
string(attribute.c_str()) +
".tangent").c_str()));
7759 ustring((
string(attribute.c_str()) +
".tangent_sign").c_str()));
7764 compiler.
add(
this,
"node_normal_map");
7773 static NodeEnum direction_type_enum;
7791TangentNode::TangentNode() :
ShaderNode(get_node_type()) {}
7797 if (attribute.empty()) {
7801 attributes->add(ustring((
string(attribute.c_str()) +
".tangent").c_str()));
7818 if (attribute.empty()) {
7822 attr = compiler.
attribute(ustring((
string(attribute.c_str()) +
".tangent").c_str()));
7838 if (attribute.empty()) {
7839 compiler.
parameter(
"attr_name", ustring(
"geom:tangent"));
7842 compiler.
parameter(
"attr_name", ustring((
string(attribute.c_str()) +
".tangent").c_str()));
7846 compiler.
parameter(
this,
"direction_type");
7848 compiler.
add(
this,
"node_tangent");
7867BevelNode::BevelNode() :
ShaderNode(get_node_type()) {}
7871 ShaderInput *radius_in =
input(
"Radius");
7872 ShaderInput *normal_in =
input(
"Normal");
7873 ShaderOutput *normal_out =
output(
"Normal");
7885 compiler.
add(
this,
"node_bevel");
7910DisplacementNode::DisplacementNode() :
ShaderNode(get_node_type()) {}
7915 if ((height - midlevel == 0.0f) || (scale == 0.0f)) {
7929 compiler.
add_node(NODE_DISPLACEMENT,
7941 compiler.
add(
this,
"node_displacement");
7967VectorDisplacementNode::VectorDisplacementNode() :
ShaderNode(get_node_type()) {}
7981 if (attribute.empty()) {
7986 attributes->add(ustring((
string(attribute.c_str()) +
".tangent").c_str()));
7987 attributes->add(ustring((
string(attribute.c_str()) +
".tangent_sign").c_str()));
8004 if (attribute.empty()) {
8009 attr = compiler.
attribute(ustring((
string(attribute.c_str()) +
".tangent").c_str()));
8011 ustring((
string(attribute.c_str()) +
".tangent_sign").c_str()));
8015 compiler.
add_node(NODE_VECTOR_DISPLACEMENT,
8029 if (attribute.empty()) {
8030 compiler.
parameter(
"attr_name", ustring(
"geom:tangent"));
8031 compiler.
parameter(
"attr_sign_name", ustring(
"geom:tangent_sign"));
8034 compiler.
parameter(
"attr_name", ustring((
string(attribute.c_str()) +
".tangent").c_str()));
8036 ustring((
string(attribute.c_str()) +
".tangent_sign").c_str()));
8041 compiler.
add(
this,
"node_vector_displacement");
KDTree *BLI_kdtree_nd_ new(unsigned int nodes_len_capacity)
MINLINE float signf(float f)
void rgb_to_hsv(float r, float g, float b, float *r_h, float *r_s, float *r_v)
void hsv_to_rgb(float h, float s, float v, float *r_r, float *r_g, float *r_b)
@ 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_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_MAPPING_TYPE_POINT
@ NODE_MAPPING_TYPE_VECTOR
@ NODE_MAPPING_TYPE_TEXTURE
@ NODE_MAPPING_TYPE_NORMAL
@ NODE_MATH_FLOORED_MODULO
@ NODE_MAP_RANGE_SMOOTHERSTEP
@ NODE_MAP_RANGE_SMOOTHSTEP
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
ATTR_WARN_UNUSED_RESULT const BMVert * v
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 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)
void expand(ShaderGraph *graph) override
void constant_fold(const ConstantFolder &folder) override
void expand(ShaderGraph *graph) override
void constant_fold(const ConstantFolder &folder) override
void constant_fold(const ConstantFolder &folder) override
void constant_fold(const ConstantFolder &folder) override
void constant_fold(const ConstantFolder &folder) override
void constant_fold(const ConstantFolder &folder) override
void constant_fold(const ConstantFolder &folder) 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
ImageParams image_params() const
void attributes(Shader *shader, AttributeRequestSet *attributes) override
ShaderNode * clone(ShaderGraph *graph) const override
~PointDensityTextureNode() 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_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_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
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
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
void expand(ShaderGraph *graph) override
void constant_fold(const ConstantFolder &folder) 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 CLOSURE_WEIGHT_CUTOFF
#define CCL_NAMESPACE_END
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)
VecBase< float, 3 > float3
constexpr T clamp(T, U, U) RET
float distance(VecOp< float, D >, VecOp< float, D >) RET
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_TEX_VOXEL_SPACE_WORLD
@ NODE_TEX_VOXEL_SPACE_OBJECT
@ 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_UV_TANGENT_SIGN
@ 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 sqr(const float a)
ccl_device_inline float interp(const float a, const float b, const float t)
ccl_device_inline float average(const float2 a)
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_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 float sky_perez_function(const float lam[6], float theta, const float gamma)
static void sky_texture_precompute_nishita(SunSky *sunsky, 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 dust_density)
#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)
void SKY_nishita_skymodel_precompute_sun(float sun_elevation, float angular_diameter, float altitude, float air_density, float dust_density, float *r_pixel_bottom, float *r_pixel_top)
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()
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)
@ IMAGE_ALPHA_CHANNEL_PACKED
@ IMAGE_ALPHA_UNASSOCIATED