rotating uv's

Started by
10 comments, last by Halsafar 18 years, 9 months ago
Yes, if you're using a vertex shader, you must replace all vertex processing, which includes

WORLD, VIEW, PROJECTION transforms
TEXTURE transforms
Fog
Lighting
Texture Coordinate Index selection
Texture Coodinate Generation (TSS_TCI_CAMERASPACENORMAL, etc.)
Fixed function matrix palette skinning (only ATI in fixed function anyway)

Just like the world matrix setting texture transforms in D3D's normal fashion does nothing when using a vertex shader.

Just do like you do for the world transform. For world, you must make a variable to hold the world matrix and then you must transform your position by the world matrix in your shader, then in C++ you need to set the matrix with the effect interfaces each frame, instead of using SetTransform(D3DTS_WORLD, mat). In pretty much the same way, you must make a matrix variable for your texture transform, you must apply the transform yourself in the shader (as shown above), and in your C++ code you must generate and set the matrix in the effect interface, instead of SetTransform(D3DTS_TEXTURE0, mat);
Advertisement
Yup I got it all working.
I am rotating my cloud, cloud noise and cloud detail textures very simply in my VS now.

Curious tho, I cannot seem to directly change the way it rotates without causing some massive uglyness.

//rotate tu,tv
float2x2 rotation = {cos(time), -sin(time),
sin(time), cos(time)};

OUT.texCoordDiffuse0.xy = mul(IN.texCoordDiffuse0, rotation);
OUT.texCoordDiffuse1.xy = mul(IN.texCoordDiffuse1, rotation);
OUT.texCoordDiffuse3.xy = mul(IN.texCoordDiffuse3, rotation);


I am not rotating texCoordDiffuse2 cuz it is a sunset gradient texture, it never needs rotating.

This topic is closed to new replies.

Advertisement