Rotate texture ?

Posted By: gri

Rotate texture ? - 02/18/14 11:38

hi,

done by changing my.u or my.v we can shift the texture at runtime.

Is there a posibility for rotating too? Like an textureanimated wheel?
Posted By: Superku

Re: Rotate texture ? - 02/18/14 11:49

For what purpose?
It can (of course) be done with a shader.

EDIT: Only now see "texture animated wheel". Is a shader an option?

EDIT2: Tested and works:
Code:
my.skill1 += 5*time_step;
my.skill1 %= 360;
my.skill2 = cosv(my.skill1);
my.skill3 = sinv(my.skill1);
mat_rotate.matrix11 = my.skill2;
mat_rotate.matrix12 = -my.skill3;
mat_rotate.matrix21 = my.skill3;
mat_rotate.matrix22 = my.skill2;
...
OutTex = mul(InTex-0.5, matMtl)+0.5;



If you want to have different speeds for different wheels you need to calculate the transformation/ rotation in the vertex shader. You can speed this up by calculating cos and sin in the entity function, save those values in vecSkill41.xy and use those to implement the rotation, for example as follows:

Code:
InTex.xy -= 0.5;
OutTex.x = vecSkill41.x*InTex.x - vecSkill41.y*InTex.y;
OutTex.y = vecSkill41.y*InTex.x + vecSkill41.x*InTex.y;
OutTex.xy += 0.5;



When I think about is, this is probably the better approach in almost all cases.
Posted By: gri

Re: Rotate texture ? - 02/18/14 13:16


crazy !

thanks Superku
© 2024 lite-C Forums