Alpha blending...need help!

hola everyone.



I am making 2.5D game with JME2. I was maping a texture to a Quad. My texture is png with transparent background. So texture is mapped correctly. My texture image has few void space at the corners with transparent color so when texture is mapped to quad then those void space are also visible i.e quad is visible at those void areas. So i want to make Quad transparent so that my texture and quad melts with my background scene. I just want to know how to make quad transparent or apply alpha values. I hope you understand my problem.



Gracias.

The secret for transparency is the BlendState.



http://www.jmonkeyengine.com/wiki/doku.php/transparency

i think i am making some mistake here as i am not getting the desired output…



This is how my texture is getting rendered:

http://picasaweb.google.co.in/padam1989/2dTexturesSprites#5444640829721374802

there is black color at void spaces where it should be transparent. I have a landscape texture as a background so those that landscape should be visible in place of that black areas. How to achieve that ??



here is the code


Quad land = new Quad("land1", 200, 10);

TextureState ts2 = display.getRenderer().createTextureState();

Texture t1 = TextureManager.loadTexture(
                Space.class.getClassLoader().getResource(
                "data/long-green.png"),
                Texture.MinificationFilter.Trilinear,
                Texture.MagnificationFilter.Bilinear);
ts2.setTexture(t1);

MaterialState ms=display.getRenderer().createMaterialState();
        ms.setAmbient(new ColorRGBA(0.5f,0.5f,0.75f,0.5f));
        ms.setDiffuse(new ColorRGBA(0.5f,0.5f,0.75f,0.5f));
        ms.setSpecular(new ColorRGBA(0.5f,0.5f,0.75f,0.5f));
        ms.setEnabled(true);
        land.setRenderState(ms);
        land.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);

BlendState bs=display.getRenderer().createBlendState();
        bs.setBlendEnabled(true);
        bs.setSourceFunctionAlpha(BlendState.SourceFunction.SourceAlpha);
        bs.setDestinationFunctionAlpha(BlendState.DestinationFunction.OneMinusSourceAlpha);
        bs.setBlendEquation(BlendState.BlendEquation.Subtract);
        bs.setTestEnabled(false);
        bs.setEnabled(true);
        land.setRenderState(bs);

scene.attachChild(land);
scene.updateRenderState();

Riddle,



I've tried your code and the code snippet doesn't contain all the details (as you don't set the texture as the land renderState), however I do know what was wrong with it.



Firstly, a side note:

        
ms.setAmbient(new ColorRGBA(0.5f,0.5f,0.75f,0.5f));
ms.setDiffuse(new ColorRGBA(0.5f,0.5f,0.75f,0.5f));
ms.setSpecular(new ColorRGBA(0.5f,0.5f,0.75f,0.5f));



Here you've set the alpha for the material's ambient, diffuse and specular at 0.5, this usually means the object will appear opaque

Gracias.

Now there is no black color around the corner and its transparent there.