Author Topic: Problem loading textures  (Read 1483 times)

Offline sidneibjunior

  • byte
  • *
  • Posts: 6
    • View Profile
Problem loading textures
« on: January 06, 2014, 03:51:59 pm »
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:

Code: [Select]
Texture texture = new Texture(inputStream);
TextureManager.getInstance().addTexture(txtName, texture);

[attachment deleted by admin]

Offline Lobby

  • int
  • **
  • Posts: 66
    • View Profile
    • flowersoft
Re: Problem loading textures
« Reply #1 on: January 06, 2014, 04:25:39 pm »
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).

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Problem loading textures
« Reply #2 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?

Offline sidneibjunior

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Problem loading textures
« Reply #3 on: January 06, 2014, 04:32:24 pm »
My device is Sony Xperia Live with walkman

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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Problem loading textures
« Reply #4 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...

Code: [Select]
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).


Offline sidneibjunior

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Problem loading textures
« Reply #5 on: January 06, 2014, 10:41:00 pm »
Unfortunately your solution didn't work.
I'll try the Lobby's approach.

Thank you

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...


Code: [Select]
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).

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Problem loading textures
« Reply #6 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.

Offline sidneibjunior

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Problem loading textures
« Reply #7 on: January 14, 2014, 05:28:16 pm »
I mean I still have the effect shown in the images.

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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Problem loading textures
« Reply #8 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...

Offline sidneibjunior

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Problem loading textures
« Reply #9 on: January 14, 2014, 06:04:34 pm »
You can download it from here: https://www.dropbox.com/s/wwqnbnp5lv180cx/2.zip

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...

Offline sidneibjunior

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Problem loading textures
« Reply #10 on: January 18, 2014, 06:51:58 pm »
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!


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...

Code: [Select]
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).