Page MenuHome

FBX import principled alpha 0
Closed, ResolvedPublic


System Information
Operating system: Windows-7-6.1.7601-SP1 64 Bits
Graphics card: GeForce GTX 1050 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 399.07

Blender Version
Broken: version: 2.80 (sub 72), branch: blender2.7, commit date: 2019-05-23 20:37, hash: rBb3f96da2e605
Worked: (optional)

since the principled shader got alpha feature everything i'm importing with fbx has alpha 0 by default. it may be helpful if by default fbx will bring objects with alpha 1

Event Timeline

Brecht Van Lommel (brecht) renamed this task from principled alpha 0 to FBX import principled alpha 0.Fri, May 24, 11:24 AM

@Bastien Montagne (mont29), seems to be a continuation of T59850 :(

@Andrei Salamandic (andreymd87), where does this file come from exactly? Which program exported it?

@Thomas Chollet (thomasch) applying the method you gave me (the one used by Unity) will indeed give 0 alpha with this file, since the template sets TransparencyFactor to 0.0, then each material only defines the TransparentColor to pure white, and Opacity to 1.0… Wondering what is the result here with Unity with this file?

In the mean time, I'll just use Opacity when given in material itself (and not in its template), and TransparencyFactor is 1.0 or 0.0sigh… FBX…

That file looks fine in Unity, the values I see on import are TransparentFactor=0 and TransparentColor=(1,1,1) for the 'leather_black' material. However, we're using the FBX SDK and we don't deal with the template properties, we get the values from the API, so the SDK must do some magic under the hood.
I opened the file in FBX Converter and it looks like TransparencyFactor is not defined in the Material, but is defined in the template. So I'm assuming that property values returned by the SDK are the material value if present or the template value.
The 'opacity' property is not used in the Unity importer. Maybe try something like this ? :

transparencyFactor = elem_props_get_number(fbx_props_no_template, b'TransparencyFactor', None)
if transparencyFactor is None:
    transparencyFactor = elem_props_get_number(fbx_props, b'TransparencyFactor', 0.0)
alpha = 1.0 - transparencyFactor
if (alpha == 1.0 or alpha == 0.0):

@Thomas Chollet (thomasch) That’s already what we were doing (we always get values from actual data first, and only use template ones as fallbacks). But in that case, since we get TransparencyFactor (from template) of 0.0, we apply alpha = 1.0 - TransparentColor.r, which gives an alpha of 0.0… which is opposite of actual value. Thus I do not understand how Unity can do that properly, applying the algorithm you gave me in T59850? TransparentColor would need to be pitch black here (0, 0, 0) for that method to give proper alpha value?

Hi @Bastien Montagne (mont29), I'm sorry, it seems like I left out the last part of the algorithm last time. There's actually another check for alpha==0 after alpha = 1.0 - TransparentColor.r.
It should look like this :

alpha = 1 - transparencyFactor
if (alpha ==1 || alpha==0)
alpha = 1- transparentColor.r
if (alpha ==0)
alpha = 1

Sorry for the confusion..

Uhu… that’s weird… looks like you can never have 0 alpha then…

I prefer my solution tbh, which can be summarized to:

alpha = 1.0 - TransparencyFactor
if (alpha == 1.0 or alpha == 0.0):
    alpha = Opacity_without_template_data or None  # Disregarding template data for that one, only using in case it's explicitly given in material.
    if alpha is None:
        alpha = 1.0 - TransparentColor.r

… but FBX data interpretation is really the worst thing I have ever seen in an 'exchange' format… (granted, I never had to work on Collada) :((((

oh I didn't even realize that! you're right we can't have alpha 0... and this must have been the case for a while. I took some time to investigate and so far, at least with the more recent versions of Max and Maya, it looks like Opacity behaves correctly. Not sure yet if that works with older files, I'll try to test more files and confirm that when I get the time... But basically, your solution seems to work ok, the only issue I found is that Opacity animation curves are not exported, so for animations we still have to rely on TransparencyFactor and TransparentColor.
Maybe we need a FBX SDK user emotional support group...

Maybe we need a FBX SDK user emotional support group...

Hihihi! Even just an “FBX user emotional support group”, I think (Blender does not use the SDK, for licensing reasons)… ;)