Applying Texture with Alpha Channel to a Plane

Hi there,

I’m currently trying to write a script that automatically applies an image to a plane in an Omniverse scene. I was able to automatically create an MDL with an extension and set the diffuse texture to the desired image, but the texture has an alpha channel, and the alpha channel was lost when it was used for the diffuse texture. I’ve tried doing some image-processing to create an alpha texture and adding that to the material as well, but it seems like on the Omniverse side, the alpha channel behaves as a binary On/Off rather than allowing for smooth transitions from visible to invisible. Any advice on the best way to implement this would be much appreciated!

Hi @jlw387. I’m going to assume you’re using OmniPBR, but OmniSurface should work similarly. You shouldn’t need to do any image processsing. You can tell the Opacity attribute to use the alpha channel of an RGBA image. Here it is working for me:

For Real-Time renderer, you’ll need to enable “Fractional Cutout Opacity”. For Interactive, it should just work.

Thanks @mati-nvidia, this works pretty well! I do notice some issues with the borders having a bit of an off-color border in certain areas (see examples):

Note that the texture itself cuts off the line on the right side; the problem is that there are two strips of white not present in the original texture.

Adjusting the opacity threshold seems to help, but it doesn’t completely remove the white border until I set it at 1.0, which makes the opacity binary again.

Follow up on this @mati-nvidia, we’re having some difficulties with inconsistencies with the proposed solution. Specifically, we noticed that changing the color space entry leads to wildly varying behavior, as can be seen in the attached video.

2023-02-06 16-54-25.mkv (5.1 MB)

This inconsistency is making it difficult to guarantee that our texture shows up correctly, as we want to do this programmatically in the extension and we can’t easily cycle through the options until it works within the Python script.

Hi @jlw387. I can’t repro that colorspace issue, but I’ll check with others to see if they can. Let me know if you made any render setting changes. Can you also try on Code-2022.3.1?

It’s very difficult for me to reproduce as well; it doesn’t seem to happen consistently.

I don’t think I made any other render setting changes.

I think this actually was on Code 2022.3.1, but I can’t exactly remember. I’ll see if I can reproduce it more consistently in 2022.3.1 and follow up if I can.

Another thing that I was able to reproduce much more consistently is that choosing a Color Image with the file picker doesn’t always result in an update to the material until I also change one of the RGB values for the diffuse color in the sliders above it, even though those don’t get factored into the material when the Color Image parameter is used. I’m pretty sure this was because I was trying to reload a file with the same path that was changed, but I’m not 100% certain. I’ll try and get a specific setup to reproduce it, but in the meantime I’d recommend checking whether or not changing this field always triggers an update callback when entering the same file path or for other possible edge cases.

EDIT: I guess it probably wasn’t the same file name that caused this, because testing it out, I don’t even need to reload the texture in Omniverse to see the changes, they get applied automatically. Tried to switch back to Code 2022.3.0 to see if it was a problem with the older version but I couldn’t reproduce it there either. I’ll keep trying to figure it out.

Could you share a simple stage and include your test image? You can use Collect Assets and then zip that up or just give me the USD file and the image and I’ll figure it out from there.