5 Replies Latest reply on Oct 11, 2007 9:09 AM by Kevin Goldsmith

    Mandelbrot Possible?

      As I understand it rendering a Mandelbrot would be possible using the AIF toolkit. However my implementation doesnt seem to work. Could this be due to the fact that my card (X1600) may not support the full range of operations used by the AIF toolkit?

      My implementation is here: Mandelbrot Implementation From what ive seen in other peoples examples this should be possible, and well within the bounds of the AIF. I just seem to get a shaded circle around the origin though.

      -Matthew Lloyd
        • 1. Re: Mandelbrot Possible?
          Kevin Goldsmith Level 3
          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.
          • 2. Re: Mandelbrot Possible?
            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:

            kernel simpleMandelbrot

            region generated()
            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;
            ++iteration )

            // 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);

            • 3. Re: Mandelbrot Possible?
              Deviant1853 Level 1
              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 :)
              • 4. Re: Mandelbrot Possible?
                Mario Klingemann
                Great Job! Can you please create a version of this now which is Flash compatible? ;-)
                • 5. Re: Mandelbrot Possible?
                  Kevin Goldsmith Level 3
                  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.