Log In  

Cart [#49509#] | Code | 2018-02-22 | License: CC4-BY-NC-SA | Embed
11

This cart is just to provoke @zep (or any other true Pico-8 genius) into releasing a fast anti-aliasing demo cart!

The code is a LUA port of that paper:
http://jamesarich.weebly.com/uploads/1/4/0/3/14035069/480xprojectreport.pdf

Note: I don't get how an incremental line drawing routine (a la Bresenham) can be that slow (compared to the native version). 270% cpu usage for 16 lines sigh...

P#49510 2018-02-22 15:16 ( Edited 2018-02-28 07:42)

:: Felice
5

I think it was slow because the code you ported was doing a lot of work per step, a lot of which isn't needed on PICO-8.

Anyway, I took the challenge. I'm lazy, though, so I just tweaked your app instead of writing one from scratch. It's less of a port of a PC app now, making more use of PICO-8 and Lua. I optimized a few things and improved the palette usage. It's still the same algorithm, just taking advantage of some implicit knowledge to avoid some work, e.g. rendering only two pixels instead of three per step. I did change the coverage blend operation to work better in areas of high previous coverage. Also, I got it under half CPU, so I upped it to 60fps too.

Edit: BTW, use ⬆️/⬇️ to change the number of spokes, ⬅️/➡️ to change the spin speed, 🅾️ to toggle AA, and ❎ to pause.

Cart [#49550#] | Code | 2018-02-23 | License: CC4-BY-NC-SA | Embed
5

P#49536 2018-02-23 05:02 ( Edited 2018-02-23 16:13)
:: Hoto

Love those tech demos!

P#49561 2018-02-23 15:41 ( Edited 2018-02-23 20:41)

Ok ok my "pixel shader" was awfull :[
I'll do my homework next time!

Bring on the Vectrex games gents!

P#49565 2018-02-23 16:29 ( Edited 2018-02-23 21:29)
:: Felice

By the way, I was playing with it a bit and you could probably simulate the effects of the electron beam slowing and speeding up in a vectrex-like game by putting a multiplier on the distance that's higher in the middle of the line.

Not sure what math would be simplest to accomplish that. Maybe a parabolic arc centered at the middle of the line segment, or maybe just two ramps that meet in the middle (abs() is handy for that).

P#49583 2018-02-23 22:00 ( Edited 2018-02-24 03:00)
:: Felice
2

I decided to try writing my own routine. I still used your shell, but this is a different algorithm. I'm taking advantage of the fact that PICO-8 has some nice (albeit unrealistic) things like 1-cycle divides. It's a fair bit faster.

(It can be about 15% faster still, if you take out the adjustment that makes diagonal lines appropriately darker. Look for k=....)

Cart [#49597#] | Code | 2018-02-24 | No License | Embed
2

Not sure if the results are technically correct. I was just winging it, using really basic linear algebra. I did make an effort to get subpixel positioning correct, but I'm not 100% sure it's perfect.

I think this is the fastest I can make it.

P#49596 2018-02-24 07:18 ( Edited 2018-02-24 12:22)

Woow - that level of dedication!!

Minor improvement (~-0.1%/line): replace the sqrt by an approximate (given we already calculate w/h majors):

"patch":

-- no longer needed
-- local d=sqrt(w*w+h*h)
local k=h/(h*0.9609+w*0.3984)
...
local k=w/(w*0.9609+h*0.3984)

Reference: https://oroboro.com/fast-approximate-distance/

P#49600 2018-02-24 09:24 ( Edited 2018-02-24 14:24)
:: Felice

Oh, nice! I wasn't aware of that trick. I think sqrt() is about 28 cycles, so that's definitely a win. I put it in.

I also fixed a typo that was culling perfect diagonals, and a precision issue with the angle calculation in the outer loop that was messing with symmetry and creating a dark spoke that traveled around the edge of a very dense fan. You can also step when paused with P2's 🅾️/❎ (tab and Q on my keyboard).

Cart [#49619#] | Code | 2018-02-25 | No License | Embed

P#49618 2018-02-24 19:50 ( Edited 2018-02-25 00:58)
:: Felice

paku paku

P#49620 2018-02-24 20:06 ( Edited 2018-02-25 01:07)

Well, I had to do it:
https://www.lexaloffle.com/bbs/?tid=30837

(and ships with anti-aliased circfill =:)

P#49677 2018-02-25 17:02 ( Edited 2018-02-25 22:03)
:: Felice

You know, this is why I've always been a game engine programmer, not actually a game programmer. :)

Some people love creating games. I love helping people create games.

P#49692 2018-02-25 23:14 ( Edited 2018-02-26 04:14)

Wow! This is excellent stuff.

P#49743 2018-02-27 02:49 ( Edited 2018-02-27 07:49)
2

To complete the thread, circ and circfill have their anti-aliased counter parts!

aacirc

Note: yeah, 10% cpu for a single circle @ 60hz...

aacircfill

Live Demo


left/right: decrease/increase radius
x: turn on/off anti-aliasing
c: fill

Cart [#49755#] | Code | 2018-02-27 | License: CC4-BY-NC-SA | Embed
2

P#49754 2018-02-27 13:22 ( Edited 2018-02-27 18:28)

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-09-22 16:06 | 0.032s | 4194k | Q:75