[BUG?] Problem with Transparent Materials

I was running into some really big problems with getting a simple shadow texture on a quad to display. It ran fine, but the quad was always coming up as solid black. I was referencing the HelloMaterial tutorial heavily for guidance, and in frustration, decided to play with some more simple things in a smaller app.

What I ran into was somewhat interesting. If I took the code from HelloMaterial (on the wiki) and commented out all of boxshape1's code, and placed boxshape3 at the end of the code (after the shiny rock code block), suddenly, the transparent effect of boxshape3's png is gone! The area that should be transparent is just black now. - Now, if I uncomment out boxshape1, the transparency is back!

Also, is there a reason if I place a SolidColor.j3md box behind the transparent texture'd boxshape3 between it and the shiny rock, the SolidColor'd box is not viewable through the boxshape3's transparent 'window?'

Sorta confused. Code below.

Running on a nVidia Quadro 1600M on jME nightly build 7-16-2010.

UPDATE: Updated video card drivers to latest version, and updated to latest jME3 nightly build of 08-05-2010. Problem persists. I'll hit a regular Joe Schmo machine with a Geforce 8800GT tonight to check again.

UPDATE2: Checked on GeForce 8800GT, same problem. Took some screenshots this time. See attached.

package hello06;
import com.jme3.app.SimpleApplication;
import com.jme3.asset.TextureKey;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Sphere;
import com.jme3.texture.Texture;
public class HelloMaterial extends SimpleApplication {
  public static void main(String[] args) {
    HelloMaterial app = new HelloMaterial();
  public void simpleInitApp() {
    /** A simple textured cube -- in good MIP map quality. */
//    Box boxshape1 = new Box(new Vector3f(-3f,1.1f,0f), 1f,1f,1f);
//    Geometry cube = new Geometry("My Textured Box", boxshape1);
//    Material mat_stl = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
//    Texture tex_ml = assetManager.loadTexture("Interface/Logo/Monkey.jpg");
//    mat_stl.setTexture("m_ColorMap", tex_ml);
//    cube.setMaterial(mat_stl);
//    rootNode.attachChild(cube);
    /** A cube with base color "leaking" through a partially transparent texture */
    Box boxshape4 = new Box(new Vector3f(3f,-1f,0f), 1f,1f,1f);
    Geometry cube_leak = new Geometry("Leak-through color cube", boxshape4);
    Material mat_tl = new Material(assetManager, "Common/MatDefs/Misc/ColoredTextured.j3md");
    mat_tl.setTexture("m_ColorMap", assetManager.loadTexture("Textures/ColoredTex/Monkey.png"));
    mat_tl.setColor("m_Color", new ColorRGBA(1f,0f,1f, 1f)); // purple
    /** A bumpy rock with a shiny light effect */
    Sphere rock = new Sphere(32,32, 2f);
    Geometry shiny_rock = new Geometry("Shiny rock", rock);
    rock.setTextureMode(Sphere.TextureMode.Projected); // better quality on spheres
    TangentBinormalGenerator.generate(rock);           // for lighting effect
    Material mat_lit = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat_lit.setTexture("m_DiffuseMap", assetManager.loadTexture("Textures/Terrain/Pond/Pond.png"));
    mat_lit.setTexture("m_NormalMap", assetManager.loadTexture("Textures/Terrain/Pond/Pond_normal.png"));
    mat_lit.setFloat("m_Shininess", 5f); // [0,128]
    shiny_rock.setLocalTranslation(0,2,-2); // Move it a bit
    shiny_rock.rotate(1.6f, 0, 0);          // Rotate it a bit

    /** A translucent/transparent texture, similar to a window frame. */
    Box boxshape3 = new Box(new Vector3f(0f,0f,0f), 1f,1f,0.01f);
    Geometry window_frame = new Geometry("window frame", boxshape3);
    Material mat_tt = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
    mat_tt.setTexture("m_ColorMap", assetManager.loadTexture("Textures/ColoredTex/Monkey.png"));

    /** Must add a light to make the lit object visible! */
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(1,0,-2).normalizeLocal());

Make sure to call "setQueueBucket(Bucket.Transparent)" on all transparent objects, otherwise they will be sorted incorrectly.

I didn't even think of setting the rendering bucket. For some reason after reading the tutorial I figured there was some sort of monkey magic going on in there to save me the trouble and I just forgot everything about it!  :smiley:

Ah well, thanks Momoko. Think there should be something added to that tutorial about rendering buckets? Or maybe another tutorial entirely? Just a thought.

Thanks again!

Is it possible maybe to render some object transparent only on color basis without transparent texture (set color alpha to smth)?

InShadow said:

Is it possible maybe to render some object transparent only on color basis without transparent texture (set color alpha to smth)?

You can do that with a shader.

Hello! I have a problem with this example. I need a shiny light effect on a sphere, but after trying the example from the documentation, my rock is not shiny at all, and I don’t know why, I copy-pasted the code in my application. You can see in my screen shot that the rock is not shiny. I use an ATI RADEON 5470, but I tested the example also on another VGA . Cand someone tell me why is this happening? In the first screen-shot is what I get in jme frame: '>

I wonder what this has to do with this thread?

A bunch of people that might otherwise be able to help probably won’t even both looking into a one and a half year old thread about a completely different topic.

The person who wrote the initial post said that he also had a problem with that example, that was the link between what he wrote and what I wrote. Let’s say I made a mistake, but why you bother posting to my post, if you can’t help? I appreciate if you could help.

Sorry. I won’t bother posting next time.

Post wherever you want. :frowning:

Though if you do decide to create a topic specifically for your issue…

Please include which version of JME you are running and any code that you’ve changed. The issues in a 1.5 year old thread are no longer relevant unless you are also running 1.5 year old JME. In which case, that’s the problem :wink: