Compute the texture coordinate based on object movement

Started by
3 comments, last by pnt1614 12 years ago
I just use a triangle with 3 vertices and texture coordinates. At frame t, the first vertex information is (x1, y1, z1) + (u1, v1), if I move it to the right 1 unit ( x1' = x1 + 1 ), so how can I recompute the texture coordinate?. Anybody helps me, please?
Advertisement
Why would the texture coordinates of a vertex change when it moves?
Normally, the texture coordinate does not change as an object moves but I just want to get to color at the new texture positio for blending, it is similar to blending 2 colors from the last frame and the current frame
I don't understand the exact problem although what you are after is totally doable.

Since you update your positions as you have showed, you'll just need to establish a relation between the texture coordinates and the positions. With the information you have provided, it isn't possible to deduce the relation you want to accomplish between the positions and texture coordinates.

Also, you haven't indicated if this is a technical problem such as "I don't know how to update the vertex buffer" or "I don't know how to calculate texture coordinates in vertex shader".

Otherwise, since you add a value to your vertex positions, can't you just add some value to your texture coordinates? Perhaps you could show a piece of code which handles the moving part?

Best regards!
thank everyone for replying, I did it, I just rendered to a texture with UV position in frame t, then in next frame I just get UV position and obtain the color of that position with tex2D

This topic is closed to new replies.

Advertisement