This content has been marked as final. Show 5 replies
Bob Archer wrote a Mandlebrot implementation. I've noticed that there are some problems on some video cards. This might be a bug in the toolkit. I'll take a look at your mandlebrot implementation and see if Bob will let me post his. He's on vacation, so it won't be until next week.
It sounds like the coordinates might need to be scaled for you to see the values.
Here's a simple example that I implemented based on the wikipedia mandelbrot article algorithm that you can use as a starting point. It seems to work on my MacBook Pro.
It only does gray, so I'll leave it as an exercise to add color:
return region( float4( 0, 0, 512, 512 ) );
void evaluatePixel( out float4 dest )
// some useful constants
const float2 offset = float2(-375.0, -256.0);
const int maxIteration = 100;
// get the output coordinate
float2 coord = outCoord();
// center and scale the results
float2 loc0 = (coord + offset) / 256.0;
float2 loc = loc0;
int iteration = 0;
// iterate through and check whether the orbit point has a modulus > 2
for( iteration = 0;
iteration < maxIteration;
// if the modulus is greater than 2, we break
if( length( loc ) > 2.0 )
float xtemp = loc.x * loc.x - loc.y * loc.y + loc0.x;
float ytemp = 2.0 * loc.x * loc.y + loc0.y;
loc = float2(xtemp, ytemp);
// get the iteration count and normalize to 0.0-1.0
float luminance = float(iteration);
luminance /= 100.0;
dest = float4(luminance, luminance, luminance, 1.0);
Ah thank you. This is actually an amature mistake on my behalf. Your right i never scaled the actual input fed in to the complex function. Ill edit mine to correct this and hopefully everything will be fine :)
Great Job! Can you please create a version of this now which is Flash compatible? ;-)
you could unroll the loop and use a conditional assign instead of the if/break. That would just be much longer :)
We're looking at doing loop unrolling automagically in the compiler for Flash filters. I can't promise that we'll be in FP10, but we'll try.