Understanding Attribute Domains And Fields In Blender Geometry Nodes

What are Attribute Domains and Fields?

In Blender, attribute domains and fields allow you to store custom data on mesh geometry. An attribute domain defines a data type and domain from which values can be assigned to each vertex, edge, face, or corner of a mesh.

Common attribute domains include:

  • Boolean – True or false values
  • Int – Integer numbers
  • Float – Floating point numbers
  • Vector – 3D vector values
  • Color – RGBA color values
  • Object – References to other Blender objects

Once an attribute domain is set up, an attribute field can be added to the mesh. This field allows accessing and setting the domain values per mesh element. For example, you could store a random integer at each vertex, a boolean at each edge indicating sharpness, or object references at each face.

The main advantage of attributes is that data can be stored directly on mesh geometry for use in geometry nodes and other systems. This allows complex vertex-level, edge-level, face-level, and corner-level effects without the need for UV maps or texture tricks.

Creating and Assigning Attribute Domains

Attribute domains and fields are managed in the Object Data Properties panel when in Edit Mode. To create a new domain:

  1. Tab into Edit Mode on the target object
  2. In the sidebar, go to the Object Data Properties panel
  3. Under Vertex, Edge, Face, or Corner, click the + button to add a domain
  4. Select the domain data type (Boolean, Int, Float, Vector, Color, or Object)
  5. Name the domain

This will create a domain that can now have fields assigned to it. To add a field:

  1. With the domain selected, click the + button under Fields
  2. Name the new field

The field will now show up in geometry nodes with a Value Output that can be used to access the domain values per element. At this point, the values will be initialized based on the domain type.

There are a few ways to assign values to an attribute field:

  • Use a Set Position node in Geometry Nodes
  • Run a script to directly set values in Python
  • Manually set constant values on all elements

Typically, the Set Position node is used within Geometry Nodes to procedurally generate values across the mesh based on different inputs.

Accessing Attribute Domain Values in Geometry Nodes

Once an attribute field has been added through the domain creation process, it can be easily accessed in Geometry Nodes:

  1. Add an Attribute Statistic node to the tree
  2. Select the target object
  3. Choose the attribute domain in the dropdown
  4. Connect the Value output to see the attribute values

From here, the values can be used to drive all sorts of vertex, edge, and face level effects. Some examples include:

  • Read integer values to instance different objects
  • Use boolean values to mix shaders
  • Factor vector values into a Color Mix node

In addition to the Attribute Statistic node, attributes can also be set using the Set Position node. This allows writing values within Geometry Nodes based on various procedural effects.

Common Uses for Attribute Domains

Variation Sets

One of the most common uses of attributes is to create “variation” sets. This is where different objects or effects are instanced across a single mesh based on integer attributes stored per face or vertex.

For example, you could store a random number from 0 to 10 on each face. Then, use this to pick between ten different wall trim shapes to scatter detail without repetition. Trees, rocks, and other scatter objects commonly use this technique.

Randomization

Attributes excel at storing random values to create variation across a mesh. This could include randomizing the rotation, scale, or positions of instanced objects. Or, mixing between different noise textures or colors based on random attributes.

The Attribute Randomize node provides an easy way to generate all sorts of varied data for later use in the node tree. Being able read the values directly from an Attribute Statistic node keeps randomization consistent even if other parameters change.

Control Maps

Detailed greyscale maps painted in external software can control material variation by using attributes as the bridge into Geometry Nodes. For example, a height map could be painted to guide mesh extrusion and vector displacement.

The Map Range node can be used to quickly convert the greyscale values to nicely scaled attribute values. Attributes preserve the small control map details better than relying on texture tricks.

Tips for Working with Complex Attribute Setups

When working with many attributes, domain types, and fields – things can get confusing. Here are some tips for keeping complex projects organized:

  • Name domains and fields clearly based on their content (i.e. Object_Instances, Bool_Tree_Type)
  • Visually color code attribute node groups for quick identification
  • Split node trees by function into clearly labeled Groups with Frame nodes
  • View multiple attribute domain values at once with a Join XYZ and Separate XYZ stack
  • Create driver paths for frequently accessed domain fields for easier Value Output selection

Taking time to cleanly structure attribute heavy node trees goes a long way. Viewing multiple domain outputs simultaneously is also very useful to debug what is going on.

Example Workflow for an Attribute-Driven Material

As an example, here is one workflow for creating an attribute driven rock material with variation between gravel, cobble, and boulder parts across a single mesh:

  1. Create distinct materials for gravel, cobble, and boulder with different normal, displacement, and base color values
  2. Set up a Face Integer attribute domain called “Rock_Type” with min and max values from 0 to 2
  3. Use a Random Attribute node to randomly set 0, 1, or 2 per face to indicate each rock type
  4. Read the integer values using an Attribute Statistic Node in the shader tree
  5. Range Remap the random integers to scale between 0 and 1
  6. Use a Mix RGB to fade between the three rock materials based on the remapped values
  7. Instance some smaller rubble objects on gravel faces using the “Rock_Type” attribute as a factor
  8. Only extrude larger boulders on areas marked as boulder with a Math Compare greater than

This combines multiple uses – accessing random values stored on attributes, mixing materials based on this variation data, and using it to control mesh variation. The color, roughness, normal, and height variations between gravel, cobbles, and boulders distributed based on face attributes adds great realism through data-driven randomness.

Leave a Reply

Your email address will not be published. Required fields are marked *