Jump to content

Creating geometry in VEX (compiling .vfl with vcc and binding to VEX n


DocWhite

Recommended Posts

Hello everybody! :)

 

If we want to create geometry using VEX we can pipe a null node into an Attribute Wrangle and in the latest we can use functions such as addpoint() to birth geometry. One requirement is that we have to set it to run over Detail (only once).

 

The problem comes when I want to do this using a .vfl file and compile into VEX and use a VEX node that points to the compiled file. Geometry won't be created. It is strange because I know VEX just work on points, not on Detail so I have two questions:

 

1. Why do we have to run the Attribute Wrangler in mode "run over Detail (only once)"? Why not points?

2. Is there a way to use a pragma flag or something to tell the vcc compiler that this code must run over Detail and only once?

 

Thanks for your help in advance.

Ramon.

Link to comment
Share on other sites

Vex just loops over anything that you select in the dropdown menu, it also denotes what kind of default attributes that you have available.

For instance v@P, will be different in point mode from primitive mode. In the same way if you are in points mode you cannot get the varmap using s@varmap,

instead you will have to use detail(0,"varmap");

 

If you put it on point mode and there are no incoming points, there will be no geometry output. it will execute the code for every point.

so for generating geo, you generally want to do that in detail mode, unless you want to create some geometry for every input geometry object (point,vertex or primitive).

If you do not know upfront if the input will have geometry, you may want to add a dummy point to the input using a merge node,

or a switch checking if the input geometry has points or something like that.

Link to comment
Share on other sites

If you do not know upfront if the input will have geometry, you may want to add a dummy point to the input using a merge node,

or a switch checking if the input geometry has points or something like that.

 

Thanks for your answer! :) I tried what you suggested and it still does not create the point. I attach a screen capture so that you can see exactly what I am doing. Thanks Twan.

 

IMPVXyD.png

Link to comment
Share on other sites

Guest mantragora

Wrong context. You can create geometry only in cvex, but you operator is working in sop. I don't think that you can force New Operator Type to work in cvex. Place AttributeVOP SOP, put a SnippetVOP inside and place you position and addpoint() code there, then RMB on AttributeVOP SOP and pick View Vex Code. See the difference what is returned from function?

Probably you can compile custom cvex operator with VCC, but I'm not sure what flags you need to set. I never had any need for it. Maybe someone here done this.

EDIT:

If you tried to compile with VCC, then try to add this flag

-c cvex
instead of (if you set it in your command)

-c sop
and see what happens. I'm not paying for any damages :)

BTW:

They don't teach you those things (cvex) in Bournemouth?! o_O

Edited by fântastîque Mântragorîè
Link to comment
Share on other sites

you will have to use detail(0,"varmap");

 

While it is generally true, detail attributes seems to be a special case. They can be accessed in other classes too. Just remove asterisk from bindings to prevent creating an empty attribute with same name.

 

It will be even nicer if point and primitive attributes can be acessed in vertex wrangles in future Houdini builds.

point_cat.hipnc

Link to comment
Share on other sites

Wrong context. You can create geometry only in cvex, but you operator is working in sop. I don't think that you can force New Operator Type to work in cvex. Place AttributeVOP SOP, put a SnippetVOP inside and place you position and addpoint() code there, then RMB on AttributeVOP SOP and pick View Vex Code. See the difference what is returned from function?

Probably you can compile custom cvex operator with VCC, but I'm not sure what flags you need to set. I never had any need for it. Maybe someone here done this.

EDIT:

If you tried to compile with VCC, then try to add this flag

-c cvex
instead of (if you set it in your command)

-c sop
and see what happens. I'm not paying for any damages :)

BTW:

They don't teach you those things (cvex) in Bournemouth?! o_O

 

 

I'm CVA second year, we did like 2 weeks of houdini, and they didn't teach us VEX nor CVEX :'( maybe in 3rd year. Like proper CVEX stuff.

 

I did this and it doesn't work because it only runs in SHOP as it is CVEX... I will have to wrap it propably :( I just wanted to generate a UI-d digital asset just compiling a single vfl file with pragmas thats it.

#pragma opname "create_geo"
#pragma oplabel "Create Geometry"

cvex create_point()
{
    vector pos = {1, 0, 0};
    addpoint(geoself(), pos);
}

This did not work even if I compile with the -c cvex. But that flag is when you don't define a context function.

Link to comment
Share on other sites

Just to clarify my workflow is like this because I want to create the UI using pragmas (like #pragma label param "Parameter 1"... and so on):

 

1. Save a .vfl file with this code:

#pragma opname "create_geo"
#pragma oplabel "Create Geometry"

cvex create_point()
{
    vector pos = {1, 0, 0};
    addpoint(geoself(), pos);
}

2. Compile it like:

vcc -l create_geometry.otl create_geometry.vfl

3. I go to Houdini and File > Import > Houdini Digital Asset, select it and accept.

 

4. I go to a SOP context and lay it down and connect it under a Null node. And nothing happens obviously because we cannot create geometry in SOP VEX context. From the documentation I quote:

 

You can create geometry with VEX snippets in certain nodes, such as Attrib Wrangle. To be able to create geometry, the node must run in the cvex context, which means the Point Wrangle cannot create geometry since it runs in the sop context.

 

So the thing is... Is it possible to run CVEX under SOP contexts? When I import the OTL it just lets me import it to be used under SHOPS.

 

 

A friend told me this and he kind of sorted it out! :)

 

Eligijus Titas So when you use the otl it opens in the SHOP network. Have you tried going to the Object network, put down an AttributeVOP go to 'Vex Setup" tab and set "Vex Source" to Shop and then link the loaded otl that is in SHOP network? Is that what you were looking for?
 
 
Eligijus Titas Ohh and the AttributeVOP should be set to run over detail
Edited by DocWhite
Link to comment
Share on other sites

  • 7 months later...

Addressing question #1 in the original post:

One would assume that a wrangle node set to 'points'  loops over points, just like a typical 'for' loop. and one would also assume that thus, for each point, one could write to a detail attribute - incrementing it, for example. 

Not so!  Although you can read detail attributes you cannot write them, because the wrangle node is not in fact a loop. It was designed for threaded operations, which cannot be sequential. If they were, distributed processing would be pointless. Thus, you might have several processors trying to write to the same detail attribute at the same time. So that operation is not allowed.

The solution is to use a wrangle set to 'detail', and inside that, have an explicit for loop that will sequentially loop over all the points. In that context, you can write to the detail attributes each loop. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...