My application needs to access the atan function in a fragment program.
I noticed that this function is available in GLSL, but I already hand optimized my code using the arb fragment program.
Is there any way to access the atan function in arb fragment program or nv fragment program?
I tried using a texture lookup table, but since the input argument ranges from -inf to inf, I had to clamp the the texture and set the limit values in the edge pixels. Also, because it evolves slowly, I either needed a large texture which reduced performance or a small texture which didn’t have enough accuracy near zero. I could not find a good tradeoff between them.
Apparently, the Euler approximation converges faster (and thus needs fewer terms for approximation).
Also, because atan() goes very flat outside the middle range, you could use texture coordinate clamping, and map, say, the range [-10,10] to a texture, and just set the min and max values to -pi/2 and pi/2 respectively.