Sprite Rev_eng

yanomano's picture

How is done the optional antialiasing on sprite ? Is there a way to apply this method on other objects with hack ?

cwright's picture
extra geometry + cheats

It works by adding extra geometry (more polys) -- place an antialiased sprite in the Polygon Mode patch, and you'll see it change size, as well as extra lines.

This way of doing AA can be good or bad -- good, in that it works with most types, but bad in that you need to generate several extra textures, extra geometry, and you end up burning your fillrate. This implementation is notably bad because the object visibly changes size too, so edges don't line up (create 2 sprites, put one at +0.5 x, the other at -0.5 x -- they'll be touching without AA, but with AA there's a huge gap between them. Objects would have these seams too, which is useless).

it's possible to work around the spacing problem, but it's difficult, and not a good solution for mesh objects. It's likely faster (and certainly more accurate) to render at 2x the resolution, and downsample manually.

yanomano's picture
Yes it is bad

You are wright.... Try to do an antialiased cube with sprite...edges don't works...

yanomano.

PreviewAttachmentSize
SpriteCube.qtz7.57 KB

toneburst's picture
I can't believe

there isn't a better way to smooth edges than rendering at 2x... It's such a sledgehammer approach, when all you really need to change is the edges of the geometry...

alx

Quartz Composer Blog: http://machinesdontcare.wordpress.com

Music Site: http://www.toneburst.net

yanomano's picture
SuperSampling4X don't works

I noticed that 2X works well do do that (with a render in image ) but if you Up Sample to 3 or 4X the aliasing come back...any idea why ?

yanomano.

PreviewAttachmentSize
supersampling_strange.qtz6.37 KB

cwright's picture
there is .. sort of

GL has supersample and multisample stuff for Exactly this reason -- but without configuring the context for that, you can't hack your way around it simply. It's not a problem in external apps (where you control your context yourself), but it's Really Difficult to hack around in QC (because the context init stuff is buried in pieces of code that plugins don't normally touch)

cwright's picture
double-moire

it may be because the billboard used to render the texture samples too much, which would reintroduce aliasing. I tried your composition, and if I made the billboard width 4 instead of 2, the cube looked smooth again -- this isn't a very good test though, I know.

It may also have to do with how the image is resampled -- if you pass it through a lanczos filter with the proper scale set, it looks really smooth. the image resizer doesn't resample the same way though, so it looks the same.

Having mipmapping enabled might help too -- I've never really had this work well in QC, but that's mostly because I've never really played with it.

toneburst's picture
Let's hope

Let's hope Apple get around to 'turning on' hardware AA in a future release of QC, then.

alx

Quartz Composer Blog: http://machinesdontcare.wordpress.com

Music Site: http://www.toneburst.net

toneburst's picture
Intriguing

I think if you turn mipmapping on you just get no image on the billboard. Unless you have an image that is already mipmapped. Don't think QC natively supports mipmapped image formats though....

Re. the lanczos patch; this does seem to smooth out edges quite nicely. I haven't done extensive tests, but my initial feeling is that it's about the same as the 2x supersampling method in terms of speed though.

alx

Quartz Composer Blog: http://machinesdontcare.wordpress.com

Music Site: http://www.toneburst.net

toneburst's picture
Incidentally

I've just been rendering in a Render In Image at 2x size, then piping the output of the RiI straight to a billboard set to output dimensions, so the billboard itself is doing the resizing. It seems to work OK.

Passing it through an additional Lanczos Scale Transform patch doesn't smooth it out significantly, but has a big effect (for the worse) on the framerate.

alx

Quartz Composer Blog: http://machinesdontcare.wordpress.com

Music Site: http://www.toneburst.net

yanomano's picture
SuperSampling_OK

seems it need a mix of the 2 methods... 3X and 4X are cool for non-realtime rendering...

yanomano.

PreviewAttachmentSize
supersampling.qtz9.31 KB