AuthorTopic: Forcing AA out of engines  (Read 5444 times)

Offline .TakaM

  • 0100
  • ***
  • Posts: 1178
  • Karma: +1/-0
    • View Profile
    • Fetch Quest

Forcing AA out of engines

on: February 22, 2007, 10:31:56 am
hard to come up with a suitable topic name..

I'll just get into it, in my Twinsen game Im considering having the background's sky be spherical in real time, so when you jump up and down, move to the left/right you see the clouds and sky get warped on the sphere.

obviously, for Twinsen's current sky background:

when the engine warps it to a sphere, its made jagged, pixelated and the 1 pixel lines will be invisible at some points
the solution is to 2x the sky, and apply AA like so:

then, when you put it in the game, have the code shrink it to 50% so it looks exactly the same as the original.
except that when you warp it, it automatically AA's itself, because even though you don't see the 50% shades, they're just in between the displayed pixels, so when you shrink a certain part another 50% it goes to select the pixels halfway between the pixels displayed

kinda a mess to explain

here is the before and after, the before showcasing how it would look to just skew the original, un-aa'd sky:

jagged, and clearly not AA'd
and the after, showcasing how it looks when you skew the larger version with the AA:

smooth, and aa'd

just keep in mind this would be a much better example if I could spherize these without photoshop blurring them, and if you could see it move around in real time.

Just think back to old mode7 racers:
How if you lined up perfectly adjacent with the pixels of the track image, lines parallel to the horizon would flash and flicker as you moved until they got close enough that they could be consistently displayed without the pixel's you didn't see a frame earlier taking their place.
again, its a bit of a mess to explain, but I'm sure most of you understand what I'm talking about

Yeah. Ive just always thought its interesting how pixel art can be skewed, shrunk, and rotated nicely in a controlled environment, but so very few games ever made use of such technique

edit-

this is probably a better example:
« Last Edit: February 22, 2007, 12:19:17 pm by .TakaM »
Life without knowledge is death in disguise

Offline Ai

  • 0100
  • ***
  • Posts: 1057
  • Karma: +2/-0
  • finti
    • http://pixeljoint.com/pixels/profile.asp?id=1996
    • finticemo
    • View Profile

Re: Forcing AA out of engines

Reply #1 on: February 22, 2007, 01:57:42 pm
Have you checked that? your results seem too good to match the input. Particularly the last image -- the input image guarantees that you won't get AA on both sides of the line.
Something else that you haven't brought up -- The scaled image should have 'AA' in both directions to work correctly with your approach - ie. it's a linear interpolation of the input.

You might be better off just implementing supersampling or simple decimation. This solution you describe strikes me as very tense (programming term meaning strongly dependent)
If you insist on being pessimistic about your own abilities, consider also being pessimistic about the accuracy of that pessimistic judgement.

Offline .TakaM

  • 0100
  • ***
  • Posts: 1178
  • Karma: +1/-0
    • View Profile
    • Fetch Quest

Re: Forcing AA out of engines

Reply #2 on: February 22, 2007, 02:04:54 pm
the last example was an example of how an in game engine would handle it.

the benefits of having the code shrink the image to 33% (while still keeping the complete information of the image at 100%) then letting the code skew it, means when it moves it will give the effect of sub-pixel animation

however, if you want to try this in a program like MSpaint, you just need to skew the 100% image first, then shrink it.
infact, if you've got the firefox plug-in to rescale images on the fly, shrink this image to 33%:
http://img337.imageshack.us/img337/3039/33yl3.png
Life without knowledge is death in disguise

Offline ptoing

  • 0101
  • ****
  • Posts: 3063
  • Karma: +0/-0
  • variegated quadrangle arranger
    • the_ptoing
    • http://pixeljoint.com/p/2191.htm
    • View Profile
    • Perpetually inactive website

Re: Forcing AA out of engines

Reply #3 on: February 22, 2007, 02:16:58 pm
Looks jaggy to me. I would just use opengl or something. dunno.
There are no ugly colours, only ugly combinations of colours.

Offline eck

  • 0010
  • *
  • Posts: 322
  • Karma: +0/-0
  • But why is RUM gone???
    • View Profile

Re: Forcing AA out of engines

Reply #4 on: February 22, 2007, 02:18:41 pm
not really sure what your talking about, and my not reading through everything you posted probably doesn't either.

so if i understand this correctly, you want the bg to skew in your game, but you get a bad case of the jaggedness?  then you found that if you double its size, it gets aa'd?

so then wouldn't it make since that if you drew it at half size, then doubled it so it fit your game, that it would be auto aa'd?
untz untz untz?

Offline .TakaM

  • 0100
  • ***
  • Posts: 1178
  • Karma: +1/-0
    • View Profile
    • Fetch Quest

Re: Forcing AA out of engines

Reply #5 on: February 22, 2007, 02:24:09 pm
Looks jaggy to me. I would just use opengl or something. dunno.
well, it's not exactly the same as it would be done by hand, its a strictly mathematical outcome.

I just thought its interesting that there are ways to make pixel art techniques work with 3d, albeit limited 3d
Life without knowledge is death in disguise

Offline Ai

  • 0100
  • ***
  • Posts: 1057
  • Karma: +2/-0
  • finti
    • http://pixeljoint.com/pixels/profile.asp?id=1996
    • finticemo
    • View Profile

Re: Forcing AA out of engines

Reply #6 on: February 22, 2007, 10:58:11 pm
[...]
however, if you want to try this in a program like MSpaint, you just need to skew the 100% image first, then shrink it.
infact, if you've got the firefox plug-in to rescale images on the fly, shrink this image to 33%:
http://img337.imageshack.us/img337/3039/33yl3.png
Okay, that worked! It has worse AA quality than your example skewed sky, though.

Quote
well, it's not exactly the same as it would be done by hand, its a strictly mathematical outcome.
So's decimation, and that would produce usually-better AA without needing a large input image. It just depends on whether it's intended for a platform with a full color or limited color display -- decimation might be a speed hit if you have to fit the colors to a palette after decimation.

http://en.wikipedia.org/wiki/Decimation_%28signal_processing%29
If you insist on being pessimistic about your own abilities, consider also being pessimistic about the accuracy of that pessimistic judgement.

Offline Akira

  • 0010
  • *
  • Posts: 334
  • Karma: +0/-0
  • Heheheh
    • View Profile

Re: Forcing AA out of engines

Reply #7 on: February 23, 2007, 10:12:40 pm
thats cool. would it work with images other than straight lines? i guess the hard part there would be the AA. intriuging.
what would decimation look like Ai? any examples?
thanks Dogmeat!

Offline Ai

  • 0100
  • ***
  • Posts: 1057
  • Karma: +2/-0
  • finti
    • http://pixeljoint.com/pixels/profile.asp?id=1996
    • finticemo
    • View Profile

Re: Forcing AA out of engines

Reply #8 on: February 24, 2007, 12:25:17 am
Decimation doesn't look like anything per se -- It involves calculating a pixel value for each output pixel based on the nearby pixel. Typically it is done using linear interpolation (weighted contributions from the nearest 4 input pixels)

In the case where you only want to skew, it can probably be optimized, since skewing is a transformation across only one dimension.

Decimated without quantization:


Decimated with quantization to a similar palette as TakaM's example uses.
If you insist on being pessimistic about your own abilities, consider also being pessimistic about the accuracy of that pessimistic judgement.

Offline Akira

  • 0010
  • *
  • Posts: 334
  • Karma: +0/-0
  • Heheheh
    • View Profile

Re: Forcing AA out of engines

Reply #9 on: February 24, 2007, 12:41:29 am
hm i actually think that taka's example fits pixel art better. idk.
thanks Dogmeat!