gazebosim/gz-common

Collada <transparency> setting

Ouverte

#229 ouverte le 12 juil. 2021

 (0 commentaire) (0 réaction) (0 personne assignée)C++ (59 forks)auto 404
bughelp wanted

Métriques du dépôt

Stars
 (28 étoiles)
Métriques de merge PR
 (Merge moyen 9j 6h) (30 PRs mergées en 30 j)

Description

Environment

  • OS Version: Ubuntu 18.04
  • Source or binary build? both - all versions

Description

The transparency result is different between Ignition ColladaLoader and threejs's CollaLoader if <transparency> tag is present, and <transparent> tag is missing, e.g. the follow tag produces an opaque mesh in Ignition but a transparent mesh in threejs:

            <transparency>
              <float sid="transparency">0.000000</float>
            </transparency>

Looking at the collada spec (pdf) spec, the default mode should be A_ONE. The current code sets transparency in the following way:

      dstFactor = 1.0 - color.A() * transparency;
      srcFactor = color.A() * transparency;
      _mat->SetTransparency(dstFactor);

This should produce a transparency value of 1.0 which means fully transparent.

Other notes

_mat->SetTransparency(dstFactor); is a bit confusing since srcFactor is the one that corresponds to the object's material opacity. However, the math works out to be correct because:

transparency = 1.0 - opacity
             = 1.0 - srcFactor
             = dstFactor

Guide contributeur