Note: This is an archived version of the Blender Developer Wiki (archived 2024). The current developer documentation is available on developer.blender.org/docs.

User:KevinDietrich/CyclesAPI

Cycles node socket API refactor

In an effort to improve the Cycles API and to better detect how a Node has changed, Node socket properties are now private and should be queried or modified through specific methods. For each Node socket, the following methods are defined:

  • get_x
  • set_x
  • x_is_modified
  • tag_x_modified

Where x is the name of the socket. This name, for scalar or array sockets, is the same as the current class member, so Mesh::verts will give Mesh::get_verts, Mesh::set_verts, etc. For class members that are structures, like Camera::border (of BoundBox2D type), the name is the concatenation of the names of the property and its related member using snake case, so camera.border.x becomes camera.get_border_x(), etc.

The set_x methods will check if the value is different than the one previously set, and if so, tag the socket as modified, which can be checked using the x_is_modified() method. Additionnaly, tag_x_modified() can be used to manually tag a socket as modified.

Some other class members were removed from public access, while other were transformed into sockets where it made sense. Below is an exhaustive list of changes for specific Nodes:

Background


  • Background::need_update was removed, Background::is_modified() should be used instead.
  • Background::modified(Background) was removed, Background::is_modified() should be used instead.

Camera


  • Camera::type was renamed to Camera::camera_type
  • Camera::width, Camera::height, and Camera::resolution have been removed from public access, and are not accessible through sockets. Camera::set_screen_size_and_resolution can be used to modify those properties.
  • Camera::modified(Camera) and Camera::motion_modified(Camera) were removed, checking for this should be done via the related sockets' update flag status.
  • Camera::tag_update() was removed, Camera::tag_modified() should be used instead, if the intent is to tag every socket as dirty.
  • Camera::need_update was removed, Camera::is_modified() should be used instead.
  • new sockets are available for the following properties: viewport_camera_border, full_width, full_height, use_perspective_motion

ClampNode


  • ClampNode::type was renamed to ClampNode::clamp_type

EnvironmentTextureNode


  • added a socket for the animated property

Film


  • Film::need_update was removed, Film::is_modified() should be used instead.
  • Film::modified(Film) was removed, Film::is_modified() should be used instead.
  • Film::tag_update(Scene) was removed, Film::tag_modified().
  • new sockets are available for the following properties: use_light_visibility, display_pass, cryptomatte_passes, cryptomatte_depth

Geometry


  • Geometry::type was renamed to Geometry::geometry_type
  • Geometry::need_update was removed, Geometry::is_modified() should be used instead.
  • Geometry::used_shaders is now an array<Node *> (used to be vector<Shader *>)

GradientTextureNode


  • GradientTextureNode::type was renamed to GradientTextureNode::gradient_type

ImageTextureNode


  • new sockets are available for the following properties: tiles, animated

Integrator


  • Integrator::need_update was removed, Integrator::is_modified() should be used instead.
  • Integrator::modified(Integrator) was removed, Integrator::is_modified() should be used instead.

Light


  • Light::type was renamed to Light::light_type

MappingNode


  • MappingNode::type was renamed to MappingNode::mapping_type

MapRangeNode


  • MapRangeNode::type was renamed to MapRangeNode::range_type

Mesh


  • Mesh::SubdParams was removed from public access, and is replaced by the new sockets: subd_dicing_rate, subd_max_level, and subd_objecttoworld.
  • Mesh::SubdEgdeCrease was removed from public access, and is replaced by the new sockets: subd_creases_edge, subd_creases_weight
  • Mesh::SubdFaces was removed from public access, and is replaced by the new sockets: subd_start_corner, subd_num_corners, subd_shader, subd_smooth, subd_ptex_offset
  • additionnal sockets are available for the following properties: triangle_patch, vert_patch_uv, and num_ngons

MixNode


  • MixNode::type was renamed to MixNode::mix_type

MathNode


  • MathNode::type was renamed to MathNode::math_type

Object


  • added sockets for the following properties: asset_name, particle_system, particle_index

Shader


  • added a socket for the pass_id property

SkyTextureNode


  • SkyTextureNode::type was renamed to SkyTextureNode::sky_type

VectorMathNode


  • VectorMathNode::type was renamed to VectorMathNode::math_type

VectorRotateNode


  • VectorRotateNode::type was renamed to VectorRotateNode::rotate_type

VectorTransformNode


  • VectorTransformNode::type was renamed to VectorTransformNode::transform_type

WaveTextureNode


  • WaveTextureNode::type was renamed to WaveTextureNode::wave_type