Karma depth shader problems

   1172   3   1
User Avatar
Member
13 posts
Joined: Aug. 2019
Offline
I'm running into some weird issues in karma when trying to render depth based on distance to object.

In arnold I can create a State Float node and plug Rl(Ray Length) into a solid shader and it works great.

But for some reason I can't get the same behavior out of karma. I've tried two approaches so far and neither have worked.
1. Connecting Pz from global into a principled shader.
2. Connecting ray:hitdist or ray:hitPz from a karma ray import node into a materialx unlit shader.
Both of these just render a constant value instead of a distance.

I've attached my simple debug scene as well as one image from arnold and one from karma that shows the difference.

I'm sure I'm just doing something wrong here as I don't see how something so simple wouldn't work in karma.

Any suggestions would be appreciated.

Attachments:
karma_depth_shader.hip (401.7 KB)
arnold_depth_shader.jpg (58.0 KB)
karma_depth_shader.jpg (51.9 KB)

User Avatar
Member
7836 posts
Joined: Sept. 2011
Online
AlexOddbratt_CPHVFX
I'm running into some weird issues in karma when trying to render depth based on distance to object.

In arnold I can create a State Float node and plug Rl(Ray Length) into a solid shader and it works great.

But for some reason I can't get the same behavior out of karma. I've tried two approaches so far and neither have worked.
1. Connecting Pz from global into a principled shader.
2. Connecting ray:hitdist or ray:hitPz from a karma ray import node into a materialx unlit shader.
Both of these just render a constant value instead of a distance.

I've attached my simple debug scene as well as one image from arnold and one from karma that shows the difference.

I'm sure I'm just doing something wrong here as I don't see how something so simple wouldn't work in karma.

Any suggestions would be appreciated.

The reason it appears constant is because its being clamped. Karma clamps all colors to 10 by default. Changing the color limit on the karma render settings to 1e9 will allow any color to come through unchanged. It might also make sense to try to keep the range of pixel values more reasonable to be around 0 to 10. Why do you want to set the Beauty color to be depth instead of using an AOV?
Edited by jsmack - Oct. 9, 2023 12:38:45

Attachments:
karma_depth_shader_edit.hip (718.7 KB)

User Avatar
Member
13 posts
Joined: Aug. 2019
Offline
You are awesome.
That was totally the issue. Thanks a bunch.

Kind of sneaky of karma to have the default be to clamp it at 10 and I've now changed that default to 1e9 on all of our karma based tools so as to avoid this issue going forward.

And you are also correct in that 99% of the time we just use the depth aov.
But sometimes we have cases that require the depth pass to be rendered differently, whether it's a matter of different filtering or sampling compared to the main render or the user wanting to remap the values pre render so as to still have maximum precision instead of doing it in comp. Or even having a depth pass from an arbitrary point instead of the render camera.
User Avatar
Member
31 posts
Joined: June 2010
Offline
AlexOddbratt_CPHVFX
You are awesome.
That was totally the issue. Thanks a bunch.

Kind of sneaky of karma to have the default be to clamp it at 10 and I've now changed that default to 1e9 on all of our karma based tools so as to avoid this issue going forward.

And you are also correct in that 99% of the time we just use the depth aov.
But sometimes we have cases that require the depth pass to be rendered differently, whether it's a matter of different filtering or sampling compared to the main render or the user wanting to remap the values pre render so as to still have maximum precision instead of doing it in comp. Or even having a depth pass from an arbitrary point instead of the render camera.

Think Karma clamps only primary buffer. Aov's should be fine with astronomic values.
  • Quick Links