best way to draw polygon lines?

GFA, ASM, STOS, ...

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

Zamuel_a
Atari God
Atari God
Posts: 1235
Joined: Wed Dec 19, 2007 8:36 pm
Location: Sweden

best way to draw polygon lines?

Postby Zamuel_a » Sun Nov 08, 2009 3:55 pm

I wonder what the best way is to draw polygons and especially what is the most efficent way to draw the horizontal lines. I made a polygon routine some years ago and then I used precalced tables for the left and right edge so I could get the bitplane data directly from a table and draw with that. the part between the left and right edge was easier, just a bounch of move.l
Another way to calc the left and right edge would be to shift data I guess. Start with $FFFF and shift it to the right with the left edge coordinate to get the mask and bitplane data (mask would just be a inverse of it).

I'm curious about using the blitter to draw polygons. It feels like it would be faster than software.
ST / STFM / STE / Mega STE / Falcon / TT030 / Portfolio / 2600 / 7800 / Jaguar / 600xl / 130xe

User avatar
bod/STAX
Atari Super Hero
Atari Super Hero
Posts: 508
Joined: Wed Nov 24, 2004 8:13 pm
Location: Halesowen, West Midlands, England

Re: best way to draw polygon lines?

Postby bod/STAX » Sun Nov 08, 2009 5:41 pm

Check you're personal messages. :)
So let it be written, So let it be done. I'm sent here by the chosen one.

User avatar
Cyprian
10 GOTO 10
10 GOTO 10
Posts: 1716
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: best way to draw polygon lines?

Postby Cyprian » Mon Nov 09, 2009 5:32 pm

bod/STAX wrote:Check you're personal messages. :)


can you share it?
Lynx II / Jaugar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / Lynx Multi Card / LDW Super 2000 / XCA12 / SkunkBoard / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Steem SSE / Aranym / Saint
http://260ste.appspot.com/

User avatar
earx
Captain Atari
Captain Atari
Posts: 353
Joined: Wed Aug 27, 2003 7:09 am

Re: best way to draw polygon lines?

Postby earx » Thu Nov 12, 2009 2:34 pm

zamuel: best way is to do like you say. on bitplane mode it's always the same. use mask tables for left and right edges.. and just moves inbetween. that's the basic idea.

implementations and variants:
there are many variants! 1 or multi bitplane hlines for starters. you can use jumptables for the moves, or even special routines for 0..20 moves. and there are even precalced hline routines.. delta hline routines (like in the synergy demo: crazy stuff). you can even do a combination: precalced delta routs (basically an animation).

it all depends a bit on what you'll use it for. how big are the polys? how many colours will you use.. interactive yes or no?

Zamuel_a
Atari God
Atari God
Posts: 1235
Joined: Wed Dec 19, 2007 8:36 pm
Location: Sweden

Re: best way to draw polygon lines?

Postby Zamuel_a » Thu Nov 12, 2009 3:11 pm

I never found an explanation for delta polygons. How are they made? the actual hline drawing must be more or less the same basic idea? The line routine I made years ago used mask tables and a unrolled loop inbetween that I moved the PC to the correct place for the current line. I never found any documentation on it, but it seemd to be the easiest way to do it.

One thing I thought about was a way to make sure you don't draw polygons on top of each other if you have many polygons on the screen at once. First sort the polygons so they are drawn FRONT to back, then calc the first polygon and create a table with left and right values for all hline spans, then instead of drawing them, just save the table and start with the next polygon. If the coordinates for a line span in that polygon is between the ones that are currently in the table, then clip if it's partially hidden or ignore it.
After all polygons are calculated you have a buffer with info about all line spans on the screen. Maybe something like: color,start_x,end_x,color,end_x,color,end_x
the previous line's end coordinate would be the next ones start coord.

It sounds like it could be a fast way to draw polygons if you have the entire screen filled or maybe it would still be to much so you don't gain anything usefull in framrate :wink:

Atleast I guess you could save the tables for every frame and then draw all spans like in an animation
ST / STFM / STE / Mega STE / Falcon / TT030 / Portfolio / 2600 / 7800 / Jaguar / 600xl / 130xe

User avatar
earx
Captain Atari
Captain Atari
Posts: 353
Joined: Wed Aug 27, 2003 7:09 am

Re: best way to draw polygon lines?

Postby earx » Tue Nov 17, 2009 2:48 pm

delta polys are only useful for simple but very very big objects. like a cube or dodecahedron covering the entire screen. that sort of thing. it works only on polygons that keep the same colour each frame. this is because only the differences between animation frames are drawn. and yes, it uses hlines. just two of them instead of one (on each side).

it was never documented because coders in the old days didn't like to. ;) anyway, i disassembled synergy's code to get an understanding. really great stuff. but optimised so far that it's a puzzle to trace it back to the 'essence'. i should write an article about it someday.. then at least it's in the open.

the span buffering technique you talk about i've also tried. nice that you've thought about it! it's a very nice system. if a pixel operation is expensive (possibly texturemapped or fancier) and there are loads of polygons this pays off. for a simpler 3D scenes it doesn't help at all. i tried on standard falcon. but it seems like it's more a technique for CT60..

Zamuel_a
Atari God
Atari God
Posts: 1235
Joined: Wed Dec 19, 2007 8:36 pm
Location: Sweden

Re: best way to draw polygon lines?

Postby Zamuel_a » Tue Nov 17, 2009 7:42 pm

Yea I thought the span buffer technic needed a rather big 3d environment before you got any increase in speed. Atlest it needs the entire screen filled so you always nows that you will fill 320 pixels. Then it would be possible to precalc the edge between two spans so you can ignore the bitplanes, and you don't need an endmask eather.

Has anyone tried the TT's special span drawing graphic mode? Sounds like that would be great for this kind of stuff.
ST / STFM / STE / Mega STE / Falcon / TT030 / Portfolio / 2600 / 7800 / Jaguar / 600xl / 130xe

Zamuel_a
Atari God
Atari God
Posts: 1235
Joined: Wed Dec 19, 2007 8:36 pm
Location: Sweden

Re: best way to draw polygon lines?

Postby Zamuel_a » Wed Nov 18, 2009 12:38 pm

delta polys are only useful for simple but very very big objects. like a cube or dodecahedron covering the entire screen


I know I have seen some demos there you are inside a box so it is covering the entire screen and it's still 50fps. I guess they used delta polygons there. All you would have to do then is just to draw a "wire frame" cube, but the wire is actully a 32 pixel wide section that covers the edge of two connecting polygons if I understood it right?

I guess it's to much to be able to draw a cube in 50 fps that uses real polygon routines. As usual with demo effects. If it looks to good to be true, then it probibly is :D
ST / STFM / STE / Mega STE / Falcon / TT030 / Portfolio / 2600 / 7800 / Jaguar / 600xl / 130xe


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: No registered users and 2 guests