Houdini 20.0 Nodes Geometry nodes

Volume Wrangle geometry node

Runs a VEX snippet to modify voxel values in a volume.

On this page
Since 12.5

Overview

This is a very powerful, low-level node that lets experts who are familiar with VEX tweak voxel values using code.

This node corresponds to the Volume VOP SOP, but uses a textual VEX snippet instead of a VOP network.

This node runs the snippet on every voxel in the input volume(s) (unless the Bind each volume to density parameter is on). The snippet can edit the input geometry by changing attributes. It can access information from other geometry using attributes and VEX functions.

  • Press MMB on the node to see any error output from the snippet.

  • You can use the VEX function ch to evaluate parameters. The path is relative to this node (ch("parm") will evaluate the parameter parm on this node). This evaluation will be done at the current time.

  • Unlike the Volume Mix SOP, this does not use local variables. Further, all backtick expressions and $F variables will be evaluated at frame 1, not the current time. Use Frame, Time, or TimeInc instead.

  • The Volume VOP only processes voxels to write to (and only once for each colocated voxel).

Syntax

The VEX snippet parameter lets you enter a snippet of VEX code to run on the input geometry. See VEX snippets for basic information on the syntax available in the snippet parameter. See the VEX chapter for general information on the VEX language.

Reading and modifying the voxel value

The current voxel value in a volume is available as @volume_name. You can read this variable to get the current value, and assign it to change the value. For example, to add 0.1 to the value of every voxel in the float volume foo:

@foo += 0.1

If a volume does not have a name, it will automatically be bound to @density.

If you have multiple named volumes in the input, you can write a single snippet that modifies the different volumes in different ways, for example:

@foo += 0.1
@bar += 0.2
@baz += 0.3

Alternatively, you can turn on Bind each volume to density. This acts as if every input volume was named density, so you can use the same snippet to modify every voxel in every volume:

// Modify @foo, @bar, and @baz in the same way
// (when Bind each volume to density is on)
@density += sin(@P.x)

Note

Unlike how the Point Wrangle and Attribute Wrangle nodes work, writing to an unknown @name variable will not create a volume.

VEX variables

You can create temporary variables. For example, the following code reads an offset location from a point.

vector temp = @P;
temp += {0.1, 0.2, 0.3};
@density = volumesample(@OpInput1, 0, temp);

Bound Variables

A number of variables are bound in the Volume VOP context. Use the @ prefix syntax to access them.

P

Location of the current voxel’s center.

ix, iy, iz

The integer index of the current voxel. With VDBs, this can be negative.

resx, resy, resz

The resolution of the current volume primitive. For VDBs this is the size of the active voxel region.

dPdx, dPdy, dPdz

Vectors giving the length and orientation of the x, y, and z edges of the 0th voxel.

center

The center of the volume in SOP space.

primnum

Primitive number of primary volume being iterated over. If more than one volume or VDB align, there may be only a single pass done and this will be only one of those. Bind Each to Density will ensure one pass per primitive.

Time

Current time in seconds.

Frame

Current time in frames.

TimeInc

Time increment between frames, in seconds.

OpInput1, OpInput2, OpInput3, OpInput4

A string that can be used to refer to the corresponding input of this SOP in vex operations that take file parameters.

Parameters

Code

Group

Only run the program on these volumes in the input geometry. Leave this blank to modify all volumes in the input.

(See reading and writing voxel values above.)

Bind Each Volume to Density

Changes how the node applies the snippet. When this is off, you must refer to specific volumes in the input by name (for example @foo). When this is on, every input volume is treated as @density, so you can write one snippet to affect every input volume regardless of their names.

(See reading and writing voxel values above.)

VEXpression

A snippet of VEX code that will manipulate the point attributes. You can use @variable_name syntax to access geometry attributes.

Volumes to Write to

Only modify volumes if their names match this pattern. The default pattern allows any volume to be modified. You can speed up the node by only listing volumes that are actually modified by the snippet.

For example, in the following snippet, only the density volume is modified. The temperature volume is not modified, only read.

@density = @temperature;

However, for obscure reasons, the node will both modify density and copy temperature. This uses time and memory. To prevent this, you could set this parameter to density to prevent the node from copying temperature. Of course, this requires that you explicitly manage the list of writable volumes.

Enforce Prototypes

Requires that you declare @ bindings in snippets as prototypes before using them. This applies to both attributes (for example @Cd) and “convenience” bindings such as @ptnum and @Frame. For example:

// Declare bindings
int @ptnum;
float @Frame;
vector @Cd;

// Use bindings after declaration
int pointnum = @ptnum;
float red = @Cd[0] / @Frame;

Automatic binding with the @ syntax can be convenient, but as your scene becomes more complex there is the risk that a typo in an @ binding will silently just bind a non-existent attribute.

Bindings

Autobind by Name

Number of Bindings

Enter the number of binding of binding to establish when you turn off Autobind by Name . Each binding adds a new parameter set. Delete existing bindings with the Remove button.

Primitive, Primitive Name, VEX Parameter

Manually specifies the bindings of each primitive. This is equivalent to those primitives having a name attribute with the given name. If Primitive Name is not empty, the primitive with the matching name will be bound to the given vex parameter.

Only Output Created Geometry

Signed-Flood Fill Output SDF VDBs

When narrow-band SDFs are processed the sense of the interior cells can be lost. This results in the interior being falsely output with the default background value. This option will do the sweep to reset these tiles to the correct sense. It only affects VDBs which are of grid class SDF.

Export Parameters

VEX Precision

VEX can evaluate at 32-bit or 64-bit precision. 64-bit provides higher accuracy, especially for transforms.

Note

Incoming attributes will preserve their original precision, so using 64-bit VEX on 32-bit positions will convert them to 64-bit, apply the operation, then convert back to 32-bit when writing out.

The auto mode will switch between 32-bit and 64-bit depending on the preferred precision of the incoming geometry. When run in 64-bit precision, any created attributes will be 64-bit. When run in 32-bit any created attributes will be 32-bit. Use Attribute Cast to change the preferred precision.

See also

Geometry nodes