I've been looking in to making a cooldown timer effect, When you press a button and it has the shading going around.
After my third go I think I found a good way to do it but some of the math like the atan2 im doing a flip on to get 360.
Ok I know angle's again why??? only thing I know I'm a Ex metal fabricator.
Any how the cooldown timer is in the pixel shader using the texture coords and I pass in a angle based on time 1 degree or more a second
depends on how fast you want it to spin(go around).
It looks like a mess is there a neater way of doing it.
What way would you try.
//heres the pixel shader this is my test code it works I display red for now for range between 0 and 180
and green when I flip the angle.
float4 DrawPStimer(GS_OUT pIn) : SV_TARGET
float2 start = float2(0.0,0.0);//points up
float currentangle = radians(345.0);
//we need to turn the texture coords into a direction vector ???
//texcoord need to be converted to its 0, 0 pos
float2 e = float2(0.5,0.5);
float2 t = pIn.texC - e;
float2 p = normalize(start - t );
float a2 = atan2(p.y, p.x);
if(a2 <= currentangle && a2 > 0.0)
return float4(1.0f, 0.0f, 0.0f, 1.0f);
if(a2 <= 0)
if(a2+ radians(360) < currentangle)
return float4(0.0f, 1.0f, 0.0f, 1.0f);
return float4(0.0f, 0.0f, 0.0f, 0.0f);
here is a image with the current angle set to 275
0 degrees is to the left 180 right
new image now
Edited by ankhd, 02 July 2014 - 09:08 PM.