• Advertisement
Sign in to follow this  

Moving Texture Coordinates To Keep Texture Static

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

Sorry for the long title. I can't really figure out exactly how to phrase this question. Basically I'm wondering how I can program (in 2D) shapes that are textured that when they move the texture appears to remain static while the shapes move. Basically you could think of the texture being a wall outside and the shape being a moving window such that you would see different parts of the texture as it moved. I'm sure this is pretty basic and I'll kick myself for not figuring it out, but it's something I've been wondering for a while now.

Share this post


Link to post
Share on other sites
Advertisement
In OpenGL you would use one of the 'distance-to-plane' texture generation modes (don't remember the syntax off the top of my head). I imagine there's an equivalent in D3D as well.

The basic idea is that the (u,v) values corresponding to a vertex are derived by computing the distance of that vertex as measured from a set of planes (one for each texture coordinate element). In 2D this can be simplified to e.g. computing u and v as simple scalar multiples of x and y.

If for some reason you don't want to use the automatic texture coordinate generation facilities of your API, it's easy enough to perform the computations manually.

Share this post


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

  • Advertisement