How to create a double-sided material in Karma?

   2309   16   4
User Avatar
Member
45 posts
Joined: Nov. 2016
Offline
Can someone explain to me how I can create and apply a double-sided material to in Karma?

I found a post on this forum, but it didn't make it understandable for me.
User Avatar
Member
2537 posts
Joined: June 2008
Offline
You'd think the kma_ray_import would offer some type of 0-1 output value you could use to drive the bias on a mtlxMix. Can't figure it out yet. Some way to fetch the sign of the magnitude of ray:direction then remap that into 0-1?
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
7771 posts
Joined: Sept. 2011
Offline
Enivob
You'd think the kma_ray_import would offer some type of 0-1 output value you could use to drive the bias on a mtlxMix. Can't figure it out yet. Some way to fetch the sign of the magnitude of ray:direction then remap that into 0-1?

N.I plugged into a greaterthan(0) should do it
User Avatar
Member
45 posts
Joined: Nov. 2016
Offline
Would someone be willing to give a more detailed explanation on how to do this?
User Avatar
Member
2537 posts
Joined: June 2008
Offline
I tried this type of setup, but couldn't get it to work. N.I means reference the ray normal and export it using an integer signature, right?

Attachments:
Untitled-1.jpg (292.3 KB)
ap_kr_two_sided_grid_image_120123.hiplc (716.5 KB)

Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
7771 posts
Joined: Sept. 2011
Offline
Enivob
N.I means reference the ray normal and export it using an integer

no, it means N dot I, as in dot product of the ray direction and the surface normal
User Avatar
Member
2537 posts
Joined: June 2008
Offline
Getting close with your suggestion. I see some purple, but I need red on one side and blue on the other.

Attachments:
ap_kr_two_sided_grid_image_120123.hiplc (737.3 KB)
Untitled-1.jpg (321.8 KB)

Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
7771 posts
Joined: Sept. 2011
Offline
Enivob
Getting close with your suggestion. I see some purple, but I need red on one side and blue on the other.

What is the input range of the remap set to? it should be something like -0.000001, 0.000001 to 0, 1 and clamped to simulate a switch. The ifgreater would be a better choice.
User Avatar
Member
85 posts
Joined: April 2017
Offline
I don't know maybe this is the setup you are after?
I think this is not yet supported by XPU

Edited by jomaro - Dec. 4, 2023 16:10:36
User Avatar
Member
7771 posts
Joined: Sept. 2011
Offline
jomaro
I don't know maybe this is the setup you are after?
I think this is not yet supported by XPU


That node isn't supported in XPU, but it's trivial to emulate it using switches going into a standard material.
User Avatar
Member
2537 posts
Joined: June 2008
Offline
@jsmack I tried the very small range numbers and very large. The greaterif didn't seem to help either.

I just wonder if the ray_import is actually working?

@jamaro Your method certainly works for CPU only render.
Edited by Enivob - Dec. 4, 2023 17:17:35
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
7771 posts
Joined: Sept. 2011
Offline
Enivob
I just wonder if the ray_import is actually working?

hmm, it's possible that's the issue. There are presets in the menu that should work for getting the ray direction though. I recently used it for making a fresnel blend, since one is missing in the factory node set.
User Avatar
Member
273 posts
Joined: Nov. 2013
Offline
rayimport seems to be working for me with xpu (on Mac OS tho)

Attachments:
rayimport.png (693.1 KB)

User Avatar
Member
7771 posts
Joined: Sept. 2011
Offline
Working fine here as well.

Attachments:
karma_twosided.hip (248.5 KB)
twoside.jpg (233.1 KB)

User Avatar
Member
2537 posts
Joined: June 2008
Offline
That was it. Thanks, everyone!

I was using ray:hitN instead of mtlxNormal node. I guess hitN is not the same as the geometry normal.
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
45 posts
Joined: Nov. 2016
Offline
Thank you guys very much!
User Avatar
Member
8 posts
Joined: July 2018
Online
There's a simpler way other then using 2 rayimport and dot product. You can directly using ray:backface to get a bool. This is listed in the documentation of the rayimport node, but don't know why it's not listed in the drop down menu probably is a bug.
  • Quick Links