Jump to content

Functions in VEX?


lisux

Recommended Posts

Hi all.

I'm creating some shaders using the inline code VOP.

When i try to create a new function to be used by the main shader, coding it in the same inline VOP, i get a compiler error:

"function declaration within a VEX shader is not supported in VEX"

How can i declare my own functions to use them into VOP's?, moreover if i've my own header file with this functions, how can i include it? i cannot include it in the Inline VOP because then the functions will be declared into the shader.

Thanks

Link to comment
Share on other sites

How can i declare my own functions to use them into VOP's?

File\New Operator Type...

Operator Name : myfunction

Operator Label : Myfunction

Operator Style : VEX Builder Type

And then Accept!

At the next window,

Basic\

Set VopNet Mask: *

If you were creating a renderman shader function, VopNet Mask may set to rsl_*, If you had set nothing at VopNet Mask, you could not see your function builder in the VOPs.

Parameters\

Create New Direction Vector and Name it N, Label it Normal

Vex Code\Innder Code\

$diff=diffuse($N);

Input/Output\

New Input: Normal

Name it N, it use by the codes $N

New Output : Color , name it diff and also it use by the code $diff

Now, you have create a new vops builder doing diffuse function!

At the vops, type Operator Label : Myfunction , you could use this builder!

cheers!

Link to comment
Share on other sites

How can i declare my own functions to use them into VOP's?

File\New Operator Type...

Operator Name : myfunction

Operator Label  : Myfunction

Operator Style  :  VEX  Builder Type

And then Accept!

At the next window,

Basic\

Set VopNet Mask: *

If you were creating a renderman shader function, VopNet Mask may set to rsl_*,  If you had set nothing  at VopNet Mask, you could not see your function builder in the VOPs.

Parameters\

Create New Direction Vector and Name it N, Label it Normal

Vex Code\Innder Code\

$diff=diffuse($N);

Input/Output\

New Input: Normal

Name it N, it  use by the codes $N

New Output : Color ,  name it diff and also it use by the code $diff

Now, you have create a new vops builder doing diffuse function!

At the vops, type Operator Label  : Myfunction , you could use this builder!

cheers!

15662[/snapback]

Thats great! thanks

Link to comment
Share on other sites

  • 1 year later...

I tried this and although the custom diffuse function seems to work for poly's, Nurbs are resulting in black.

Any idea why?

D.

Okay, I'll answer my own question again: You need to normalize N. Not sure why the problem didn't show with polys, but for a diffuse function, normalize is what is needed, right?

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