Page MenuHome

Collada: Import transparent color from materials
Needs ReviewPublic

Authored by Sandy Carter (bwrsandman) on Apr 24 2016, 9:36 PM.

Details

Summary

Set materials without (1, 1, 1, 1) opacity as transparent.
Use single channel (Alpha) to populate alpha value.

Diff Detail

Repository
rB Blender

Event Timeline

Sandy Carter (bwrsandman) retitled this revision from to Collada: Import transparent color from materials.Apr 24 2016, 9:36 PM
Sandy Carter (bwrsandman) updated this object.
Sandy Carter (bwrsandman) set the repository for this revision to rB Blender.
Sandy Carter (bwrsandman) updated this revision to Diff 6519.

Not sure, what exactly does it fix?

@gaia, mind having a look?

The issue can be seen when importing a collada file which has a material with transparency in a color and not a texture. Currently, blender will create non-transparent materials for these collada materials.

This fixes it by checking for the default non-transparent opacity color (white). If it is different, it will assign a transparent material and use the alpha of the opacity color.

Best would be to get a blend file that can be used to check if the Blender collada exporter exports the material correct (with transparency). If the exporter can not do this right now, i can take a look into this.

Also it would be nice to get a collada file that can be used to check Blender's collada importer. Then we can verify that the patch does what it is supposed to do on the importer side.

thanks

Here an example .blend file (

) and the corresponding .dae file () generated with blender 2.77a.

It's a cube with .75 alpha and transparency enabled.

The generated .dae file seems to alright in the xml:

<effect id="Material-effect">
  <profile_COMMON>
    <technique sid="common">
      <phong>
        <!-- ... -->
        <transparency>
          <float sid="transparency">0.75</float>
        </transparency>
        <!-- ... -->
      </phong>
    </technique>
  </profile_COMMON>
</effect>

And when you look at the .dae in another application such as FBX review, the transparency is still there:

However, when importing the .dae in blender it loses its transparency information.

From this, I can confirm the issue is in the import and not the export. I have also had these issues with non-blender generated .dae.

Hi Sandy;

Thanks for the patch. I applied it with a small change:

You check on color != white instead of alpha < 1
As far as i can see, both checks should give the same result in this case.
But since at the end it is the alpha value that gets assigned it sounds more to the topic to check on alpha < 1.

Please let me know if i overlooked anything.

cheers,
Gaia

Hi Gaia,

Thanks for merging.

In the future I'd appreciate it if the commit properly listed me as author (e.g. https://developer.blender.org/diffusion/BA/history/master/;dbb54eee76d38e6936f0a32fd21a14844800f498)

As for color != white instead of alpha < 1, it was simply to cover more of the case where the transparency mode was activated but the alpha was still set to 1. White seems to be the default value exported when the transparency mode has not been activated.

Alpha < 1 seems fine. I don't think anyone will complain that their alpha 1 material is no longer transparent.

Regards,
Sandy

Hi, Sandy;

I am very sorry for this. I tried a lot to get your name mentioned as you want it to be. But i can not figure out how i can do this. I tried using the --author attribute during commit, but this gives me unknown author error. It looks like i needed your email address to use --author in that case but i can not find your email address. So i mentioned you in the commit message instead. I meanwhile also asked in the irc about how to do this. But so far i was advised to just add a "thank you for the patch" here.

But i already mentioned you in the commit message. So i thought that was the best i could do. Anyways, thanks a lot for your patch!,

For the future i will figure out how mont29 did it in the example you mentioned, so i can make it right the next time :)