Jump to content
  • Advertisement
Sign in to follow this  
felipedrl

OpenGL I'm clueless about this bug... any idea? ( Added a video! )

This topic is 3293 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 Guys, I'm currently developing a game in OpenGL ES for a video game console released in my country this year. I'm facing a bug which I'm struggling for a couple of days and I'm hoping someone could give me a hint how to solve it. The problem is that, for triangles near the camera, the texture is dancing on it, moving back and forth like there's some imprecision while projecting the triangles in the screen. It can be seen in this video I recorded:
One thing i think it's very relevant to say is that, when I test it on the simulator in my computer it's perfect. The problem only happens in the target platform ( which does not have float, I use fixed point math ). When the camera stops completely ( I have a chase cam ), most of the time the texture stop flickering too. Things I have tried: - Used glHint(GL_PERSPECTIVE_CORRECTION, GL_NICEST ); - Increased the near distance to avoid zbuffer imprecision ( I only have a 16bit zbuffer prec. ) - Converted all my modelview/projection matrix calculations/setup to float. - Turned off mipmaps. - Turned off multitexture. - Converted my vertice coords and uv data to float. I have no idea what to try next. I still don't know if it's a texture or vertice problem. Anyone have any idea? Thanks in advance. [Edited by - felipedrl on September 13, 2009 4:35:35 PM]

Share this post


Link to post
Share on other sites
Advertisement
This might have something to do with poor hardware clipping. Can we know a bit more about your "device"? Does the effect look like first person shooters on the PS1 (like the first medal of honor) where walls too near to you simply seemed to "move"? I worked on a PSP shooter, and we had the same problem, and had to implement a software clipping.

Share this post


Link to post
Share on other sites
Dunge,

It seems exactly like that. The only difference is that I have a race game. When the car is slow the textures move back and forth ( unlikely medal of honor that it moves only once ). I´ve implemented a clipping that will not let any triangle for opengl to clip. ( I set the GL frustum a little bit bigger than the actual "software frustum" so opengl will not scissor any triangle ). However, the hardware clipping algorithm is still being called since it's fixed function pipeline. Is there a way to turn it off? Does it make any difference the size of triangle, or if the triangle data is in short instead of fixed point?

Actually the hardware is a video game console that works under BREW, and not a mobile as I stated earlier. The one thing that makes me frustrated is that there are other games ( including FPS ) for that hardware in which that doesn't happen.

Any insights on how to solve this would be awesome.
Thanks in advance.

[Edited by - felipedrl on September 13, 2009 4:30:00 PM]

Share this post


Link to post
Share on other sites
I just edited the first post to add a video of the bug. Now it should be more clear what's happening. Hope any of you guys could help me out, we're near the deadline and I still can't figure out how to solve that.


Thanks in advance.

Share this post


Link to post
Share on other sites
Hmm crazy...

are you sure it's the texture coordinates screwing up and not the vert positions?

Does OpenGL ES support shaders? If so are you using shaders which may be somehow tweaking the coordinates?

It looks weird like, maybe something is being cast to an int which should remain a float perhaps?

Sorry im grasping at straws but hoping maybe it'll help bring some fresh ideas about whats going on

Share this post


Link to post
Share on other sites
Quote:
are you sure it's the texture coordinates screwing up and not the vert positions?


I'm not sure. All I can say is that it happens not only in the triangle edges. At some places I can see there's stipes moving along the same triangle. I guess I'll have to render it wireframed to be sure, but it will take some work since opengl ES 1.1 does not have glPolygonMode().

Quote:
Does OpenGL ES support shaders? If so are you using shaders which may be somehow tweaking the coordinates?


I'm not sure but I think opengl es 2.0 support shaders but the hardware I'm writing to only support opengl es up to 1.1

Quote:
It looks weird like, maybe something is being cast to an int which should remain a float perhaps?


Initially I thought it was a fixed point rounding precision, but I converted all the opengl matrixes calls to float. The problem happens when I call the lookAt method of my camera which builds a modelview matrix. I removed all intermediary calculation and set the camera position to the player position, camera up to world up and some fixed target and I still have the same issue. If I do not call the camera update it doesnt happen as you can see in the vid when I stop moving.

Quote:
My guess would be that it's not doing perspective correction on triangles that clip through the z-plane.


I'm not sure if I understood it. How can I check that?


Thank you all.

Share this post


Link to post
Share on other sites
It looks like old-style linear texture mapping (basically what Rubicon said). As though the z coordinate is being discarded after clipping and before the texture is applied. The texture is no longer perspective corrected and is sliding along the surface. Either that or the hardware clipper is screwing up the texture coordinates.

Share this post


Link to post
Share on other sites
Well, I have no idea how to solve that. I guess I'll try to scale the world as a last try in case the hardware clipper as you said is screwing up with a small scale.

Thanks for the insights.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!