Archived

This topic is now archived and is closed to further replies.

Chaucer

the fastest way to change texture coords

Recommended Posts

I''ve got a sky plane that''s being multi-textured like this: texturestage1) blue texture texturestage2) graymap cloud texture (additive blending) texturestage3) graymap sun texture (additive blending) I''d like to scroll the texture coordinates of the sun so it moves across the sky plane. I was hoping someone could offer a fast way to do this. Currently, I am thinking of using a dynamic vertex buffer but that will require re-calculating the vertices AND both sets of texture coords(1 for blue+clouds, 1 for sun) each frame. I appreciate any help.

Share this post


Link to post
Share on other sites
Is the blue sky texture a gradient or does it have detail? If it is solid blue or maybe even a gradient then I would see if I could make the blue come from the vertex color values, thus eliminating one texture.

As for changing texture coords for the sun, I think you pretty much have to update the buffer each time or you could render the sun on its own quad and just move the quad across the sky. To bad there isn''t a way to use some sort of dynamic vertex coordinate offset.

Share this post


Link to post
Share on other sites
Thanks Anonymous and quasar. That''s exactly what I was looking for

Igilima - thanks, I''m using a gradient blue color right now and would like to keep the flexibility it has as a texture. Good idea though. Also, I tried making the sun a billboard and translating it across the plane, but that has other problems since it''s using additive blending(I want the sun''s texture to lighten the clouds and sky instead of just being an object there if ya know what i mean). I ran into problems with the additive blending because the entire cloud texture would be mapped onto the smaller billboard. This obviously wouldn''t look right against the plane and it would be difficult to get the texture coordinates to line up

I just looked into the texture coordinate matrix and it looks like the ticket.

Share this post


Link to post
Share on other sites
Could anyone point me to a place that will tell me which matrix elements represent the tu, and tv coords? Or maybe what all matrix elements represent incase I''d like to scale, etc.

Thanks.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
For example, if you want to scale the texture coordinates, then you can do it like this:

D3DXMatrixScaling(&matScale, 2.0f /* tu-scale */, 3.0f /* tv-
scale */, 2.0f /* tw-scale */);

So, tu is like x, tv, is like y, and tw is like z if you use three texture coordinates (for example cube map).

I hope this helps.

Share this post


Link to post
Share on other sites
Hmm. So I would use D3DXMatrixTranslation() to translate the tex coords?

I have another problem in that i''m using border color for my texture addressing. I''m doing this, so I can have one sun, with the rest of the texture invisible since I''m using additive blending and the border color is black.

This works great except that the sun is always in the corner of the sky. I can''t translate it across the entire sky, since the sun texture must be between tex coords 0.0 and 1.0, which is only in the corner. I''m wondering if there''s a way to move that area across?

Share this post


Link to post
Share on other sites