Custom AOVs in Karma - Transform Vectors and AOV assignment?

   2077   3   2
User Avatar
Member
30 posts
Joined: Nov. 2018
Offline
I'd like to output a custom AOV / Render Var with my beauty pass. I'm trying to make a "distance from camera" AOV that outputs a grayscale float value on all geometry in the scene based on distance from camera.

The shader part seems pretty straightforward. Make a Material X or Karma Material, then transform the position (P) attribute from world to camera space and use a distance function. I'm having some issues for everything else...

First question...
There is very little information on this page [www.sidefx.com] about what names to use to transform spaces using the MtlX Transform node. How do I go from world space to camera space? Should I be using this node or something else? Essentially I'm just trying to find a way to get the camera position into Material X.

Second...
If my scene has multiple materials assigned to different objects, how do I get all objects to render using the same shader in the custom AOV, but keep their original material in the beauty pass? It appears that I need to do the logic for the AOV and put a Karma AOV node inside each material separately. Is there a way to keep the logic for the AOVs in one place, and then assign it to all objects irrespective of its surface shader?

Thanks!
Edited by davidbk - July 16, 2024 21:37:07
User Avatar
Member
8173 posts
Joined: Sept. 2011
Offline
You can add the hitdist aov from the karma aov menu.
User Avatar
Member
30 posts
Joined: Nov. 2018
Offline
jsmack
You can add the hitdist aov from the karma aov menu.

Thanks @jsmack! That seems to do the trick.

Just curious, say I wanted to do additional math using hitdist to make a custom AOV, and I wanted it to affect all objects in the scene, how would I go about making the shader and applying it to all objects?
User Avatar
Member
8173 posts
Joined: Sept. 2011
Offline
davidbk
and I wanted it to affect all objects in the scene, how would I go about making the shader and applying it to all objects?

There's no mechanism for this that I know of other than editing all of the materials.

The karma ray import node can bring in ray hit dist, ray direction and other geometric information for use in the shader. for your original question, yes that node can transform from to "camera" space.
  • Quick Links