I have a pixel shader that calculates a mandelbrot fractal. It uses the standard formula:
z = z2 + c
I'd like to extend it so the power z is raised by varies. To do this i have the following function:
float2 ComPow(float2 Arg, float Power)
{
float Mod = pow(Arg.x * Arg.x + Arg.y * Arg.y, Power / 2);
float Ang = atan2(Arg.y, Arg.x) * Power;
return float2(Mod * cos(Ang), Mod * sin(Ang));
}
The problem i've got is the xbox does this really slowly compared to squaring a complex number. I'm thinking it's partly because of the increased number of instructions, but mainly it's using trig functions (cos, sin and atan2).
I tested this by adding a single atan2 within the for loop and it's visibly jerky, whereas before it was getting a good FPS.
Can i use texture lookup to speed up / replace the cos, sin and atan2 calls? If so, how?