Jump to content

Arbitary Output Variables


Recommended Posts

Arbitary Output Variables

Hello, I want to accomplish something simmilar to AOV in PRMAN, but with Mantra, where inside my VEX shaders I would write different nodes to buffers, which would be saved in their own files upon rendering is finished.

I see that in a deep raster you can output predifened vars (Cf, Of, Af etc) But is it possible to create custom AOVs ? Hip takes feels a little wrong to me (like Maya render layers) that for each pass I need to render a scene over again with different materials, rather then rendering everything in one pass and write down different parts of shaders to their own files.

Link to comment
Share on other sites

This is easy enough. Just make a parameter and set it to export, if you are making shaders in Vops then just turn on the export toggle then wire whatever value you want in your deep raster into the input for the parameter node. In the deep raster tab just set that to the same name as the parameter you created, and set the type to match, ie float or vector.

If you are writing code from scratch just declare your parameter as exportable like this

export float foo;

and set the value in the body of the code, after that you set the deep raster the same way as for Vops.

Link to comment
Share on other sites

Thanks, thats exactly what I need thank!

Also, since this is clear, I have another question. When I use VOPs to build vex (for me its much like SLIM for SL) can I reuse "nodes" in other shaders. I.e. in SLIM I can have one occlusion node connected to one AOV node, and then I connect output of that AOV to all shaders, and dont have to worry if I for example mistype the name of the variable, since I type it only in one instance. Nevertheless, SLIM copies the occ->aov connection to each shader, the cool thing it does it for me.

This is easy enough. Just make a parameter and set it to export, if you are making shaders in Vops then just turn on the export toggle then wire whatever value you want in your deep raster into the input for the parameter node. In the deep raster tab just set that to the same name as the parameter you created, and set the type to match, ie float or vector.

If you are writing code from scratch just declare your parameter as exportable like this

export float foo;

and set the value in the body of the code, after that you set the deep raster the same way as for Vops.

Link to comment
Share on other sites

Not 100% sure I follow you. You can make your own vops and then those vops can be used in any shader you make. Is that what you mean?

Yeah, thats one solution which might help. I.e. if I have occulsion node connected to parameter node, how do I make it one VOP, that I can use in all shaders?

But original idea is to have parameter node to be connected to all shaders that I hvae in the scene.

Link to comment
Share on other sites

If all the shaders in the scene are based on the same vop network then job done. If you have several vop networks defining different shaders then you either have to set them all manually to have the parameter you want, or build your own version on the occlusion that does the export and use that in each definition.

Link to comment
Share on other sites

If all the shaders in the scene are based on the same vop network then job done. If you have several vop networks defining different shaders then you either have to set them all manually to have the parameter you want, or build your own version on the occlusion that does the export and use that in each definition.

Okey, now it makes perfect sense! So I am either building my supershader and just play with parameters for each model, or I build my super-occlusion and use that node inside different shaders.

Now the question of course is how can I make a custom VOP node to be used in VOP networks?

Link to comment
Share on other sites

Now the question of course is how can I make a custom VOP node to be used in VOP networks?

I have a page showing how I wrote custom vex ops here:

http://studentpages.scad.edu/~aschwo20/vops/

It's pretty simple, in the case of a shader op, you build it the same way you'd build a SLIM template,

with input params declared with #pragmas. Then, a c-like function declaration. In the case of a surface op, declare it like this:

surface vopname( input params )

{

// do surface ops here

}

I haven't done this in a while, but off the top of my head you can use Cd (surf color) and Of (surf opacity) for output params.

Write the file as a .vfl, then compile into an .otl from the command line:

vcc -m yourOTL.otl yourVOP.vfl

-m denotes that it should be compiled as type VOP

Then import your otl, and tab in your new custom vop in the vex builder.

Here's a pretty useless op:

http://studentpages.scad.edu/~aschwo20/vop...oiseVOP.vfl.txt

I haven't tried this for general math stuff, but I imagine if you want to output a vector then the function should be declared like this:

vector yourvop (input params)

{

// do stuff

}

I don't have access to houdini, but I think there's enough there to get you started.

- alex

Edited by aschwo
Link to comment
Share on other sites

Thank you so much! Thats really cool, I can build my own VOPs now! I think I can convert some PRMAN shaders this way as well. Great

I have a page showing how I wrote custom vex ops here:

http://studentpages.scad.edu/~aschwo20/vops/

It's pretty simple, in the case of a shader op, you build it the same way you'd build a SLIM template,

with input params declared with #pragmas. Then, a c-like function declaration. In the case of a surface op, declare it like this:

surface vopname( input params )

{

// do surface ops here

}

I haven't done this in a while, but off the top of my head you can use Cd (surf color) and Of (surf opacity) for output params.

Write the file as a .vfl, then compile into an .otl from the command line:

vcc -m yourOTL.otl yourVOP.vfl

-m denotes that it should be compiled as type VOP

Then import your otl, and tab in your new custom vop in the vex builder.

Here's a pretty useless op:

http://studentpages.scad.edu/~aschwo20/vop...oiseVOP.vfl.txt

I haven't tried this for general math stuff, but I imagine if you want to output a vector then the function should be declared like this:

vector yourvop (input params)

{

// do stuff

}

I don't have access to houdini, but I think there's enough there to get you started.

- alex

Link to comment
Share on other sites

OK, I just digged through the manual, and it seams like I cannot create custom node for VEX builder (as I cannot do this in SLIM) I can create a shader but not a node that would be used in the VEX builder - and it makes sence. VEX builder is disigned to build VEX code, but not the other way around (create VEX code that would create VEX node that would again create VEX code)

Link to comment
Share on other sites

You can create a custom node for VOPs. Either as a subnet asset, some of the nodes that ship are like that already, or as a coded vop node which is a little more tricky. Sorry I don't have time to explain it all right now.

Hmm thats what I though, it just cant be that simpe =) I hope that you'll have sometime to post maybe not explanation but maybe a link that would guide me.

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