If I recall correctly, Panda3D automatically recognises a loaded object having a transparent texture, and assigns such objects to the “transparent” bin. First of all, do I have that correct?
If so, what are the conditions for considering an object to be “transparent”? I gather that having a semi-transparent colour-texture would qualify, but would a semi-transparent normal map do so, too? And if an object has more than one colour-texture, do any of the textures after the first count towards it being considered “transparent”?
[edit]
What about vertex-colours, come to that? How do they influence the sorting, if at all?
[/edit]
And finally, I know that I can examine which objects are considered to be transparent by including " show-transparency 1" in my “prc” file. Does this cover everything that has been automatically sorted into the “transparent” bin? If not, is there a way to see what has been so sorted?
Normally, one can specify a specific <Scalar> alpha { on } (or other mode) tag, which enables the equivalent of node_path.set_transparency(TransparencyAttrib.M_alpha), which indeed causes the object to be sorted into the transparent bin.
When such a tag is not specified, Panda3D sets it to on if any of the following conditions apply:
If any texture applies to the model with an alpha channel.
If the material has a diffuse color with alpha value other than 1.0.
If the primitive has a color with alpha value other than 1.0.
If any of the vertices of the primitive has an alpha value other than 1.0.
You can override this default behaviour by explicitly setting your own alpha mode, either in the <Texture> or in the primitive.
This will flash object with a color dependent on which TransparencyAttrib mode is applied. Different TransparencyAttrib modes will do different things, but the plain old M_alpha does do nothing more than sort it into the transparent bin indeed.
If you specifically want to flash objects that are in a specific bin, you can do something like this:
The code that you posted is quite useful! With it causing the “transparent” bin to flash, I see some things flashing that aren’t intended to be transparent–but rather less than I expected. As almost all of my normal-maps make use of their alpha-channel, I somewhat expected much of my game to end up flashing!
As to vertex-colours, I do in some cases store data in the alpha channel of my vertex-colours. I may thus want to remember to specify that objects in which I do so not be considered transparent, where called for.