Sign in to follow this  

What's causing this texture problem ?

This topic is 2853 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone, I try to render a model in OpenGL ( ES) . When I don't scale the model , it looks fine as it shows here : http://www.flickr.com/photos/47753924@N03/4379225898/ But when I scaled it 10 times ( glScalef( 10.0f, 10.0f, 10.0f ) ) , it looks weird : http://www.flickr.com/photos/47753924@N03/4379226066/in/photostream/ I don't know what's causing this ? Any help would be appreciated . P/S: Here is what I use for glFrustrum : const GLfloat zNear = 0.1, zFar = 1000000.0, fieldOfView = 60.0; GLfloat size = zNear * tanf(fieldOfView / 180.0f * MATH3D_PI / 2.0); CGRect rect = CGRectMake(0, 0, 320, 480); glFrustumf(-size, size, -size / (rect.size.width / rect.size.height), size / (rect.size.width / rect.size.height), zNear, zFar); and for the texture , I used GL_LINEAR for MIN_FILTER and MAG_FILTER .

Share this post


Link to post
Share on other sites
The problem looks like z-clipping.

It may be caused by the fact that your near/far ratio is huge. This causes the depth resolution to be very poor, because the depth buffer has a finite number of bits per pixel that need to be divided across that range. In addition, the precision of floating-point numbers at scales of 1000000 is also poor.

To fix this, try to move the near plane as far as possible, and use smaller scales altogether. If you absolutely need a huge depth range (I doubt it), you can render the scene in multiple passes (slices) which have different depth ranges.

It may also be that the model scaled by ten is simply bigger than 1000000 units, causing it to clip as it should.

Share this post


Link to post
Share on other sites
Quote:
Original post by Nik02
The problem looks like z-clipping.

It may be caused by the fact that your near/far ratio is huge. This causes the depth resolution to be very poor, because the depth buffer has a finite number of bits per pixel that need to be divided across that range. In addition, the precision of floating-point numbers at scales of 1000000 is also poor.

To fix this, try to move the near plane as far as possible, and use smaller scales altogether. If you absolutely need a huge depth range (I doubt it), you can render the scene in multiple passes (slices) which have different depth ranges.

It may also be that the model scaled by ten is simply bigger than 1000000 units, causing it to clip as it should.


Thanks ,
Actually I moved the model a bit higher ( glTranslatef(0, -500, 0) instead of glTranslatef(0, -1000, 0); ) , it's rendered correctly. ( quite feel embarrassed because I posted the question without much investigating ). However I still not sure what caused this . I will try both your suggestions to gain deeper understanding.

Share this post


Link to post
Share on other sites

This topic is 2853 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this