Jump to content


Rasterizing Complex polygon, vertical jitter problem


4 replies to this topic

#1 Rhino

    New Member

  • Members
  • PipPip
  • 15 posts

Posted 27 March 2006 - 01:25 PM

Hey guys,

I've just recently converted a polygon filler to j2me so that we can use it to draw vector fonts.

to accomplish this I converted this Gem:
http://ftp.arl.mil/f...vePolygonScan.c
to j2me and to fixed point and it works fine.

I then added horizontal antialiassing just by using the 8 bit fixed point value of the starting spans. Also, no problem.


the only problem I encountered is that due to the nature of the horizontal scanline conversion algorithm, is that horizontal lines can completely be skipped and not rendered at all. :sad:

Consider for instance the A and the little line in the middle. If one is unlucky, that whole line could not be rendered because it just falls inbetween scanlines.


is there a way to get over this shortcoming? And better yet, to implement vertical antialiassing in a cheap manner too?

thanks!

Reinier

#2 Nick

    Senior Member

  • Members
  • PipPipPipPip
  • 1225 posts

Posted 27 March 2006 - 07:15 PM

I'm not experienced with font rendering, but one idea that jumps to mind is to just render the polygon with horizontal scanlines, then vertical scanlines (into a second buffer), and then blend the two together.

#3 Nils Pipenbrinck

    Senior Member

  • Members
  • PipPipPipPip
  • 597 posts

Posted 27 March 2006 - 10:20 PM

Rhino,

For small glyhps, where one feature might be less than a pixel in size you should take a different approach and do forward rasterization.

For each pixel, find the polygons that intersect the pixel-rectangle, calculate the coverate and shade the pixel according to the coverage.

Yes, this is horrible slow, but fortunately if you need a glyph of a font.. say the 'A'-character it's likely that you'll need it again sooner or later. So cache your glyph bitmaps and you're done.

Rendering the triangles of a glyph tesselation works only for large glyphs or if you do lots of multisampling.

#4 Rhino

    New Member

  • Members
  • PipPip
  • 15 posts

Posted 28 March 2006 - 09:37 AM

nils: It makes sense what you write, but given that j2me is dead slow already, this method would just take too long. Furthermore, caching it is not a possiblity since of screen surfaces which are drawable in j2me, can not have transparent regions. This means that the fonts would loose their transparency which is quite necessary.


nick: this seems like a nice solution. I'll give it a try. I think that the algorithm can easily be rewritten so that it can swap the 'scanline direction' by just swapping the X and Y coords and then again at the moment I draw the lines. :happy:

thanks!

Reinier

#5 Reedbeta

    DevMaster Staff

  • Administrators
  • 4979 posts
  • LocationBellevue, WA

Posted 28 March 2006 - 04:40 PM

Rhino: can't you use any kind of alpha blending with your cached bitmaps?
reedbeta.com - developer blog, OpenGL demos, and other projects





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users