Karma Get Surface Position Pre-Displacement?

   2196   4   0
User Avatar
Member
76 posts
Joined: Sept. 2011
Offline
Is it possible to retrieve the pre-displacement surface position in a Karma surface shader?

The only way I've been able to do this at the moment is by copying P to rest or another extra attribute and then reading that attribute in the surface shader.

I'm hoping there's a way to access the P attribute directly or before the displacement shader has run without relying on extra attributes being stored on the geometry.
Edited by jkunz07 - Sept. 28, 2022 05:48:43
User Avatar
Member
76 posts
Joined: Sept. 2011
Offline
Here's an example showing what I'm hoping to achieve, I'd like to have the pattern in the surface shader and the displacement noise line up. If I use the mtlxposition node it only grabs the position of the surface being shaded (after it's been displaced). If I read the rest attribute, it gives me the result I'm hoping for but it seems redundant to copy P to rest just to do this. Is it possible to directly read the P attribute or get the pre-displacement surface position in some other way?

Attachments:
mtlx_karma_disp_pos_q.hiplc (298.7 KB)
Screen Shot 2022-09-29 at 5.56.07 PM.png (2.9 MB)
Screen Shot 2022-09-29 at 5.56.36 PM.png (3.0 MB)

User Avatar
Member
134 posts
Joined: Dec. 2006
Offline
I dont think that is possible at the moment with material x, In mantra you have the import displacement variable node, it allows you to import the position value before displacement gets calculated.

Using the rest position seems like a good alternative.
Edited by willh - Oct. 3, 2022 05:29:40
User Avatar
Member
76 posts
Joined: Sept. 2011
Offline
Thanks! Yes, I've been looking into this a bit more and it seems to be the case.

https://www.sidefx.com/docs/houdini/render/understanding.html [www.sidefx.com] is a good explanation of Mantra's shading process, and using dimport to grab variables from the displacement shader in the surface shader.

I've been looking for similar info on Karma and MaterialX but believe using rest is a good solution for now but was hoping there might be some secret rayimport [www.sidefx.com] or renderstate [www.sidefx.com] type of trick
User Avatar
Member
210 posts
Joined: Dec. 2016
Offline
I’m looking for a simpler way, but you should be able to bake the pre displaced normals in cops.
You can just use P instead of N.
Edited by NicTanghe - Nov. 13, 2022 10:20:02

Attachments:
bake_atribute1.hiplc (225.4 KB)

  • Quick Links