Using VEX to modify another geometry (different geohandle)

Recommended Posts

Hi guys!

I use VEX in a AttribWrangle in order to go through all faces of a "base" mesh and on each mesh face create a Lattice like (FreeFormDeformed) version of another geometry. This other geometry (imagine it like a dynamic pattern) I want to populate with, needs to change its parameters before the AttribWrangle creates a Lattice transformed "copy" of it for each face.

Let me give you a simple example. Let's say the pattern is a cube with a round hole inside. The pattern's parameter is the radius of this hole. Now this pattern has to be distributed over the faces of another geometry. Given the distance to a point affector (or curve) or the base geometry's curvature for example, the pattern must change its radius parameter before being distributed on each of the base's faces. So no two faces will have an identical pattern.

The way I do things now:
The AttribWrangle runs over the primitives of the base mesh (input 1 is the geometry of the base mesh).
Input two holds some points and curves that are used as affectors inside the AttribWrangle in order to compute each primitive's distance to these affectors.
Input three contains the geometry of the pattern.
Inside the AttribWrangle, I compute the "deformed to base surface" of the pattern and add it to the current geo as a new group.
It all works fine, except that I cannot change the radius of the pattern proportionally to the distance to the affectors of the base geometry current face.

What I tried to do was to create a DetailAttribute on the pattern geometry that then can be modified from VEX from the AttribWrangle, something like this:

//Distance computations yield a DistanceToAffectors parameter between 0 and 1 that should affect the radius

```float OldAttribValue = DistanceToAffectors * MaxRadius;//DistanceToAffectors always normalized (0..1)
int rez =setdetailattrib(2, "radius_value", DistanceToAffectors, "set");
float NewAttribValue = detail(2,'radius_value');```

I use 2 because it is the third input of the AttribWrangle node.

Normally this should change the detail attribute "radius_value" of the geometry on input #3 (2), but nothing happens. The NewAttribValue remains unchanged and the setdetailattrib returns 2 (and has no effect on the attribute whatsoever)

My question is: why? Or how can I change the parameter of another geometry before using it in the same AttribWrangle node? Or in general: how do you change a parameter of another geometry from VEX?

Thank you!

Share on other sites

For me, your logic is a non-sense:

Quote

What I tried to do was to create a DetailAttribute on the pattern geometry

Quote

Input three contains the geometry of the pattern.

The wrangle node run over input 0 geometry (by points/primitives/etc...).

So if you want to create an attribute on the pattern geometry, connect this geometry in input 0, then iterate the others geometry with other inputs to get values.

You can NOT set attribute on input2 except if you recreate this geometry in the wrangle node and delete geometry of the input 0.

Share on other sites

You can do this with Python, however.

Share on other sites
2 hours ago, Atom said:

You can do this with Python, however.

Very useful...

The question was:

Quote

My question is: why? Or how can I change the parameter of another geometry before using it in the same AttribWrangle node? Or in general: how do you change a parameter of another geometry from VEX?

And like all SOP nodes in houdini, the idea is to apply something from the first input, python or vex or anything else, you apply from the input.

I think here the problem is the logic and without a file attached is difficult to understand the entire problem. I don't understand the necessity to create a detail attribute on input_3, a simple variable is enough to apply this value in the wrangler node to other geometry.

in this code:

```int rez =setdetailattrib(2, "radius_value", DistanceToAffectors, "set");
float NewAttribValue = detail(2,'radius_value');```

is equal as :

`float NewAttribValue = DistanceToAffectors;`

and why recreate a new variable if we have already one ???

Edited by fsimerey

Share on other sites

This (see attached image) is more or less what I'm trying to achieve. Just imagine that the Perforated Hexagon is the Pattern (in reality, it will be a more complex object with more than 1 parameter).

Any idea how to get this result using VEX? (I need it to be really fast). How can I first compute the "pattern" parameters for each position and then generate the unique geometry?

Share on other sites

Using VEX to modify non-input geometry is not possible for now. In future maybe, it may became true, at least in form of multiple outputs from VOPnets and Wrangles. You always can do things in opposite way, however. Write unique parameter to copy points, and then just copy input geo on this points using stamp expression or foreach loop. Another way is quad-copying, best and simplest implementation of which @petz provided there:

Share on other sites

See attached file with a purely SOP houdini approach which is the best and easiest, and another one, with a part done in VEX (a pseudo poly extrude).

H15.5_hexa_deform.hip

Share on other sites

Thank you, guys. I'll look into your examples and I'll post my result when it is finished.

I'm really impressed by how responsive this community is.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account