Jump to content
  • Advertisement
Sign in to follow this  
TheUmpteenth

Texture coordinate transform

This topic is 4138 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'm still working on my skybox code, and I'm just as flummoxed (i like that word) Now, though, my problem is texturing. I want to make a texture for cloudy skies, and I want it to move accross the sky. I've been trawling the internet, but I can't find any decent tutorials on it. about all i've come up with is SetTextureStageState and D3DTSS_TEXTURETRANSFORMFLAGS but i don't quite understand how I can use this to make a texture move. can anyone point me in the right direction?

Share this post


Link to post
Share on other sites
Advertisement
I've always done scrolling manually by just passing down 'time' and 'rate' parameters to the shader and doing time*rate to get the coordinates (with wrap texture addressing). Maybe after a long enough time you'd have to reset the time back to 0 to avoid precision issues, but that's only after a really long time and shouldn't be a problem when you do.

I know that OpenGL has a special transformation stack for texture coordinates (as well as a bunch of environment settings), but I'm not sure about DX and to be honest I haven't done much messing around with them.

Share this post


Link to post
Share on other sites
If I were you I would stay away from states and lean towards Vertex and Pixel processing. From what I know it is the future. But if it's just not important then you need the sampler states I beleive.

Share this post


Link to post
Share on other sites
ok, i'll take that advice!

think I've got a CG book somewhere :)

although i've heard good things about HLSL

do you know if there is a Directx shader language? (iknow theres one for OpenGL)

Share this post


Link to post
Share on other sites
HLSL is the language used most often with DirectX, since D3DX (the utility library) has a bunch of support for it. You could technically use Cg with DX too, but you wouldn't have all the built-in support.

Share this post


Link to post
Share on other sites
If you wanted to use the fixed pipe, you'd so something like this:

D3DXMATRIX mat;
D3DXMatrixTransformation2D(&mat, ...);
SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
SetTransform(D3DTS_TEXTURE0, &mat);

And remember to
SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
when you're done drawing.

Share this post


Link to post
Share on other sites
Quote:
Original post by TheUmpteenth
Hi, I'm still working on my skybox code, and I'm just as flummoxed (i like that word)

Now, though, my problem is texturing. I want to make a texture for cloudy skies, and I want it to move accross the sky.

I've been trawling the internet, but I can't find any decent tutorials on it. about all i've come up with is

SetTextureStageState
and
D3DTSS_TEXTURETRANSFORMFLAGS

but i don't quite understand how I can use this to make a texture move.

can anyone point me in the right direction?




You could also make the clouds pass overhead on a seperate plane (possibly one quad or several seperate planes for a nice layered effect) and shift that plane quad depending on your weather direction.

To make a texture move across that quad it would be a window on a larger texture and the UV values for the quad's vertices would be shifted in formation (a small rectangle ex- one tenth the UV range .1) across your full texture space (0..1 0..1) as time progresses. There is the wrap mode that can simplify the edge encases.

A simple slow way is to copy the modified quad vertices (with the time changed UV values) into graphics mem or do a drq promitive directly out of system mem.
The slowness may not mater much since it only one (or a few) quads once per render cycle.

Share this post


Link to post
Share on other sites
Quote:

If you wanted to use the fixed pipe, you'd so something like this:


thanks, that was what I was looking for, except that I'm not sure what a matrix for a texture should look like (just a world matrix i guess, as you can rotate and scale)


Quote:

HLSL is the language used most often with DirectX, since D3DX (the utility library) has a bunch of support for it. You could technically use Cg with DX too, but you wouldn't have all the built-in support.


Thanks, I used Cg in Uni a couple of years ago, so I think I'll give it a try before trying to learn something totally new.


Quote:

You could also make the clouds pass overhead on a seperate plane


yeah, though of this, but it sounds a bit inefficient.


can you check for shader support? if so then I could use both approaches, the fixed pipeline model for GPUs that dont support shaders.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!