Getting and setting properties on objects

Bifrost has multiple nodes that can be used for getting and setting properties, such as get_property and get_geo_property. It's important to understand their differences and the purposes of each.

Objects and properties

In Bifrost, an object is a complex data type consisting of one or more properties. Each property is a key-value pair, with the key being the name and the value being its associated data. This data can be almost anything, such as a single float, an array of matrices, or even another object with one or more properties of its own.

You can create objects with custom properties for any purpose. For example, you can use them to control custom effects, employ them as user data in shader networks, or render them as arbitrary output values (AOVs) for compositing.

Geometric objects

Geometric objects must have specific properties that can be recognized and interpreted by the viewport and other renderers. For example, point-based geometries (like point objects, meshes, and strands) must have a point_component property as well as a point_position property. The point_component property must in turn have a count property that matches the array size of the point_position's data property.

Each type of geometry has certain properties that are required, and others that are optional but recognized when present. You can explore the properties that exist on an object by right-clicking on an active object connection and opening a Data Browser.

Geo properties

Geometric objects include geo properties, which are a special type of property that contains data associated with its components like points, face vertices, strands, and voxels. point_position is an example of a geo property, as are point_size, face_vertex_uv, strand_offset, voxel_fog_density, and many others.

The value of a geo property is itself an object with its own properties, including:

Nodes for getting and setting properties

The various nodes for getting and setting properties have different effects and purposes, and also many similarities.

For many common properties, there are dedicated nodes like get_point_position and set_point_position. When available, these are the most convenient because you do not need to specify the property name, type, and so on.

For other cases, there are generic nodes like get_property and set_geo_property. To specify a property, you can type its name in the property box. Some generic nodes also have a magnifying-glass icon in the box. If the node is connected to a graph output or active terminal node downstream, you can click the icon to select from a list of properties that exist on the connected object. The correct data type gets set automatically.

get_geo_property

Use get_geo_property to return the array of values of a geo property. It also returns the default value and the name of the targeted component. However, if the property does not exist on the connected object, the returned data is an empty array.

There is a variation named get_geo_property_check that additionally returns a Boolean value to indicate whether the property was found.

set_geo_property

Use set_geo_property to create a geo property and set its initial data values. You can create custom geo properties for any purpose. Once the geo property has been created, you can get and set it using get_geo_property and set_geo_property_data.

One reason for using set_geo_property to create custom properties is to store user data for rendering purposes. Renderers that support Bifrost have ways to use this data. For example, Arnold has user-data shaders to get the value of geo properties and connect them in a shader tree. Floating-point geo property values are interpolated between vertices. See "Bifrost Graph" in the Arnold guide for a list of supported types and how they are converted.

Be careful using set_geo_property to modify an existing property, because you can accidentally overwrite it with an incorrect data type, target component, and so on. This is why it's better to use set_geo_property_data.

set_geo_property_data

Use set_geo_property_data to update the array of data of an existing geo property. It can be more convenient than set_geo_property because you do not need to specify the default value or the targeted component since the property already exists.

get_property, set_property

Use get_property and set_property to get and set the value of any arbitrary property. However, these nodes are not convenient for geo properties, because the value is an object with more properties. For example, to use get_property to get point positions, you'd need to first get the point_position property and then get the data property of the returned value.

You must also be careful to make sure the values of any property are the correct type because these nodes do not perform any checking.