Matcap shader in Karma XPU

   1232   3   0
User Avatar
Member
95 posts
Joined: Feb. 2020
Offline
Does anyone know how I can create a basic matcap shader in LOPs? This must be possible right, we're just using the normal for the texture coordinates of our matcap texture file, right?

The labs material shows up in Karam CPU, but when I switch the XPU the materials disappear.

When I use the labs quick shader node, I get a bunch of errors.

Using H 19.5

C:\PROGRA~1/SIDEEF~1/HOUDIN~1.303/houdini/python3.9libs\husd\previewshadertranslator.py", line 878, in createMaterialPreviewShader
    helper.createAndConnectUsdTerminalPreviewShader(
  File "C:\PROGRA~1/SIDEEF~1/HOUDIN~1.303/houdini/python3.9libs\husd\previewshadertranslator.py", line 351, in createAndConnectUsdTerminalPreviewShader
    self.createUsdPreviewShaderInputs( usd_shader, input_infos )
  File "C:\PROGRA~1/SIDEEF~1/HOUDIN~1.303/houdini/python3.9libs\husd\previewshadertranslator.py", line 773, in createUsdPreviewShaderInputs
    texture_shader = self.createAndConnectUsdTextureShader(
  File "C:\PROGRA~1/SIDEEF~1/HOUDIN~1.303/houdini/python3.9libs\husd\previewshadertranslator.py", line 488, in createAndConnectUsdTextureShader
    (attrib_value[0], attrib_value[1], attrib_value[2], 1),
TypeError: 'NoneType' object is not subscriptable
Edited by wyhinton1 - Jan. 31, 2024 00:54:04

Attachments:
houdini_Ee1Zu4RVOv.jpg (266.2 KB)

User Avatar
Member
8173 posts
Joined: Sept. 2011
Offline
a matcap shader is pretty simple, just remap the normal from -1 to 1 to 0 - 1 and connect to the uv of the texture map. However, the normal needs to be in camera space. This is simple for Karma CPU, just set the space on the mtlx normals node to "space:camera", however this doesn't work with XPU. I'm not sure how to get camera space normals with XPU--without the unnecessarily complex coordsys technique which also has restrictions on the structure of the scene.
User Avatar
Member
95 posts
Joined: Feb. 2020
Offline
jsmack
a matcap shader is pretty simple, just remap the normal from -1 to 1 to 0 - 1 and connect to the uv of the texture map. However, the normal needs to be in camera space. This is simple for Karma CPU, just set the space on the mtlx normals node to "space:camera", however this doesn't work with XPU. I'm not sure how to get camera space normals with XPU--without the unnecessarily complex coordsys technique which also has restrictions on the structure of the scene.


Based on your notes I was able to get this work. I notice that it seems like I need to use slightly different values for the remap in order to get the texture to cover the entire surface, otherwise I get these black patches:




Using I get a better result -1.1 to .9 to remap. Not sure why.


I'm not sure how to get camera space normals with XPU--without the unnecessarily complex coordsys technique which also has restrictions on the structure of the scene.

Do you have any examples of settings this up? What kind of restrictions?

Switching to XPU causes Houdini to crash :/

Attachments:
matcapLopsCPU.jpg (267.8 KB)
blackpatches.jpg (310.7 KB)

User Avatar
Member
8173 posts
Joined: Sept. 2011
Offline
wyhinton1
Based on your notes I was able to get this work. I notice that it seems like I need to use slightly different values for the remap in order to get the texture to cover the entire surface, otherwise I get these black patches:

you need to extrapolate the edges so the black parts are just filled in with the border value.

wyhinton1
I'm not sure how to get camera space normals with XPU--without the unnecessarily complex coordsys technique which also has restrictions on the structure of the scene.

Do you have any examples of settings this up? What kind of restrictions?

Use the coordsys LOP to create a coordsys binding from a camera, then the binding can be referenced by name in the shader as a named space. The limitation is the binding has to be on a prim that is a common ancestor of all of the prims in the relationship: the camera, the object, and the material. I usually do this by making a "root" prim that has the whole scene below it and put the coordsys binding on this root prim. It's a bit of a pain to set up and the coordsys node is not very intuitive.
Edited by jsmack - Jan. 31, 2024 19:19:35

Attachments:
MatCap_mtlx.hip (307.8 KB)

  • Quick Links