I’ve started texturing the vehicles in my game and I decided I wanted to make use of gloss maps and glow maps, but I’ve run into a problem. When I add additional textures to my model, the gloss and glow textures are being treated as if they were plain white images. This didn’t happen when I was storing the gloss or glow information in an alpha channel and using the MModulateGloss and MModulateGlow modes for my texture stages. Since I can’t use multiple alpha channels, I need to apply the two maps separately. When I use MGloss and MGlow and add the textures separately, the gloss and glow maps are treated as if they were blank white images. I’ve gone through the manual and the forums and for the life of me, I can’t figure out why this is happening. I did check my gpu’s limit on the number of texture stages using the method in the manual, and I came up with 4.
I have a call to render.setShaderAuto() in my program, and I do see gloss and glow effects. The problem is that the effects are not limited by the textures I am feeding them. The gloss is too bright for a mostly 25% gray image, and the glow is emitting from parts of the texture that are quite black.
Here are the two images being used for the textures, the first is ColorGloss01.png, and the second is Glow01.png:
ColorGloss01.png
Glow01.png
And here is the resulting effect:
You can see by comparing the two images that only the blue parts should be glowing, the rest should not. I left the bloom filter on for this image because it makes the effect even more obvious, but I assure you that with the bloom off the light gray areas have their emission maxed out by the glow.
I can’t figure out why Glow01.png isn’t limiting the glow effect, and I have the same problem with gloss maps.
I understand that, and I have gotten it to work that way. I can also get gloss maps to work that way. However, I wanted to get both a gloss map and a glow map on the same node. Is that not possible?
loadTexture() will cache texture loads based on the primary texture name. So the second call to loadTexture() with the same primary texture name will return the first texture, even though you have specified a different alpha texture name.
There are other hacks you can do, including TexturePool.releaseTexture(), or an explicit call to tex.read(), but probably using a different texture file is the easiest and least hacky solution.
It’s going to end up consuming redundant memory anyway, so there’s not really any good reason to avoid doing this.
This, again, makes no difference to your memory usage.
Another approach is to define Glow01.png as a two-channel grayscale/alpha image, with the desired color in the color channel, and the desired alpha in the alpha channel. Then you don’t have to use the two-parameter loadTexture() call at all.
(Honestly, I don’t know why the manual recommends the two-parameter loadTexture() call over simply putting the alpha channel in the right place in the first place.)