I´m working on a point sprite shader with rotation based on the acceleration of the particles.
The conversion “Angle= asin (Acceleration/4)” works but it seems that the rotation of the quads is inverted for Angle > 0.25(East) and < 0.75(West).
I want to invert the angle in this part using this code, but only works the first conditional.
Am I missing something?
float Accel3 =normalize(tex2Dlod(SampData, TexCd).ba);
float Angle=asin (Accel/4);
if (Angle >= 0.25)
{Angle=Angle;}
else if (Angle>= 0.75)
{Angle=1-Angle;}
Is it possible to use a sort of double conditional?
like:
Thanks a lot vux,
now i understand it better.
But still some questions,
it works well in the X axis (from Pi/2 to 2Pi/3), but when the particles move through the Y axis they doesn´t change the direction (always 0).
Maybe is this not the best way to obtain the rotation values?
Any tip?
Ari
float Accel3 = (normalize(tex2Dlod(SampData, TexCd).ba));
float Angle = (atan (Accel3))/Pi;
if [Angle >= (Pi/2](https://vvvv.org/documentation/Angle->=-(Pi/2) && (Angle<= (TwoPi/3)))
{Angle=1-Angle;}
else
{Angle=Angle;}
if(Accel >= MaxColor)
{ Accel= MaxColor;}
else
{ Accel= Accel; }
Pos = mul(Pos, tW);
//now apply the position taken from the texture
Pos.xy = rotate( (Pos.xyz), 0, 0, (Angle))+particlePosition.xy; //rotate1.z does the roll
Pos = mul(Pos, tPost);
try atan2, it gives the right angle for all directions. and first you devide by Pi, setting the angle range to 0…2 and then you check for Pi/2 which does not look right. http://en.wikipedia.org/wiki/Atan2