Author Topic: weird lines show in texture when camera move  (Read 918 times)

Offline peter

  • byte
  • *
  • Posts: 24
    • View Profile
weird lines show in texture when camera move
« on: March 30, 2016, 09:53:10 pm »
weird lines show in texture when camera zoom out. went away when zoom in. any idea why this happened?
the 3d objects are load from .obj and .mtl file

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: weird lines show in texture when camera move
« Reply #1 on: March 30, 2016, 10:10:38 pm »
Looks strange. It might be z-fighting issue, but it's hard to tell from just a screen shot. Which device are you using?

Offline peter

  • byte
  • *
  • Posts: 24
    • View Profile
Re: weird lines show in texture when camera move
« Reply #2 on: March 30, 2016, 10:13:46 pm »
I am using Samsung Galaxy note 4, android version 5.1.1

Offline peter

  • byte
  • *
  • Posts: 24
    • View Profile
Re: weird lines show in texture when camera move
« Reply #3 on: March 30, 2016, 10:16:18 pm »
if camera is close enough, those lines go away

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: weird lines show in texture when camera move
« Reply #4 on: March 30, 2016, 10:26:04 pm »
What's your render calls looks like (the clear/renderScene/draw sequence)?
You might want to try the NVDepthConfigChooser in the util package to make sure that it's not a depth buffer related issue. You have to use OpenGL ES 2.0 for this to work if you aren't doing this already.
If that doesn't help, can you provide with me a simple test case that shows the problem?

Offline peter

  • byte
  • *
  • Posts: 24
    • View Profile
Re: weird lines show in texture when camera move
« Reply #5 on: March 30, 2016, 10:51:16 pm »
my render calls are almost the same with hello world example
onSurfaceChanged(GL10 gl, int width, int height)
        fb = new FrameBuffer(width, height);
        world = new World();
        world.setAmbientLight(85,85,85);
        world.setClippingPlanes(10,1000);
        world.setObjectsVisibility(true);
        create Lights
        world.addObjects(objects);//objects loads from obj and mtl
        world.getCamera().setPosition(0,0, 800);
        MemoryHelper.compact();

onDrawFrame(GL10 gl)
        fb.clear(background);
        world.renderScene(fb);
        world.draw(fb);
        fb.display();

I will try NVDepthConfigChooser see if that helps.
thank you!!!
« Last Edit: March 30, 2016, 10:54:06 pm by peter »

Offline peter

  • byte
  • *
  • Posts: 24
    • View Profile
Re: weird lines show in texture when camera move
« Reply #6 on: March 30, 2016, 11:16:55 pm »
NVDepthConfigChooser actually fix the problem!!!
thank you very much!!!
so that is a depth buffer related issue?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: weird lines show in texture when camera move
« Reply #7 on: March 31, 2016, 04:08:37 pm »
Yes, somehow. Is there anything behind these textured parts? Like an all white solid body or something similar?

Offline peter

  • byte
  • *
  • Posts: 24
    • View Profile
Re: weird lines show in texture when camera move
« Reply #8 on: March 31, 2016, 04:41:20 pm »
the whole thing is load from obj and mtl, according to what is showing in the screen I guess it happened when there are two objects overlapped.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: weird lines show in texture when camera move
« Reply #9 on: March 31, 2016, 09:39:20 pm »
Most likely. If that can happen in this case, then it's no wonder that there are depth buffer issues. The default depth buffer setting on Adreno GPUs is 16bit, this is quite low. That config chooser tries to increase it if possible. It was first created for nVidia GPUs (hence the name), which have a similar issue, but it works for Adreno as well.

Offline peter

  • byte
  • *
  • Posts: 24
    • View Profile
Re: weird lines show in texture when camera move
« Reply #10 on: April 18, 2016, 10:53:13 pm »
is there a way to increase depth buffer? because those weird line shows after zooming out. NVDepthConfigChooser's depth buffer is not large enough.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: weird lines show in texture when camera move
« Reply #11 on: April 19, 2016, 07:57:26 am »
No, that's it. You can't increase depth buffer precision beyond that. You can try to set a new near clipping plane by doing something like:

Code: [Select]
Config.glIgnoreNearPlane=false;
world.setClippingPlanes(<near > 1, maybe 10>, <far plane>);
world.getCamera().adjustFovToNearPlane();

In theory, this will increase the depth buffer's accuracy, because it spreads on a smaller range. In practice, I've never seen that this helps as much as it would have to to fix such issues. The only real option is to create a model that doesn't suffer from this.
« Last Edit: April 19, 2016, 08:16:29 am by EgonOlsen »

Offline peter

  • byte
  • *
  • Posts: 24
    • View Profile
Re: weird lines show in texture when camera move
« Reply #12 on: June 10, 2016, 03:43:02 pm »
the z-fighting problem could be solve by shrink all vertices by 100 times, so I can move camera distance from 5000 to around 50. don't know why shrink 3D object's vertices effect the z-fighting, I think it has something to do with the camera distance. could this be a bug?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: weird lines show in texture when camera move
« Reply #13 on: June 11, 2016, 09:49:53 am »
No, it's not a bug. It depends on the device's rendering accuracy. Using very large polygons usually isn't a good idea as is using very small ones.