[Solved] Transparency/Shader problem

I’m having trouble getting transparency to work right with some Materials I’m using. The intent is for a wall to be translucent and the floor behind it to be opaque (should be able to see the floor tinted by the wall). Seems like it should be simple, but I’m missing something because the floor is not showing through the wall.



It seems that if I set the material to the standard “Common/MatDefs/Misc/Unshaded.j3md” that transparency seems to work fine. However, I need to use a different shader for other reasons and I can’t seem to figure out what the difference between the standard shader and my shaders is.







Here’s the java code to set everything up.



Texture tex = m_application.getAssetManager().loadTexture(“Textures/wood.jpg”);

tex.setWrap(Texture.WrapMode.Repeat);

Material m_woodFloor = new Material(m_application.getAssetManager(), “MatDefs/Unshaded.j3md”);

m_woodFloor.setTexture(“Tex”, tex);

m_woodFloor.setFloat(“TexScale”, 1.0f);

m_woodFloor.setFloat(“Alpha”, 1.0f);

m_woodFloor.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);

m_woodFloor.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);



Material m_wallMaterial = new Material(m_application.getAssetManager(), “MatDefs/Wall.j3md”);

m_wallMaterial.setColor(“color”, ColorRGBA.Blue);

m_wallMaterial.setFloat(“alpha”, 0.1f);

m_wallMaterial.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);

m_wallMaterial.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);





Here are my shader programs:



Wall.frag



uniform vec4 m_color;

uniform float m_alpha;



void main(void)

{

// set color

vec4 color = m_color;

color.a = m_alpha;

gl_FragColor = color;

}





Unshaded.frag



uniform sampler2D m_Tex;

uniform float m_TexScale;

uniform float m_Alpha;



varying vec2 texCoord;



void main(void)

{

// set color

vec4 outColor;

outColor = texture2D(m_Tex, texCoord.xy * m_TexScale);



outColor.a = m_Alpha;



gl_FragColor = outColor;

}

try to add:



[java]wallGeom.setQueueBucket(Bucket.Transparent);[/java]



and floor do not need that:

[java]

m_woodFloor.setFloat("Alpha", 1.0f);

m_woodFloor.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);

[/java]

why it could need it? use Common/MatDefs/Misc/Unshaded.j3md instead of yours MatDefs/Unshaded.j3md

Thanks on both accounts. I didn’t realize I had those redundant lines. It looks much better!