Model not rendering properly, might be related to depth buffer?

I can’t get my model to render properly on Android. Here’s what it should look like (screenshot from desktop):

And here’s what it looks like on Android:

As you can see entire parts of the model aren’t rendered at all and there’s some problem with the top/bottom borders (ignore the shadows, those are part of the texture and were added later). I was able to get the same result on desktop if I disable depth tests, so I guess the problem on Android is somehow related to those. I thought the problem might be the world size so I tried around with that, but neither scaling my model to a size smaller 1 nor bigger 100 changed anything. Any ideas?

could you please try what I explain in this post ?
http://hub.jmonkeyengine.org/forum/topic/some-scene-objects-not-visible/#post-207101

It could be a pixel configuration issue.

1 Like
@nehon said: could you please try what I explain in this post ? http://hub.jmonkeyengine.org/forum/topic/some-scene-objects-not-visible/#post-207101 .

Unfortunately I somehow can’t seem to get any detailed log. I added Logger.getLogger(AndroidConfigChooser.class.getName()).setLevel(Level.FINE); into the constructor of MainActivity, but all I ever get is:
I/AndroidConfigChooser(11035): JME3 using choosen config:
I/AndroidConfigChooser(11035): EGL_RED_SIZE = 5
I/AndroidConfigChooser(11035): EGL_GREEN_SIZE = 6
I/AndroidConfigChooser(11035): EGL_BLUE_SIZE = 5
I/AndroidConfigChooser(11035): EGL_ALPHA_SIZE = 0
I/AndroidConfigChooser(11035): EGL_DEPTH_SIZE = 0
I/AndroidConfigChooser(11035): EGL_STENCIL_SIZE = 0
I/AndroidConfigChooser(11035): EGL_RENDERABLE_TYPE = 7
I/AndroidConfigChooser(11035): EGL_SURFACE_TYPE = 1415
I/AndroidConfigChooser(11035): EGL_SAMPLE_BUFFERS = 0
I/AndroidConfigChooser(11035): EGL_SAMPLES = 0

configType LEGACY gives me a working config, but there’s no output what that one looks like.

this one is enough.
Somehow the pixel configuration chosen has a 0 bit depth buffer. So this is clearly your issue.
Something is flawed in the choosing algorithm, but i can’t get what without a good example :smiley:
What is your device hardware?
And oh…do you use nightly? or RC2?

1 Like

I use a ZTE Blade and the latest nightly (just updated before my last post).

ok, so I really need the stack trace I was asking before.
The thing is I could fall back to legacy in that case, but you surely have a better conf, and legacy is really poor (that’s why you have those very ugly banding for example)
The trace should display all the configurations, did you try going to the adb log cat view and enabling debug output?

Hi I have the same issue now.

I am rendering a quad plane and a box. On PC, I see both, but on android I only see the box. The quad that is not showing up is a custom mesh.

My I/AndroindConfigChooser lists:

I/OGLESContext(20483): INFO OGLESContext 22:56:49 Display EGL Version: 1.0
I/com.jme3.system.android.OGLESContext(20483): Display EGL Version: {0}.{1}
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 JME3 using choosen config: 
I/com.jme3.system.android.AndroidConfigChooser(20483): JME3 using choosen config: 
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_RED_SIZE  = 8
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_RED_SIZE  = 8
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_GREEN_SIZE  = 8
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_GREEN_SIZE  = 8
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_BLUE_SIZE  = 8
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_BLUE_SIZE  = 8
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_ALPHA_SIZE  = 0
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_ALPHA_SIZE  = 0
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_DEPTH_SIZE  = 24
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_DEPTH_SIZE  = 24
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_STENCIL_SIZE  = 8
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_STENCIL_SIZE  = 8
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_RENDERABLE_TYPE  = 7
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_RENDERABLE_TYPE  = 7
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_SURFACE_TYPE  = 1413
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_SURFACE_TYPE  = 1413
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_SAMPLE_BUFFERS  = 0
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_SAMPLE_BUFFERS  = 0
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_SAMPLES  = 0
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_SAMPLES  = 0
D/dalvikvm(20483): GC_CONCURRENT freed 311K, 4% free 8770K/9108K, paused 3ms+4ms, total 22ms
I/Adreno200-EGL(20483): : EGL 1.4 QUALCOMM build: Nondeterministic AU_full_mako_PARTNER-ANDROID/JB-MR1-DEV_CL2961380_release_AU (CL2961380)
I/Adreno200-EGL(20483): Build Date: 12/10/12 Mon
I/Adreno200-EGL(20483): Local Branch: 
I/Adreno200-EGL(20483): Remote Branch: m/partner-android/jb-mr1-dev
I/Adreno200-EGL(20483): Local Patches: NONE
I/Adreno200-EGL(20483): Reconstruct Branch: NOTHING
I/OGLESContext(20483): INFO OGLESContext 22:56:49 Display EGL Version: 1.0
I/com.jme3.system.android.OGLESContext(20483): Display EGL Version: {0}.{1}
I/com.jme3.system.android.OGLESContext(20483): Display EGL Version: {0}.{1}
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 JME3 using choosen config: 
I/com.jme3.system.android.AndroidConfigChooser(20483): JME3 using choosen config: 
I/com.jme3.system.android.AndroidConfigChooser(20483): JME3 using choosen config: 
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_RED_SIZE  = 8
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_RED_SIZE  = 8
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_RED_SIZE  = 8
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_GREEN_SIZE  = 8
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_GREEN_SIZE  = 8
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_GREEN_SIZE  = 8
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_BLUE_SIZE  = 8
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_BLUE_SIZE  = 8
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_BLUE_SIZE  = 8
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_ALPHA_SIZE  = 0
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_ALPHA_SIZE  = 0
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_ALPHA_SIZE  = 0
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_DEPTH_SIZE  = 24
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_DEPTH_SIZE  = 24
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_DEPTH_SIZE  = 24
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_STENCIL_SIZE  = 8
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_STENCIL_SIZE  = 8
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_STENCIL_SIZE  = 8
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_RENDERABLE_TYPE  = 7
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_RENDERABLE_TYPE  = 7
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_RENDERABLE_TYPE  = 7
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_SURFACE_TYPE  = 1413
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_SURFACE_TYPE  = 1413
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_SURFACE_TYPE  = 1413
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_SAMPLE_BUFFERS  = 0
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_SAMPLE_BUFFERS  = 0
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_SAMPLE_BUFFERS  = 0
I/AndroidConfigChooser(20483): INFO AndroidConfigChooser 22:56:49 EGL_SAMPLES  = 0
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_SAMPLES  = 0
I/com.jme3.system.android.AndroidConfigChooser(20483): EGL_SAMPLES  = 0

Full java code:

[java]public class Main extends SimpleApplication {

private Geometry box;    

public Main(){
}

public static void main(String[] args) {
    Main app = new Main();
    app.start();
}

@Override
public void simpleInitApp() {
    
    Box b = new Box(Vector3f.ZERO, 1, 1, 1);
    box = new Geometry("Box", b);

    Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat.setBoolean("UseMaterialColors", true);
    mat.setColor("Ambient",  ColorRGBA.Orange);
    mat.setColor("Diffuse",  ColorRGBA.Orange);
    mat.setColor("Specular", ColorRGBA.White);
    mat.setFloat("Shininess", 12);
    box.setMaterial(mat);

    rootNode.attachChild(box);
    
    DirectionalLight sun = new DirectionalLight();
    sun.setColor(ColorRGBA.White);
    sun.setDirection(new Vector3f(-.1f,-.2f,-.5f).normalizeLocal());
    rootNode.addLight(sun);        
    
    PointLight lamp_light = new PointLight();
    lamp_light.setColor(ColorRGBA.Yellow);
    lamp_light.setRadius(4f);
    lamp_light.setPosition(new Vector3f( -1, -1, -1 ));
    rootNode.addLight(lamp_light);        

    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(0.3f));
    rootNode.addLight(al);

    this.getCamera().setLocation( new Vector3f( 0, 8, 0 ) );
    this.getCamera().lookAt( Vector3f.ZERO, Vector3f.UNIT_Z );
    
    Geometry floor = this.createGrid( 6, 12 );
    this.getRootNode().attachChild( floor );
}

private Geometry createGrid( float width, float height ){
    
    float halfWidth = width / 2f;
    float halfHeight = height / 2f;
    
    Vector3f[] vertices = new Vector3f[ 4 ];
    vertices[ 0 ] = new Vector3f( -halfWidth, 0, -halfHeight );
    vertices[ 1 ] = new Vector3f( -halfWidth, 0,  halfHeight );
    vertices[ 2 ] = new Vector3f(  halfWidth, 0, -halfHeight );
    vertices[ 3 ] = new Vector3f(  halfWidth, 0,  halfHeight );

    Vector3f[] normals = new Vector3f[ 4 ];
    normals[ 0 ] = new Vector3f( 0, 1, 0 );
    normals[ 1 ] = normals[ 0 ];
    normals[ 2 ] = normals[ 0 ];
    normals[ 3 ] = normals[ 0 ];
    
    
    Vector2f[] texCoord = new Vector2f[ 4 ];
    texCoord[ 0 ] = new Vector2f( 0, 0 );
    texCoord[ 1 ] = new Vector2f( 0, 1 );
    texCoord[ 2 ] = new Vector2f( 1, 0 );
    texCoord[ 3 ] = new Vector2f( 1, 1 );        
    
    short [] indexes = { 2, 0, 1, 1, 3, 2 };        
    
    Mesh mesh = new Mesh();
    mesh.setBuffer( Type.Position, 3, BufferUtils.createFloatBuffer( vertices ) );
    mesh.setBuffer( Type.Normal, 3, BufferUtils.createFloatBuffer( normals ) );
    mesh.setBuffer( Type.TexCoord, 2, BufferUtils.createFloatBuffer( texCoord ) );
    mesh.setBuffer( Type.Index,    3, BufferUtils.createShortBuffer( indexes ) );
    mesh.updateBound();
    
    Geometry geo = new Geometry( "Grid", mesh );
    
    Texture t = assetManager.loadTexture( "Textures/Grid6x12.png" );
    t.setMagFilter( Texture.MagFilter.Nearest );
    Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");

// mat.setBoolean(“UseMaterialColors”, true);
mat.setColor( “Ambient”, ColorRGBA.Orange );
mat.setColor( “Diffuse”, ColorRGBA.Orange );
mat.setColor( “Specular”, ColorRGBA.White );
mat.setFloat( “Shininess”, 12 );
mat.setTexture( “DiffuseMap”, t );
geo.setMaterial( mat );

    return geo;
}

float time = 0f;

@Override
public void simpleUpdate(float tpf) {
    time += tpf;
    if( time > FastMath.TWO_PI ){
        time = 0f;
    }
    this.getCamera().setLocation( new Vector3f( 0, FastMath.cos( time ) * 3f  + 8f , 0 ) );
    this.box.setLocalTranslation( FastMath.sin( time ), 0, FastMath.cos( time ) );
}

}
[/java]

On Nexus 4, using nightly ( pretty sure it is nightly this time… :stuck_out_tongue: ).

Hmmm… Does [java] *** [/java] not work?

Note, I tried various hacks to get the quad to render. What did it in the end was removing the texture from the material…

Nope, it doesn’t seem to list all configurations, it just repeats the same thing 3 times (could this be the reason why the picking doesn’t work)? Here’s my entire LogCat output, filtered by AndroidConfigChooser, set to verbose:

00:44:27.262 12052 INFO AndroidConfigChooser JME3 using choosen config:
00:44:27.262 12052 INFO AndroidConfigChooser EGL_RED_SIZE = 5
00:44:27.262 12052 INFO AndroidConfigChooser EGL_GREEN_SIZE = 6
00:44:27.262 12052 INFO AndroidConfigChooser EGL_BLUE_SIZE = 5
00:44:27.262 12052 INFO AndroidConfigChooser EGL_ALPHA_SIZE = 0
00:44:27.262 12052 INFO AndroidConfigChooser EGL_DEPTH_SIZE = 0
00:44:27.262 12052 INFO AndroidConfigChooser EGL_STENCIL_SIZE = 0
00:44:27.262 12052 INFO AndroidConfigChooser EGL_RENDERABLE_TYPE = 7
00:44:27.262 12052 INFO AndroidConfigChooser EGL_SURFACE_TYPE = 1415
00:44:27.262 12052 INFO AndroidConfigChooser EGL_SAMPLE_BUFFERS = 0
00:44:27.262 12052 INFO AndroidConfigChooser EGL_SAMPLES = 0
00:44:27.312 12052 INFO AndroidConfigChooser JME3 using choosen config:
00:44:27.312 12052 INFO AndroidConfigChooser EGL_RED_SIZE = 5
00:44:27.312 12052 INFO AndroidConfigChooser EGL_GREEN_SIZE = 6
00:44:27.312 12052 INFO AndroidConfigChooser EGL_BLUE_SIZE = 5
00:44:27.312 12052 INFO AndroidConfigChooser EGL_ALPHA_SIZE = 0
00:44:27.312 12052 INFO AndroidConfigChooser EGL_DEPTH_SIZE = 0
00:44:27.312 12052 INFO AndroidConfigChooser EGL_STENCIL_SIZE = 0
00:44:27.312 12052 INFO AndroidConfigChooser EGL_RENDERABLE_TYPE = 7
00:44:27.312 12052 INFO AndroidConfigChooser EGL_SURFACE_TYPE = 1415
00:44:27.312 12052 INFO AndroidConfigChooser EGL_SAMPLE_BUFFERS = 0
00:44:27.312 12052 INFO AndroidConfigChooser EGL_SAMPLES = 0
00:44:27.402 12052 INFO AndroidConfigChooser EGL_RED_SIZE = 5
00:44:27.402 12052 INFO AndroidConfigChooser EGL_GREEN_SIZE = 6
00:44:27.402 12052 INFO AndroidConfigChooser EGL_BLUE_SIZE = 5
00:44:27.402 12052 INFO AndroidConfigChooser EGL_ALPHA_SIZE = 0
00:44:27.402 12052 INFO AndroidConfigChooser EGL_DEPTH_SIZE = 0
00:44:27.402 12052 INFO AndroidConfigChooser EGL_STENCIL_SIZE = 0
00:44:27.402 12052 INFO AndroidConfigChooser EGL_RENDERABLE_TYPE = 7
00:44:27.402 12052 INFO AndroidConfigChooser EGL_SURFACE_TYPE = 1415
00:44:27.402 12052 INFO AndroidConfigChooser EGL_SAMPLE_BUFFERS = 0
00:44:27.402 12052 INFO AndroidConfigChooser EGL_SAMPLES = 0

And just to make sure I didn’t do anything wrong there, here’s the constructor of my main activity:
[java]public MainActivity(){
Logger.getLogger(AndroidConfigChooser.class.getName()).setLevel(Level.FINE);
// Set the application class to run
appClass = “laby.Main”;
// Try ConfigType.FASTEST; or ConfigType.LEGACY if you have problems
eglConfigType = ConfigType.BEST;
// Exit Dialog title & message
exitDialogTitle = “Exit?”;
exitDialogMessage = “Press Yes”;
// Enable verbose logging
//eglConfigVerboseLogging = true;
// Choose screen orientation
screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
// Invert the MouseEvents X (default = true)
mouseEventsInvertX = true;
// Invert the MouseEvents Y (default = true)
mouseEventsInvertY = true;
}[/java]

@nihal said: Note, I tried various hacks to get the quad to render. What did it in the end was removing the texture from the material...

You might also want to try setting eglConfigType = ConfigType.LEGACY; in your MainActivity constructor. As nehon mentions in his earlier post this is no good final solution, but if it works you can at least keep developing your app like that and change it back later once a proper solution has been found.

@nihal that’s not the same issue, you have a 24 bit depth buffer that is plenty enough

@Sebioff your mainActivity is ok…i don’t get why it doesn’t work. Sure you have the latest latest nightly? make sure the jars in your mobile/lib folder are the good ones.

Anything specific I can check to see if they are the good ones? I checked out jME from SVN; the jars in there have a timestamp from yesterday morning and the ones in my mobile/lib folder have the exact same size.

@nehon: I built the jars myself from the sources in the meantime, now I get the detailed log…apparently the jars in SVN are outdated?
Here’s the log.
Also, I tested on a Samsung Galaxy S II in the meantime; it picks a working config there.

1 Like

Thanks, it’s gonna be very useful, I’ll keep you updated

I’ve just committed a fix in last svn.
@Sebioff Could you try it?

@nihal about your issue, did you try deactivating Texture compression?

1 Like

@nehon: looking good!
W/com.jme3.system.android.AndroidConfigChooser( 3015): WARNING Failed to find a suitable display configuration for BEST, attempting BEST_TRANSLUCENT
I/com.jme3.system.android.AndroidConfigChooser( 3015): INFO JME3 using choosen config:
I/com.jme3.system.android.AndroidConfigChooser( 3015): INFO EGL_RED_SIZE = 8
I/com.jme3.system.android.AndroidConfigChooser( 3015): INFO EGL_GREEN_SIZE = 8
I/com.jme3.system.android.AndroidConfigChooser( 3015): INFO EGL_BLUE_SIZE = 8
I/com.jme3.system.android.AndroidConfigChooser( 3015): INFO EGL_ALPHA_SIZE = 8
I/com.jme3.system.android.AndroidConfigChooser( 3015): INFO EGL_DEPTH_SIZE = 24
I/com.jme3.system.android.AndroidConfigChooser( 3015): INFO EGL_STENCIL_SIZE = 8
I/com.jme3.system.android.AndroidConfigChooser( 3015): INFO EGL_RENDERABLE_TYPE = 7
I/com.jme3.system.android.AndroidConfigChooser( 3015): INFO EGL_SURFACE_TYPE = 1511
I/com.jme3.system.android.AndroidConfigChooser( 3015): INFO EGL_SAMPLE_BUFFERS = 0
I/com.jme3.system.android.AndroidConfigChooser( 3015): INFO EGL_SAMPLES = 0

Thanks!

Good!
So the problem is that your device doesn’t have an opaque configuration with 8 bit r,g,b channels, but it has a translucent one (with a 8 bit alpha channel).
The problem is translucent display configurations bring some overhead, and it’s slower. but in that particular case i guess that’s better that the awful banding you have with rgb565.

@nehon said: I've just committed a fix in last svn. @Sebioff Could you try it?

@nihal about your issue, did you try deactivating Texture compression?

No, I havent tried that. I opened another topic for it, And wesrule suggested trying a power of 2 texture, which solved the issue. I was using a 6x12 texture. I have not seen any errors for non-power of two textures not being supported though, so I just assumed it was not an issue.

I might try deactivating texture compression, I guess that is done through the Texture class?

@nihal said: No, I havent tried that. I opened another topic for it, And wesrule suggested trying a power of 2 texture, which solved the issue. I was using a 6x12 texture. I have not seen any errors for non-power of two textures not being supported though, so I just assumed it was not an issue.

I might try deactivating texture compression, I guess that is done through the Texture class?

That’s strange, non power of 2 textures are automatically resized to power of 2 if needed by the engine…
to disable compression use TextureUtil.ENABLE_COMPRESSION = false; in your activity constructor.

@nehon said: That's strange, non power of 2 textures are automatically resized to power of 2 if needed by the engine... to disable compression use TextureUtil.ENABLE_COMPRESSION = false; in your activity constructor.

Well it may have been resized. What actually happened was that the texture had “turned black” after import or on render, and since it was rendering against a black background, I thought it was simply not rendering. Turns out it was rendering, it was just rendering black. I suspect the issue is produced on import, since generated textures did not have the same issue, even if they were 6x12.

I think I can revert my code and reproduce the issue, if you are interested in a test-case.

Also: This is the thread I opened for the issue: http://hub.jmonkeyengine.org/forum/topic/loaded-texture-rendering-black/

I think I can confirm that there’s a very strange problem with textures and it seems pretty random. Take a look at this:

Two screenshots from my game. On the left, the texture beneath the ball is called test2.png. On the right, the texture is called grid_normal.png. Apart from that, it is the exact same texture (and game code) on both sides - I just made a copy of grid_normal.png in Windows-Explorer and renamed it to test2.png.
Btw, this is running on my PC, so I guess since it’s not Android-related and not really related to this topic I’ll open a new one.

EDIT: Opened a new topic