How to determine material based on light path

   1625   7   0
User Avatar
Member
15 posts
Joined: Dec. 2021
Offline
Blender has a kind of cool feature where the type of light path can be used as a boolean in a shader network to mix between different kinds of shaders. For example, in this image:



a light path node is used to make it so any rays directly from the camera make the material have a green color, while any other rays see the object as red.

I noticed that Houdini has some kind of light path expression [www.sidefx.com]. Could I use light path expressions to get a similar result in Karma? If so, how?

Thanks!
User Avatar
Member
7803 posts
Joined: Sept. 2011
Offline
AnsonSavageBYU
a light path node is used to make it so any rays directly from the camera make the material have a green color, while any other rays see the object as red.

I noticed that Houdini has some kind of light path expression . Could I use light path expressions to get a similar result in Karma? If so, how?

I don't think you can use LPE in shaders, they are only applied to AOVs. Karma CPU supports Mantra shaders; if you make a shader using VEX material builder the renderstate/raylevel information allows for ray path switching.
User Avatar
Member
129 posts
Joined: Sept. 2021
Offline
Okay, I can confirm that using a raybounce node does work with a Mantra Vex material imported into Karma. I can also confirm it doesn't work with Karma XPU. I wasn't sure how to use a renderstate node, but that does sound interesting.

Thanks so much for the help!

Attachments:
KarmaCPULightPath.png (856.7 KB)

User Avatar
Member
7803 posts
Joined: Sept. 2011
Offline
AnsonSavage
I can also confirm it doesn't work with Karma XPU. I wasn't sure how to use a renderstate node, but that does sound interesting.

XPU doesn't support Mantra VEX materials, so that makes sense.

For materialX materials that work with XPU, the Karma rayimport node can import the raylevel. I'm not sure if it works with XPU or not as not all the variables are importable in both engines.
User Avatar
Member
7803 posts
Joined: Sept. 2011
Offline
Here's a simple example that works with XPU and CPU
Edited by jsmack - Feb. 16, 2023 19:13:19

Attachments:
karma_rayswitch.hip (673.4 KB)
ray_switch_karma.png (735.1 KB)

User Avatar
Member
333 posts
Joined: April 2018
Online
This is pretty nuts. Thanks for the info.
User Avatar
Member
129 posts
Joined: Sept. 2021
Offline
Hey, this is awesome, it works great!

Thanks so much
User Avatar
Member
129 posts
Joined: Sept. 2021
Offline
Does anyone know how to implement this in RenderMan for Houdini?
  • Quick Links