No luck with multitexture quad + alpha


I’ve spent hours on this, but probably someone who knows what they’re doing can tell me what’s wrong in 1 minute or less. I am probably missing one line or property or something.  :oops:

I started making a command menu with buttons (like in a typical RTS game for build units, upgrade units, etc). This is made of several buttons (Quads) in an ortho Node. My plan was to simply have each button be one Quad with 4 textures units: 0 = glow for rollover effect, 1 = button icon, 2 = disabled x-out, 3 = highlight glow. Each of these textures is a 64x64 png with transparency. I must have the wrong idea of how alphastate and multitexturing works – I just can’t get this even close to looking right.

Reduced to a simple case with just 2 textures, suppose texture 0 is

and texture 1 is . What I thought I could get was but I can’t find the combination of properties that does it.

Here’s the short test case:

package ca.jotests;

import com.jme.image.Texture;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.Renderer;
import com.jme.scene.Node;
import com.jme.scene.shape.Quad;
import com.jme.scene.state.AlphaState;
import com.jme.scene.state.LightState;
import com.jme.scene.state.TextureState;
import com.jme.system.DisplaySystem;
import com.jme.util.LoggingSystem;
import com.jme.util.TextureManager;

public class TestMultiTextureAlphaOrtho extends SimpleGame {

   protected void simpleInitGame() {
            "This video card has a total of " + TextureState.getNumberOfTotalUnits() + " texture units.");
            "This video card has a total of " + TextureState.getNumberOfFixedUnits()
                  + " fixed function pipeline texture units.");


      Node hud = new Node("Hud");

      Texture tx0;
      tx0 = TextureManager.loadTexture(TestMultiTextureAlphaOrtho.class.getClassLoader().getResource("ca/jotests/tx0.png"),
            Texture.MM_LINEAR, Texture.FM_LINEAR);

      Texture tx1;
      tx1 = TextureManager.loadTexture(TestMultiTextureAlphaOrtho.class.getClassLoader().getResource("ca/jotests/tx1.png"),
            Texture.MM_LINEAR, Texture.FM_LINEAR);

      TextureState txs = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
      txs.setTexture(tx0, 0);
      txs.setTexture(tx1, 1);

      AlphaState as = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();

      Quad q = new Quad("q", 64, 64);
      q.getLocalTranslation().set(160, 100, 0);
      q.copyTextureCoords(0, 0, 1);

   public static void main(String[] args) {
      TestMultiTextureAlphaOrtho app = new TestMultiTextureAlphaOrtho();

One texture looks like and the other looks like .  Great. But I tried all combinations of alphastate properties and test functions yet can't get it to look like what I'd expect. Just nothing, all black, or partical masked out black.

Even if I got passed this and got the textures working, is it worth pursuing? I mean will it work to switch texture on and off within a texture state? For example, can I use textureState.removeTexture(0) to turn off a button's rollover effect, and set the texture again to turn it on?

The jME test TestMultitexture works fine for me. My gfx card has 6 texture units. I noticed TestMultitexture doesn't use an AlphaState at all in multitexturing so maybe that's where I'm confused.

Any input is appreciated. Thanks.

Try using AM_DECAL as the apply mode of the texture in unit 1

Thanks, that was it. Setting AM_DECAL on 3 of the 4 button textures (rollover, highlight, disable) makes them work just like I hoped for.

Glad to hear it. :slight_smile: