Sign in to follow this  

Clamping and texcoord modulation

This topic is 4859 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

I'm working on a simple Quake 3 style shader system. I have various texture coordinate modulations (rotate and stretch), that transform to the center of uv space, perform the modulation, and transform back, like this: glTranslatef(-0.5f, -0.5f, 0.0f); glScalef(s, s, 1.0f); glTranslatef(0.5f, 0.5f, 0.0f); This works fine, *except* when the texture in question is set to CLAMP or CLAMP_TO_EDGE instead of REPEAT. When the texture is clamped, the texture 'bounces' in the v dimension in addition to stretching. When the texture is not clamped, it works fine, except of course for the unwanted repeating. This is the effect used on i.e. the jumppads in Quake. It obviously works fine there, so I must be doing something wrong. Any ideas? Thanks very much.

Share this post


Link to post
Share on other sites
Your translations are simply done in the wrong direction. When the textures repeat it doesn't matter since you'll just end up one whole texture to the right (or left).

glTranslatef(0.5f, 0.5f, 0.0f);
glScalef(s, s, 1.0f);
glTranslatef(-0.5f, -0.5f, 0.0f);

Will probably work a lot better (it does for me anyway).

Good luck!

Share this post


Link to post
Share on other sites
Weird. I actually tried that earlier, but it didn't help. I just tried it again, though, and it's fixed! I must have changed something else in between that made a difference.

So thanks very much :-)

Share this post


Link to post
Share on other sites

This topic is 4859 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