Jump to content
woodenduck

Sop vex ptnum vs cvex

Recommended Posts

Hi, 

So in days of old when you used to create a Sop Vex Geometry Type Operator you had access to ptnum as a read-only global variable. Now if I try that in a cvex operator I get "Error 1067: Reference to undefined variable: ptnum". 

What is the current method for getting the current point number in the cvex context?

Cheers, 

WD

Share this post


Link to post
Share on other sites

in CVEX you define it as an argument and if it's fed to the shader it will be automatically populated, so in most geometry CVEX contexts it will contain actual ptnum in others like lens CVEX shader it will stay the default value (in this case 0) etc.

cvex
randomshader(int ptnum = 0; export vector Cd = { 0, 0, 0 })
{
    Cd = random(ptnum);
}

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks Thomas, 

So if I understand you correctly, ptnum just needs to be initialised to some value, then fed in to the function and will automatically receive a value?

Share this post


Link to post
Share on other sites

all arguments of a context level (shader) function have to be initialized with default value

and yes, whatever program calls the CVEX shader function may pass some arguments

 

Share this post


Link to post
Share on other sites

i don't understand. does anyone mind showing an example of what i need to type in to get the point values to show up? i'm following an older "beginner's" tutorial that has me write the following into VEXpression of my point wrangle node: @scale = set(1, random(ptnum*321.45)*2-1, 1);

but I'm using Houdini 17.5 and it's giving me the error "reference to undefined variable: ptnum"

what is the newer version of the expression?

Share this post


Link to post
Share on other sites

this is not exactly the correct thread for it

the original question was about the full definition of the cvex shader vs older context specific sop vex shader

 

in VEXpressions of most Wrangles and other nodes you are not typing the full shader, rather snippet and rather than using pure VEX you have some extra syntax  like binding operator @ that will help houdini to build the shader code properly

so by binding the ptnum using @ptnum it will generate the arguments of the shader function as well as use ptnum in the code automatically 

so in your case the code will be

@scale = set(1, random(@ptnum*321.45)*2-1, 1);

 

  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)

Tomas, your Houdini knowledge and numerous answers are truly amazing. 

 

Edited by fuat

Share this post


Link to post
Share on other sites

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

Sign in

Already have an account? Sign in here.

Sign In Now

×