A.D.A. Amiga Demoscene Archive

  Welcome guest! Please register a new account or log in

  

  

  

Demos Amiga Demoscene Archive Forum / Coding / sub-pixel precision rendering

 

Author Message
dalton
Member
#1 - Posted: 13 Mar 2012 09:55
Reply Quote
Hi,

for some time I've beem meaning to look into the subject of using sub-pixel precision for rendering different geometric shapes. For instance I would like to draw circles with their center position between screen pixels, and I've also been told that polygon rendering benefits from this technique. Many amiga coders seem to be using it these days.

Perhaps someone here could point me in the right direction? Haven't been able to find any good documents about it =(

Cheers

Dalton
pmc
Member
#2 - Posted: 13 Mar 2012 15:10 - Edited
Reply Quote
Dalton: check this stuff out: http://scalibq.wordpress.com/2011/11/

Read the "Just keeping it real - old skool style" stuff and all the related articles. You'll get to a section where Scali tells you all about his investigations into sub-pixel rendering of polygons on Amiga. He even includes some example videos and discussion of how to code hybrid blitter / CPU sub pixel line drawing routines on Amiga too.
Kalms
Member
#3 - Posted: 13 Mar 2012 16:08 - Edited
Reply Quote
Look at the first image on this page: http://msdn.microsoft.com/en-us/library/windows/de sktop/cc627092(v=vs.85).aspx


Imagine that each square there represents one pixel, and the cross in the center is where you "paint" the pixel. You have specified the triangle's vertices with (x,y) coordinates that include decimals.
So what you want to do in order to rasterize a triangle, is to interpolate down along both edges of the triangle until you reach the first row of pixel centers. At that moment you know which pixel-centers on that scanline are covered by that span. Then, if you want to apply any shading/texturing when rendering the span, you start from the leftmost edge, and interpolate horizontally till you reach the first pixel center; paint, interpolate to the next pixel center, etc.
Then interpolate down along both edges till you reach the next row of pixel centers. Repeat.

In practice this works out as a vertical (per-edge) and a horizontal (per-scanline) pre-step. Grab your pen & paper and draw some figures, that usually helps.

The source code in the article at http://www.lysator.liu.se/~mikaelk/doc/perspective texture/ does subpixel correction and is reasonably well commented (albeit without any pretty pictures).
dalton
Member
#4 - Posted: 13 Mar 2012 20:26
Reply Quote
Thanks! Lots of material. Will keep me occupied for quite some time =)
Scali
Member
#5 - Posted: 14 Mar 2012 13:29
Reply Quote
I think I can save you some time by pointing out that my subpixel-corrected blitter polygons are mostly a 'gimmick' for classic Amiga. It works, but only for flatshading.

If you want to do an AGA/accelerated routine with more advanced shading and/or texturing, then you should just take the 'conventional' route of rendering the entire polygon in software. Kalms' article is what you'll want.
Even if you do choose to go down my route, it is good to at least read Kalms' article and study the source first (or the Chris Hecker articles that I link to in my blog), as I don't explain subpixel-correct rendering itself in great detail with source code examples. I mainly concentrate on how to adapt the idea to the Amiga blitter.
dalton
Member
#6 - Posted: 16 Mar 2012 08:42
Reply Quote
@Scali: That's some very interesting articles you wrote, thanks!

 

  Please register a new account or log in to comment

  

  

  

 

A.D.A. Amiga Demoscene Archive, Version 3.0