Problem loading textures

Started by sidneibjunior, January 06, 2014, 03:51:59 PM

Previous topic - Next topic

sidneibjunior

HI,

I am working on a Android project and I am using jpct.
I noticed that some textures appear only half full when the object moves away from the camera.
I attached two images showing the object when it is close and far from the camera.

The code I use for loading the textures is the follow:


Texture texture = new Texture(inputStream);
TextureManager.getInstance().addTexture(txtName, texture);


[attachment deleted by admin]

Lobby

The problem isn't the texture but that there are some triangles really close together - such Problems are called z-fighting and are a result of the 16 bit depth buffer (which is not that much).
It should help to set the far clipping plane to a smaller value or make the object bigger. But the best solution is to avoid such triangles in the mesh using a texture that contains such details as different materials (and this should also help to decrease triangle count).

EgonOlsen

It might also be possible to fix this by using a different depth buffer config, but that depends on your device. Which device are you using?

sidneibjunior

My device is Sony Xperia Live with walkman

Quote from: EgonOlsen on January 06, 2014, 04:29:29 PM
It might also be possible to fix this by using a different depth buffer config, but that depends on your device. Which device are you using?

EgonOlsen

Pretty ancient device... ;) It uses an Adreno GPU, which means that it's default depth buffer accuracy sucks. You can improve this by switching to OpenGL ES 2.0 (in case you haven't already) and use another config provided by this ConfigChooser: http://www.jpct.net/jpct-ae/doc/com/threed/jpct/util/NVDepthConfigChooser.html

Like so...


mGLView = new GLSurfaceView(getApplication());

mGLView.setEGLContextClientVersion(2); // Do enable ES 2.0

mGLView.setEGLConfigChooser(new NVDepthConfigChooser(mGLView, false)); // To set the new chooser


Also make sure to use the other constructor for FrameBuffer when using ES 2.0 (the one without the gl context).


sidneibjunior

Unfortunately your solution didn't work.
I'll try the Lobby's approach.

Thank you

Quote from: EgonOlsen on January 06, 2014, 08:30:37 PM
Pretty ancient device... ;) It uses an Adreno GPU, which means that it's default depth buffer accuracy sucks. You can improve this by switching to OpenGL ES 2.0 (in case you haven't already) and use another config provided by this ConfigChooser: http://www.jpct.net/jpct-ae/doc/com/threed/jpct/util/NVDepthConfigChooser.html

Like so...



mGLView = new GLSurfaceView(getApplication());

mGLView.setEGLContextClientVersion(2); // Do enable ES 2.0

mGLView.setEGLConfigChooser(new NVDepthConfigChooser(mGLView, false)); // To set the new chooser


Also make sure to use the other constructor for FrameBuffer when using ES 2.0 (the one without the gl context).

EgonOlsen

What exactly does 'doesn't work' mean in this context? The solution itself works fine, because that's what i'm using personally all the time.

sidneibjunior

I mean I still have the effect shown in the images.

Quote from: EgonOlsen on January 07, 2014, 07:21:19 AM
What exactly does 'doesn't work' mean in this context? The solution itself works fine, because that's what i'm using personally all the time.

EgonOlsen

Might be that the polygons are just too close then to be rendered correctly in all cases on a mobile GPU. Mobile GPUs suffer from low accuracy. If you can provide a download link to this model, i can have a look...

sidneibjunior

You can download it from here: https://www.dropbox.com/s/wwqnbnp5lv180cx/2.zip

Quote from: EgonOlsen on January 14, 2014, 06:01:23 PM
Might be that the polygons are just too close then to be rendered correctly in all cases on a mobile GPU. Mobile GPUs suffer from low accuracy. If you can provide a download link to this model, i can have a look...

sidneibjunior

I was using some beta version when I had the Z fighting problem.
Now I downloaded a new version of jpct jar and the solution using the NVDepthConfigChooser works fine.

Thanks a lot!


Quote from: EgonOlsen on January 06, 2014, 08:30:37 PM
Pretty ancient device... ;) It uses an Adreno GPU, which means that it's default depth buffer accuracy sucks. You can improve this by switching to OpenGL ES 2.0 (in case you haven't already) and use another config provided by this ConfigChooser: http://www.jpct.net/jpct-ae/doc/com/threed/jpct/util/NVDepthConfigChooser.html

Like so...


mGLView = new GLSurfaceView(getApplication());

mGLView.setEGLContextClientVersion(2); // Do enable ES 2.0

mGLView.setEGLConfigChooser(new NVDepthConfigChooser(mGLView, false)); // To set the new chooser


Also make sure to use the other constructor for FrameBuffer when using ES 2.0 (the one without the gl context).