alpha-file egg directive

Greetings all!

I was wondering if anyone has had any luck with using the following directive in an egg file to specify the alpha channel of a texture:

<Scalar> alpha-file {alpha-filename}

I found this directive in the egg syntax documentation in the Sourceforge image, and it would be really helpful for what we’re currently trying to do. However, it doesn’t seem to work as advertised.

We have a texture (foo.jpg) and a corresponding grayscale alpha file (foo_alpha.jpg). When I open an egg file (model.egg) and change the reference for foo.jpg to the following:

<Texture> foo {
  <Scalar> alpha-file {foo_alpha.jpg}

… nothing happens to the texture at runtime (checking the data by loading it into a PNMImage shows it as a 3-channel texture, and no transparency effects can be seen). However, if I first load the texture and its alpha at runtime (by calling myFooTexture = loader.loadTexture(“foo.jpg”,“foo_alpha.jpg”) ), and then after this step load model.egg, then not only does myFooTexture behave correctly (shows alpha, has four channels) but also parts of the model in model.egg that use texture ‘foo’ behave correctly (which I assume is because the texture cache already has a texture named ‘foo’ loaded and so doesn’t load the one from the egg file, perhaps?).

Does anyone have any idea what I’m seeing here? Is ‘alpha-file’ simply not a supported egg file directive?

Thanks for your help!

Hmm, as far as I know, the alpha-file syntax in an egg file works as advertised. We rely on this feature every day in the VR Studio.

Is it possible that something else is going on, for instance, you’re loading a different version of the egg file than the one you’re modifying, or you’re loading the bam file without realizing it?


Ah, I found my mistake!

Since I’m not sure how to get egg-texture-cards to output an egg file with two-file alpha transparencies specified, I had hand-edited the egg file to include the alpha-file directives. In doing so, I had assumed Panda3d would change the default ‘format’ directive in the texture to rgba to allow for the alpha-file to be used. This appears to not happen; specifying

<Scalar> format {rgba}

inside the texture directive fixed the problem. With this change, the multi-file texture definitely works as advertised (that way of working being “awesomeness”)! :smiley:

In general, is there any reason that an alpha-file would be specified when the texture format doesn’t request an alpha channel? If not, when we finish this project I might have time to dig through the source code and look into causing the egg-loader to post a warning when it encounters an alpha-file directive on an rgb-format texture. It might be a good warning to have if there are no situations (outside of debugging) where configuring a texture in this format would be useful.

Thank you for the help!