Jump to content

Recommended Posts

When using the inline vop node; I understand that you can set multiple output types but how does the Inline VEX code link with the output types ? For example, if I create a variable named $pntLng or I assign Cd to $pntLng as such $pngLng = @Cd;. How would the output type variable name link to the Inline VEX variable $pntLng ? The output type has two options where one can enter Output Names, how can the right side of a Output name be used ?

Share this post


Link to post
Share on other sites

there are no links or anything. it's paired by names. so if you want to export $pngLng your output has to be named the same, as well as data type.

the right side column from the output variable name is supposed to be Label. Not sure how that can be used in this case... 

Share this post


Link to post
Share on other sites

By label you mean, if I wanted $pngLng to have a parameter label such as `PointL` ? What if I have a variable called $something but I don't create the same export name, I assume it's only used within the code but can't be exported obviously, correct ?

Share this post


Link to post
Share on other sites

yeah typically you can have a parameter Name and then Label which can be more user friendly or something. not sure thou where Label gets propagated with inline VOP.

you can't export parameter that's not been defined. in other words, you can only export parameters that you are using in the particular inline VOP. that's the entire logic. on output, inline VOP is looking for the equally named existing parameter and if that doesn't exist it raises an error that parameter is unidentified or something along those lines.

Share this post


Link to post
Share on other sites

You mention one can't export parameters which are not defined for output.  Although I have a crude test example, which I have a variable within the inline vop but I'm not defining it for export but the inline vop doesn't give me any errors. 

Why I asked, if you define a variable inside the inline vop without declaring it as an exported parameter, is the variable only being used within the context of the code but not export, unless it is being declared for export ?

Share this post


Link to post
Share on other sites

in the inline VOP you can define as many variables as you want. any variable can be exported if you specify matching name in Outputs section of inline VOP. you don't have to export all the variables defined in code thou. only if you want to send any particular variable further down the stream you have to export it (you always want to export at least one variable obviously). variables that are not exported only exist within the particular inline VOP.

  • Like 1

Share this post


Link to post
Share on other sites

This is some, well; should be workable garbage code, although I don't know why I'm getting an error; unless I'm doing something wrong ?

float $opp; 

vector $sUV = dPdt; 

@Cd.r = $sUV;

 

Share this post


Link to post
Share on other sites
There's no @ syntax in inline VOPs. If you want to export Cd, add it to the output section as a vector, then in your code you can refer to it -
$Cd.r = $sUV;
 
Presumably dPdt is declared somewhere above your snippet..? If not that will throw an error too.
 
You don't have to use the $ prefix for variables that are only used internally in the Inline VOP but if you don't and you have more than one Inline in the same network using the same variable name, you'll get errors too.

 

Share this post


Link to post
Share on other sites

@j00ey If I understand correctly, if I make a variable called $pntList and I want to export the variable, I must make a export name called pntList as well; correct ? 

From my experiments if I do what I mentioned above, I get an error; but if I give the export name a different name then what is the variable within the inline vop; no error is thrown ? Meanwhile you are saying if I use something like the $Cd.r variable I must give an export name of the same variable name, in this case either @Cd or @Cd.r.  Although if you supply a different export name, it won't be linked with the variable within the inline vop, correct ?

Share this post


Link to post
Share on other sites

You can name your variables however you want to, you just have to make sure they match up if you want to export something for use outside the Inline VOP [but in the same VOPnet]. There's no @ syntax in Inline VOPs so @Cd will throw an eror. $Cd is fine.

Can you put up a sample scene with your error in it and I'll take a look at it?

Share this post


Link to post
Share on other sites

@j00ey When you look in the scene within the inline VOP, there is a variable named $pntColorList.  When creating an export variable of the same name, you get an error, although if; as seen in the attached scene you give a different name for the export name, no error is thrown ? Although if I'm correct, the variable $pngList is not accessible for export because the export name is different ?  

qa_inlinevop.hipnc

Share this post


Link to post
Share on other sites

You can't make an output variable called pntColorList AND declare it in the body of your code. If you add the output and then change the line

vector $pntColorList;

to

$pntColorList = 1;

it won't error. Same goes for $pngList

Share this post


Link to post
Share on other sites

@j00ey Why am I getting an error on this line; vector $pntList = set(1,1,1); ?

Hopefully you can explain the error in the forEach end block ?

 

forend.png

Edited by CinnamonMetal

Share this post


Link to post
Share on other sites

From what I can see in that screengrab it looks like you've got an output called pntList, in which case your line should read :

$pntList = set(1,1,1);

if you put 'vector' before it you are declaring it, and it's already declared. [Anything you put in your list of outputs is declared automatically]. Just like in a wrangle in SOPs if you write :

float value = 1;
float value = 2;

you'll get an error, that should be

float value = 1;
value = 2;

By the way, if you're setting a vector with constants you don't need to use set(). You can just write

$pntList = {1,1,1};

Use set() if you need to set it with other variables, eg:

float valueA = 1;

float valueB = 2;

vector values = set(valueA, valueB, 0);

  • Like 1

Share this post


Link to post
Share on other sites
17 hours ago, j00ey said:

Just like in a wrangle in SOPs if you write :

float value = 1;
float value = 2;

you'll get an error, that should be

float value = 1;
value = 2;

Don't you mean, f@value = 2; ?

Within the inline vop I have these lines of code; 

if($primnum > 0.5 && $primnum < 0.45){
$Cd = noise(cos(34));
}

Although I don't see any noise applied to only the primitives in the condition ?

vop_loop.png

Edited by CinnamonMetal

Share this post


Link to post
Share on other sites

There are a few issues with this.

Firstly, I don't think you have access to primnum inside a shading context. You can use something like id and bind that to do the same thing.

But assuming you did that, it would be an integer, not a float. And this condition can never be true - a float can't be greater then 0.5 and also less than 0.45.

($primnum > 0.5 && $primnum < 0.45)

Regards the declaration thing, you can actually write

f@value=1;

f@value = 2;

because that's setting the value of a geometry attribute

but you can't declare it twice - replacing f@ with float will throw an error.

Edited by j00ey
typos

Share this post


Link to post
Share on other sites

In other words you mean; 

if($id > 2 && $id < 10){
$Cd = {0.4,0.6,0.1};
}

And bind $Cd export out ? I don't see primnum working either; I thought you could use that global variable.

Share this post


Link to post
Share on other sites

Yes that should work.

A good way to check what variables you have access to for free, put down a globals VOP and look at the list.

If you want to use primnum, just give your geometry an attribute that mirrors it, eg id. You can do that with an enumerate SOP, or manually in a wrangle just put for instance:

i@id = @primnum;

then you can bind that in your shader and use it

Share this post


Link to post
Share on other sites

@j00eyUnfortunetly this code is not working; I'm expecting to see color only on the specific primitives but instead I get an error ?

$id = 0;
if($id > 2 && $id < 10){
$Cd = {0.4,0.5,0.1};
}

 

Edited by CinnamonMetal

Share this post


Link to post
Share on other sites

Can you upload your scene and I'll have a look?

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

×