Christian Sirois


About Me

Technical Director
United States


Recent Forum Posts

Programaticaly setting values to volume names for Heightfields Dec. 12, 2018, 5:12 p.m.

Hi everyone,

I have a list of string that represents layers.
["snow", "dirt", "grass", "rock"]
Because these are in an array, they have an index from 0 to 3.

Then, I have some files on disk:

Their name is in this format TILEX_TILEY_LAYER.

Now I want to load all of these images as volumes on a Heightfield. I can programaticaly create all the volumes by using the Layer Copy node but in my Volume Wrangle, I want to loop the layer list and set the values of these images into their corresponding volume. For example:

for (int i = 0; i < len(layer_list); i++) {
   string layer_id = sprintf("%03d", i);
   string layer_name = layer_list[i];
   string image = "000_000_" + layer_id + ".png";

   vector sample = rawcolormap(image, u, v);
   @layer_name = sample.x;   // doesnt work because "layer_name" is a variable, not a volume

The last line is where I'm blocked. I would like to set the value using the layer name and not the “@” symbol. I would use the setpointattrib() function in a point wrangle but how can I do this in a volume wrangle?


Is it possible to rotate a heightfield output? Nov. 9, 2018, 5:54 p.m.

I used this code in a volume wrangle:

vector current_pos = @P;
current_pos -= @center;
vector rot_pos = rotate_x_to(set(0,0,-1), current_pos);
vector sample_pos = set(rot_pos.x, 0, rot_pos.z) + @center;
float sample = volumesample(0, 0, sample_pos);
@height = sample;

1: Get the current position of the volume voxel
2: Because the center of the volume might not be at (0,0,0) we offset the voxel pos by the center position
3: Create a new vector position by rotating X to minus Z. (This is +90 degree rotation. Use (0,0,1) for -90)
4: Create a new vector called sample pos. by added the center offset.
5: Sample the volume
6: Assign height the sample value

This works only on square HF


Is it possible to rotate a heightfield output? Nov. 9, 2018, 5:24 p.m.

Yep, having the same issues. I will try to write something that rotates all layer info based on their index but it would be cool if HF xform would work for this…