iimachines / Maya2glTF

Maya to glTF 2.0 exporter
MIT License
325 stars 49 forks source link

Adding opacity map to glTF_PBR.ogsfx shader? #56

Open mikebourbeauart opened 6 years ago

mikebourbeauart commented 6 years ago

I found that you can change the glTF_PBR.ogsfx's technique to transparent, but I'm unable to find a slot to input an opacity map. How would you go about doing this/is it even possible?

ziriax commented 6 years ago

Currently the opacity map is the alpha channel of the base color, as the glTF spec dictates. Adding an opacity channel is certainly possible, but then it must be merged with the basecolor texture on export. Not a big deal, but it does bring additional complexity (like what codec to use, compression quality, chroma subsampling settings, ...). That being said, we already have code to merge occlusion, metallic and roughness into a single map, so most of the code for dealing with this is already there...

Is having a separate opacity map useful for you?

mikebourbeauart commented 6 years ago

I think it would be useful, and it seems to be a standard input (at least for transparent shaders). I'm not a shader pro though.

Here's what's going on with my file (i'm getting some other crazy results on publish, but that's another issue):

My baseColor doesn't seem to have an alpha or transparency. It's just blackness where I'm expecting transparency. I'm merging my Substance Painter output textures inside of Substance Designer. I'm then using the Substance plugin within Maya to load the designer shader. I get a graph like this:

image

Even though the files are pngs (i even opened up the file called 1077276536.png in photoshop to make sure it had transparency) everything comes in without transparency. I'm not sure how I would bake in an alpha map or get the transparency to register inside maya's shader network. So the only solution I know of would be to insert an opacity map into an alpha or opacity on the GLSL shader.

ziriax commented 6 years ago

Cool stuff!

Okay, you conviced me, a transparency channel will be added.

Unfortunately you will still need to set the technique to transparent for getting correct rendering though.

mikebourbeauart commented 6 years ago

Awesome, thanks! Are there any negatives to using the transparent technique?

ziriax commented 6 years ago

Besides potential wrong depth sorting of faces in the viewport, not really.

ziriax commented 3 years ago

I did some experiments, but Maya seems to pass wrong alpha values. For example, in the attached PNG, Maya makes the pixels around the circle opaque, while the blue ones are transparent...

Any idea why this is? My guess is that Maya is un-multiplying the alpha from the colors, but when diving by zero alpha, the result become Infinite, and is clamped to 1...

blue_transparent_circle