UsdPreviewSurface use alpha of UsdUVTexture as opacity input

   2312   4   0
User Avatar
Member
10 posts
Joined: Sept. 2019
Offline
Hi,

am I doing something wrong, or is this something that is not fully featured in Karma yet?
Trying to use the alpha channel of my png file to plug into the opacity field of the UsdPreviewSurface shader, which doesn't work.
The only thing that works is to put the rgb value into the opacity channel (which doesn't make sense, as this is a vector3 instead of a float input and I also don't want).

So I've created that material and then created this Inline USD node to check by syntax according to the pixar usd documentation what pieces I have to change.

over "camera" (
)
{
over Material "material" (
)
{
over Shader "material"
{
uniform token info:id = "UsdPreviewSurface"
color3f inputs:diffuseColor = (1, 1, 1)
color3f inputs:emissiveColor.connect = </camera/material/texture.outputs:rgb>
float inputs:ior = 1
float inputs:metallic = 1
float inputs:opacity.connect = </camera/material/texture.outputs:rgb>
float inputs:opacityThreshold = 0.5
float inputs:roughness = 0
token outputs:displacement
token outputs:surface
}

over Shader "texture"
{
uniform token info:id = "UsdUVTexture"
asset inputs:file = @/opt/dev/mytexture.png@
float outputs:a
vector3f outputs:rgb
}

This line: float inputs:opacity.connect = </camera/material/texture.outputs:rgb>
Should be: float inputs:opacity.connect = </camera/material/texture.outputs:a>
Although when I only use the alpha channel of the texture (which is a png and has an alpha channel, I've checked that in Nuke), I don't get any alpha at all. Using only r, g or b as a value works, so it can't be related to vector vs float inputs. Maybe the UsdUVTexture is unable to read the alpha channel of pngs?

Is that a bug? Is there something wrong in my setup, although this setup is quite basic.

Cheers
Edited by msearl001 - July 7, 2020 03:42:28
User Avatar
Staff
2590 posts
Joined: July 2005
Offline
This should be supported - it looks like a bug. I've submitted one into the bug database for you.
User Avatar
Staff
2590 posts
Joined: July 2005
Offline
This should be fixed in tomorrow's daily build of H18.

If you load up the attached .hip file you should see the surface become refractive where the opacity is zero. If you want a cut-out behaviour instead, you can increase the opacityThreshold to a very small amount (0.0001).

Attachments:
opacity.hip (136.8 KB)

User Avatar
Member
10 posts
Joined: Sept. 2019
Offline
Awesome. Thanks for this quick support! You guys rock!
User Avatar
Member
12 posts
Joined: Aug. 2013
Offline
Should USDZ work on iOS Quick Look with this example? In HOU19.0.383 this example, adjusted with the following suggestion

> increase the opacityThreshold to a very small amount (0.0001).

still shows as a grid, no alpha
  • Quick Links