im implementing a vector drawing module for cocos. it works with svg
like actions: line_to, move_to, bezier_to, rotate, scale, circle, arc
when drawing a line i first compile all the comands into one huge
vertex list. there i set lots of triangles and their color.
my question is: how should i make the lines i draw antialiased?
rigth now im using multisampling (comes with pyglet). but ive seen
pages that talk about using a texture of a circle and mapping it to
the triangles to get the antialias and the rounded caps.
what do you think i should do? what would look better? im willing to
even rewrite everything if i can get better quality.
regards,
lucio.
You can also try GL_LINE_SMOOTH, with varying results on different
devices (apparently a blend function also needs be set on some drivers
for this to work).
> pages that talk about using a texture of a circle and mapping it to
> the triangles to get the antialias and the rounded caps.
I've used a similar trick to render lines on web pages with DHTML/JS
(this was before SVG was commonplace, obviously). It needed input
textures at 0, 45 and 90 degrees to work at all, and looked awful even
for short lines. With GL's bilinear sampling the results might be
usable, but the antialiasing would never be correct (except, of
course, when the texture is mapped 1:1).
You can get perfect and fast results by drawing a quad with a fragment
program filling in the line (and optionally antialiasing it). See the
papers by Blinn et al from Microsoft. They also do curved lines.
Alex.
but im not using lines, just triangles (lines should have nice caps
and joins for every width)
also, GL_POLY__SMOOTH i heard that it makes the triangles that make
the polys visible.
is this correct?
>> pages that talk about using a texture of a circle and mapping it to
>> the triangles to get the antialias and the rounded caps.
>
> I've used a similar trick to render lines on web pages with DHTML/JS
> (this was before SVG was commonplace, obviously). It needed input
> textures at 0, 45 and 90 degrees to work at all, and looked awful even
> for short lines. With GL's bilinear sampling the results might be
> usable, but the antialiasing would never be correct (except, of
> course, when the texture is mapped 1:1).
ive seen some samples in a webpage where it doesnt look so bad. ill
post the link later, id like to know what you think.
>
> You can get perfect and fast results by drawing a quad with a fragment
> program filling in the line (and optionally antialiasing it). See the
> papers by Blinn et al from Microsoft. They also do curved lines.
ill take a look at that.
how easy is to get fragment shaders that worky reliably across all
video cards and systems?
Lucio.
this is the link:
http://homepage.mac.com/arekkusu/bugs/invariance/TexAA.html
im doing this:
research.microsoft.com/~cloop/loopblinn05.pdf
"Resolution Independent Curve Rendering using Programmable Graphics Hardware "
its a great paper. although im going to have trouble with antialiasing
and doing circles/arcs.
any other paper i should read?
Lucio.