how to make this function run?

the following is a fast sinus approximation do you think the following function would be lighter and/or faster on the graphics processor than the sinus function?

float  par (float xx){////// sinus approximation

var xd =((fmod(abs(xx), 2.4)) - 1.2);

if ( fmod (abs(xx) , 4.8)  > 2.4) { xd=(-xd*xd)+2.88;}
else {xd = xd*xd;}
xd = -xd*0.694444444+1;
if (  (xx<0) ) { xd=-xd;}
return xd;
}

Thats unlikely… Trigonometric functions are often hardware accelerated to the point of taking just a single cycle on modern GPUs (2008-ish). It might be faster on older hardware, but again, it depends on the device.

Your best bet is to try it out… set a number of calls per fragment (with different parameters, so they don’t get optimized away) on a full screen quad and measure the framerate :slight_smile:

Thank you, I just had a try and copy pasted 74 sine functions and then 74 accelerated functions and the frame rate was the same. It simply unbelievable that I can put 74 sine functions in one shader woot!