The texture mode setting is a major factor in determining how the texel value (color and/or alpha) affects the non-texture pixel color and alpha values. The actual texturing operation depends on the combination of the texture format and the texture mode.

The default texture mode is REPLACE, the other options are BLEND, DECAL, and MODULATE.

This program shows the effect of a Textured Box with different texture mode.

 private BranchGroup createSceneGraph(SimpleUniverse su){

    ...
    
    // Create a textured box with REPLACE mode
    MyBox box1=new MyBox(0.6f,0.6f);
    Appearance appear=box1.getAppearance();
    appear.setTexture(createTexture());
    
        // Map the texture coordinate
    TexCoord2f[] texCoords = new TexCoord2f[24];
    for (int i = 0; i < texCoords.length; i += 4) {
      texCoords[i] = new TexCoord2f(1.0f, 0.0f);
      texCoords[i + 1] = new TexCoord2f(0.0f, 0.0f);
      texCoords[i + 2] = new TexCoord2f(0.0f, 1.0f);
      texCoords[i + 3] = new TexCoord2f(1.0f, 1.0f);
    }
    
    QuadArray quadArray=(QuadArray)box1.getGeometry();
    quadArray.setTextureCoordinates(0, 0, texCoords);
    tg1.addChild(box1);
    
    // Create a textured box with BLEND mode
    MyBox box2=new MyBox(0.6f,0.6f);
    appear=box2.getAppearance();
    Texture texture=createTexture();
    texture.setBoundaryModeT(Texture.CLAMP);
    texture.setBoundaryModeS(Texture.WRAP);
    appear.setTexture(texture);
    TextureAttributes ta=new TextureAttributes();
    ta.setTextureMode(TextureAttributes.BLEND);
    appear.setTextureAttributes(ta);
    
        // Map the texture coordinate
    texCoords = new TexCoord2f[24];
    for (int i = 0; i < texCoords.length; i += 4) {
      texCoords[i] = new TexCoord2f(1.0f, 0.0f);
      texCoords[i + 1] = new TexCoord2f(0.0f, 0.0f);
      texCoords[i + 2] = new TexCoord2f(0.0f, 1.0f);
      texCoords[i + 3] = new TexCoord2f(1.0f, 1.0f);
    }
    
    quadArray=(QuadArray)box2.getGeometry();
    quadArray.setTextureCoordinates(0, 0, texCoords);
    tg2.addChild(box2);
    
    // Create a textured box with DECAL mode
    MyBox box3=new MyBox(0.6f,0.6f);
    appear=box3.getAppearance();
    texture=createTexture();
    texture.setBoundaryModeT(Texture.WRAP);
    texture.setBoundaryModeS(Texture.CLAMP);
    appear.setTexture(texture);
    ta=new TextureAttributes();
    ta.setTextureMode(TextureAttributes.DECAL);
    appear.setTextureAttributes(ta);
    
        // Map the texture coordinate
    texCoords = new TexCoord2f[24];
    for (int i = 0; i < texCoords.length; i += 4) {
      texCoords[i] = new TexCoord2f(1.0f, 0.0f);
      texCoords[i + 1] = new TexCoord2f(0.0f, 0.0f);
      texCoords[i + 2] = new TexCoord2f(0.0f, 1.0f);
      texCoords[i + 3] = new TexCoord2f(1.0f, 1.0f);
    }
    
    quadArray=(QuadArray)box3.getGeometry();
    quadArray.setTextureCoordinates(0, 0, texCoords);
    tg3.addChild(box3);
    
    // Create a textured box with MODULATE mode
    MyBox box4=new MyBox(0.6f,0.6f);
    appear=box4.getAppearance();
    texture=createTexture();
    texture.setBoundaryModeT(Texture.CLAMP);
    texture.setBoundaryModeS(Texture.CLAMP);
    appear.setTexture(texture);
    ta=new TextureAttributes();
    ta.setTextureMode(TextureAttributes.MODULATE);
    appear.setTextureAttributes(ta);
    
        // Map the texture coordinate
    texCoords = new TexCoord2f[24];
    for (int i = 0; i < texCoords.length; i += 4) {
      texCoords[i] = new TexCoord2f(1.0f, 0.0f);
      texCoords[i + 1] = new TexCoord2f(0.0f, 0.0f);
      texCoords[i + 2] = new TexCoord2f(0.0f, 1.0f);
      texCoords[i + 3] = new TexCoord2f(1.0f, 1.0f);
    }
    
    quadArray=(QuadArray)box4.getGeometry();
    quadArray.setTextureCoordinates(0, 0, texCoords);
    tg4.addChild(box4);
    
    ...
}