Jump to content
  • Advertisement
Sign in to follow this  
jyk

Strange texcoord scroll problem

This topic is 5068 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, I have a strange problem with texture coordinate scrolling. I'm trying to implement simple scrolling as a function of time, like this: glMatrixMode(GL_TEXTURE); glPushMatrix(); glTranslatef(scroll[0] * time, scroll[1] * time, 0.0f); Now if I normalize time first, like this: time -= (int)time; It works fine. But if I leave time unnormalized (i.e. any arbitrary value), I get strange tearing and jittering artifacts - the texture shakes back and forth as it scrolls, and tears at the triangle edges. Very weird. I've studied several other engines that incorporate texture scrolling, and most of them do not normalize the time. So I guess I must be doing something else wrong? I imagine quite a few of you have implemented this sort of texture scrolling as part of a Q3-style shader system. Has anyone else encountered this problem?

Share this post


Link to post
Share on other sites
Advertisement
I had a similar problem with texture jittering. The reason could be is the following:

The time function I know measures the seconds elapsed since 1970 or so, so it's usually a very very large number. The texture coordinates on the GPU are only stored in single precision and only the fractional part of the texture coordinate is important for texturing (I assume you have GL_REPEAT enabled). But the integer part of time is a very large number, so the fractional part does not have enough precision to be properly resolved. Even if your "time" is double, it gets converted to float by glTranslatef and the precision problem arises.

If time is e.g. 1000000.25, the next machine number greater or equal to time might be 1000000.30, so your texture coordinates would scroll in 0.05 steps, which is much too much for smooth scrolling.

Normalizing time is completely feasible I guess.

Share this post


Link to post
Share on other sites
Thanks for the very helpful reply! I was under the impression that on my system (Mac), time is measured in microseconds since machine startup, but I should double check that.

In any case, precision issues could definitely be to blame. Most of the other Q3-based engines I've looked at don't normalize the time, though. And normalizing the time does seem to cause problems with some combinations of scrolling and turbulence (the texture 'jumps' occasionally). I guess I'll just have to keep messing with it.

Thanks.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!