Possible almost free antialiasing

  • Craig Macomber

    Craig Macomber - 2009-01-04

    Project looks great, thanks for all your work!

    I'm new with Apophysis, and posting on SF, though I have made flame fractals with my own tools before. Hopefully this is the right place for such topics.

    I wrote a version of my ideas at:
    but here is a much more applied version.

    I found the rendering loop in the source, though I do not have stuff to compile it, nor can I really read C, Pascal, what ever it's in. I'm still learning.

    All code here comes from or is derived from Render32f.pas which is under GNU General Public License, please see original file for complete licensing.

    This is what could potentially benefit:
          pBucket := @buckets[Round(bhs * py)][Round(bws * px)];

    For the first idea in my linked post, I suggest something along the lines of:
    pBucket1 := @buckets[Round(bhs * py)][Round(bws * px)];
    pBucket2 := @buckets[Round(bhs * py+.5)][Round(bws * px)];
    pBucket3 := @buckets[Round(bhs * py+.5)][Round(bws * px+.5)];
    pBucket4 := @buckets[Round(bhs * py)][Round(bws * px+.5)];

    then run the with statement for all of them. This has the effect of translating them image 1/4 of a pixel in x and y (as a side effect, use floor/truncate instead of round to remove this effect) and adding 2X antialiasing. The cost is only that the buckets fill up twice as fast and a little more computation. You could to a similar thing using 9 buckets  for 3X or even more.

    It would require a small fix to this by the way:
          px := q.x - camX0;
          if (px < 0) or (px > camW) then continue;
          py := q.y - camY0;
          if (py < 0) or (py > camH) then continue;

    The other idea expressed in that linked thread is as follows:
    Suppose you did this?
    pBucket1 := @buckets[Round(bhs * py +rndx)][Round(bws * px+rndx)];
    assume rndx is a special random function that returns
    (random number from -.5 to .5)
    or possibly (It may or may not be better, I don't know)
    (((random number from -1 to 1)^3)/2)

    This does antialiasing a different way by making hits near the edges of pixels sometimes fall in one, and sometimes the other. The cubic version is the same, but much weaker. The below might be better, I'm not really sure.
    (random number from -1/3 to -1/3)

    If log(hits) based brightness is done, all of these should increase the brightness of the image, especially where gradients are high, which is probably a bad thing, but antialiasing before doing the log would cause the same effects.



    • Peter Sdobnov

      Peter Sdobnov - 2009-05-16

      This was one of the first renderer hacks I tried on Apo :) but somehow it didn't work as good as expected, and as I remember it was significantly slower...


Log in to post a comment.