Textures, Alpha and Geom

It would seem that textures with alpha lose their alpha if applied to geom object.

This is an odd behavior and I can’t seem to find a way to “enable” the alpha channel.

This image is of a cube imported from an egg file and a sculpt object generated from my SculptMaker.py here https://discourse.panda3d.org/viewtopic.php?t=6326

The relevant code that created this:

        tex = loader.loadTexture('texs/domeglass.png')

        self.cube = Sculpt("TwistPlane", "maps/scu-TwistPlane.png", (1.0,1.0,1.0,0.0)).generate()
        self.cube.setTexture(tex)
        self.cube.reparentTo(render)
        self.cube.setPos(0,0,0)
        self.cube.setScale(3,3,1)

        gr = loader.loadModel('cube.egg')
        gr.reparentTo(render)
        gr.setTexture(tex)
        gr.setPos(0,0,0)
        gr.setScale(1,1,1)

Anyone have any ideas on this? Is it a random bug or did I fail to do something important?

You need to set the transparency mode too.

object.setTransparency(TransparencyAttrib.MAlpha)

MAlpha is the fastest and works for most cases. However, sometimes you run into transparency issues and you might want to try the more expensive MDual, or MBinary (if you have no semi-transparent prats) or if that’s not enough MMultisample. Read more about it here:
panda3d.org/manual/index.php/Trans … d_Blending

I attempted this solution, strangely enough the result of enabling the TransparencyAttrib was that the object, even the egg, became completely transparent.

Further experiments have proven even stranger. If I create the cube egg in blender and don’t specify a texture, it also sheds it’s alpha in panda. This happens in cases where the texture image has an alpha channel and also where I specify a greyscale image for the alpha. In this case, the object loaded from the egg also vanishes like the geom object if I set the TransparencyAttrib. A strange result. This happens in both 1.5.4 and 1.6.1, I tested both to see if it was a version bug.

I’d upload a screenshot of the objects with the TransparencyAttrib set as you suggested, but as I typed, they are not present in the window so it’ be of little point.

An even stranger behavior!

I created two egg files with blender (using the most current (R69) chicken export scripts). In one I specified the texture image to be the one from the earlier screenshots, the other I put no texture or material at all. If I load the one with the specified texture, I get alpha, the one without a texture however has no alpha when I set it’s texture to an alpha channel having texture in script.

Further strangeness is that if I set the TransparencyAttrib to MAlpha for the object loaded from the egg that had no texture and previously (before setting the TransparencyAttrib) ignored alpha, it now displays alpha, where the geom object continues to disappear.

I have the color on the geom object set to (1,1,1,0), is it possible that this color is what is triggering the full transparency?

Thanks pro-rsoft! You lead me to the solution. It would seem that setting the TransparencyAttrib to MAlpha or otherwise causes the alpha to be computed by subtracting the alpha value of the texture from the vertex color instead of replacing it. If I set my color to (1,1,1,1) instead of (1,1,1,0) when the geom object is built, then enabling MAlpha works. If the color value has 0 for alpha then the object becomes completely transparent.

May seem odd but your suggestion, that I’d actually tried before posting, caused me to test more rigorously, cheers!