Jump to content

VOP inner Code


rob

Recommended Posts

vector $myP = $isconnected_P  ? $P : P;
vector $myN = $isconnected_N  ? $N : normalize(frontface(N, I));

This is a snippet of inner code from a vop and I just wanted clarification of what it means

vector $position = $P; I would use this normally

vector $position  = $isconnected_P ?$P :P;

I am not sure about this and why its even needed as if P , N are not connected its hardley going to work

$isconnected_P ?$P :P

Rob

Edited by rob
Link to comment
Share on other sites

vector $myP = $isconnected_P  ? $P : P;
vector $myN = $isconnected_N  ? $N : normalize(frontface(N, I));

This is a snippet of inner code from a vop and I just wanted clarification of what it means

vector $position = $P; I would use this normally

vector $position  = $isconnected_P ?$P :P;

I am not sure about this and why its even needed as if P , N are not connected its hardley going to work

$isconnected_P ?$P :P

Rob

x = <boolean> ? <true> : <false>;

This is called a tertiary comparator (if think) and is a shorthand for if then else.

x gets the true expression assigned, if the boolean is true, else it gets the false expression.

in your sample it means:

If P is connected to the input of the node that generated this code, then use the value of this input, else use the global variable P.

Quite handy if you want to make your code able to use custom versions of global variables.

Also quite common when dealing with UVs, In this case you check if UVs are bound and switch to s and t if they aren't.

Hope this helps.

Georg

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...