Rendering error between two meshes

View previous topic View next topic Go down

Rendering error between two meshes

Post  waterbuffalo99 on Mon Aug 24, 2009 7:35 pm

Hi,

I'm seeing rendering errors at the edges between two objects. I believe it only happens or at least its worse where the meshes actually intersect. In this case its a sky dome and a plane.

Also note that it is much worse on the phone (iPhone 3G). Instead of mostly just a jagged edges the layer between the plane and sky that is black is a significantly larger area.

What could cause this? Here's a screenshot from the simulator:


waterbuffalo99

Posts : 36
Join date : 2009-06-03

View user profile

Back to top Go down

Re: Rendering error between two meshes

Post  sio2interactive on Mon Aug 24, 2009 8:07 pm

1. Make sure that the zNear, zFar have acceptable values, I personally recommend something like:

zNear: 1.0
zFar: 500.0

2. Make sure that the field of view is not too narrow or too wide, I personally recommend:

FOV: 45
or
FOV: 65

3. Avoid overlapping triangles, that will cause some zFigthing...

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

zNear and zFar

Post  waterbuffalo99 on Tue Aug 25, 2009 12:04 pm

Thanks. I found _SIO2camera cend and cstart were 8000 and 0.1 and changed cstart to 1.0. I was experimenting with a large plane (the diagonal is about 8000) and this is the only evidence that might be too big. Didn't recall changing cstart to 0.1 but there it was.

The problem went away in the simulator but is not completely gone on the device. I can probably live with it but I probably won't stick with such a large plane.

waterbuffalo99

Posts : 36
Join date : 2009-06-03

View user profile

Back to top Go down

Re: Rendering error between two meshes

Post  glDisable on Tue Aug 25, 2009 12:22 pm

If I see it right you're having some water there and it's fighting in the Z-buffer with the terrain. Try this:

Code:
    Render Terrain;

   glEnable(GL_POLYGON_OFFSET_FILL);
   glPolygonOffset(-1.f, -2.f);

   Render Water;

   glDisable(GL_POLYGON_OFFSET_FILL);

Also try different values for glPolygonOffset. See the man page. Smile

glDisable

Posts : 3
Join date : 2009-03-11

View user profile

Back to top Go down

Larger zNear / cstart value of 4.0

Post  waterbuffalo99 on Tue Aug 25, 2009 12:29 pm

I tried a larger value of for cstart of 4.0 and the problem is completely gone in the simulator and on the phone. Just from observing this so far it seems to be a good solution.

Given that its a 3rd person camera situation, do you see any downside of having a value of 4.0 for cstart?

-George

waterbuffalo99

Posts : 36
Join date : 2009-06-03

View user profile

Back to top Go down

Re: Rendering error between two meshes

Post  sio2interactive on Tue Aug 25, 2009 4:39 pm

You can always increase the precision of the depth buffer by default its set to 16bits but you can change it to 24 with:

glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);

to

glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT24_OES, backingWidth, backingHeight);

And try to don't use polygon offset... there's no need to use it for this kind of scenario...

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

precision problem

Post  waterbuffalo99 on Tue Aug 25, 2009 9:17 pm

I see how this is a precision problem so adjusting zNear helps but may not be good enough in some cases.

I'll try the depth buffer 24 bit solution with the original zNear of 0.1 and also with 1.0 and see what the difference is, and I'm also curious whether it will affect performance.

... thanks

waterbuffalo99

Posts : 36
Join date : 2009-06-03

View user profile

Back to top Go down

Re: Rendering error between two meshes

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum