Jump to content

Switcher VOP Problem


Recommended Posts

Hey there

Having a few issues with using a switch node in VOPs and can't seem to work out what is going on! I've got a bunch of spheres with a point attribute (integer value btwn 0-4) and need to reference this in a VOPSOP to colour each one using a switch node which 5 different colour types. However, when I promote the switch value paramater and input my attribute it just comes back with a 'Undefined variable' error, even though the attribute definately does exist! Anyone had this happen before or know what I'm doing wrong?

Cheers

Dan

Link to comment
Share on other sites

Attribute variables are only local to the network they exist in. If you open the "Details View" you will likely not see the attribute at the promoted level.

Good point! Is there anyway that I can access such an attribute in another network such as SHOPs at all, or is there a better way to do this?

Link to comment
Share on other sites

Yes, I think you can access custom attributes from SOP networks in all other networks, which is what makes the attribute approach in Houdini so powerful.

I've never had to do this, but I think the SHOP node you need is the Import Surface Variable.

Link to comment
Share on other sites

Before everyone gets too giddy about using hard conditionals in surface shaders to modulate between varying render colors with a geometry attribute, a word of caution.

Simply do NOT use a Switch or If VOP or any other hard conditional to drive the mixing of colors.

When mantra evaluates the current shading point in both microploygon and raytrace mode (and pbr of course), it needs to build the derivatives on that spot. Things like the area of the current spot size being rendered (change in P), change in uv's, change in depth (dPdz) and any Parameters that are picking up attributes on surfaces.

Those surface attributes are considered to be varying across the surface. If you have a hard switch between two colors, that switch based on a varying geometry attribute will be discontinuous across that boundary. What this means that is when Mantra tries to build the derivatives across the hard switch, it is discontinuous and will create garbage derivative results.

Now you could argue that in the above test case you have individual spheres that share the same attribute that increments and then the hard switch is ok. I would argue that this shader would then fall in to the wrong hands and will be used for varying attributes across a single surface and you will get crap.

See the attached example file. The VOP network contains both a Switch VOP and a Mix VOP to do the same thing. Switch = garbage. Mix = good. Try the different render engines as well. Raytrace and PBR screw up even more than micropolygon rendering.

If you want to read more about this and more, see the Advanced RenderMan book about getting around render artefacts in a Reyes based render engine. The nice thing about VOPs is all the patterns, mixes and smooth operators are all filtered for you making things very simple for the shader builder.

Edited by old school
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...