Author Topic: [Axe] Plane deformations are fun  (Read 26233 times)

0 Members and 1 Guest are viewing this topic.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
[Axe] Plane deformations are fun
« on: January 23, 2014, 01:02:36 pm »
Hey guys,

Graphically impressive (read : useless) programs had always been my thing, so when I figured out that I could do some intense LUT-based demoscenes-like programs (my first one was actually nSpeedX3D, it uses the same concept), I took the only programmable machine that was near me : my TI-83+. Could have been my PC, but I was at school.

So, in a mere 3 hours I wrote a small LUT generator that takes X, Y as input (the center of the screen being 0,0) and gives U, V as output. Basically, X and Y are screen coordinates, and U and V are texture coordinates, so I use those to draw things on the screen with a bit-per-bit basis - very slow in Axe, but w/e, it was meant only to look good, not to be fast. Actually, you can argue a bit about it looking good, but I couldn't really do any better with Axe's precision and the z80 calcs' LCD.

So yeah, basically, to perform a plane deformation, you don't need many things :
  • A texture (I use a 8*8 one),
  • Two 6144-bytes LUTs (yup, that's a lot), one byte for the X of each pixel, one byte for the Y,
  • Two equations, one that gives U, one that gives V.
So first, you want to make sure everything works. So you just do U = X and V = Y. It gives this.



(Note how the LUT generation takes ages. We actually generate 12288 coordinates.)
Now that you're certain it works, you can start doing actually funny and interesting things ;D

r = sqrt(x² + y²)
a = tan-1(x,y)


u = x * 8 // abs(y)
v = 512 / abs(y)



u = x * cos(r * 2) - (y * sin(r * 2)) // 256
v = y * cos(r * 2) + (x * sin(r * 2)) // 256



u = 1.0 /* (r * 256 + 0.5 + (sin(a * 5) // 2))
v = a * 3 * 256 /* 3.142



u = r * cos(a + r) // 320
v = r * sin(a + r) // 320



u = a
v = 1.0 /* r



Also, the whole program includes those 5 scenes and is only 1354 bytes. So it can be done very lightly.

To use it, just put a number between 0 and 5 inclusive in Ans before running Asm(prgmPLDEFORM). You need at least 13800 bytes of free RAM though. No test is done to see if Ans is out of bounds, but that shouldn't do anything else than displaying random garbage. Binaries attached, source will come later (when cleaned).

I'm going to make everything more ergonomic and release it as a pure eye-candy program I guess (among with some additional equations).
« Last Edit: January 23, 2014, 01:05:10 pm by Matrefeytontias »

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: [Axe] Plane deformations are fun
« Reply #1 on: January 23, 2014, 01:25:23 pm »
That's what I initially used for my Nspire Mode 7 engine, but I moved on to faster methods. For the mode 7-type plane, the derivative of the coordinates between pixels on the same row of the screen is constant, so you can just add a constant vector to the coordinates for a pixel to get the coordinates for the next. It's not as easy when you get into using trig functions, but you could keep the values of sine and cosine, and add them to each other to quickly and dynamically compute their values, though this probably won't work out so well with the limited precision you have.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: [Axe] Plane deformations are fun
« Reply #2 on: January 23, 2014, 01:41:16 pm »
I already draw the scenes in the fastest way possible ; I push bits into A and when I did that 8 times, I store A to a byte in plotSScreen. This is faster than Pxl-On. The problem is that you can't actually do much faster in Axe (or maybe I'm missing something huge).

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: [Axe] Plane deformations are fun
« Reply #3 on: January 23, 2014, 02:38:23 pm »
wow, just wow, that is just looking too awesome :P (and yes, it is useless, lol :P)

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: [Axe] Plane deformations are fun
« Reply #4 on: January 23, 2014, 02:50:17 pm »
Of course it's useless :P its only point is to look good x) and be as fast as possible (actually, not very fast).

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [Axe] Plane deformations are fun
« Reply #5 on: January 23, 2014, 09:37:53 pm »
Woah that looks great! :O Also, screenshot 2 gave me some ideas since the tiles were from supersonic ball, but of course I would need to learn how to do mode 7 (and have it run fast) on the HP Prime. :P

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: [Axe] Plane deformations are fun
« Reply #6 on: January 23, 2014, 10:24:52 pm »
If you need help wrapping your head around Mode 7, just ask. None of the explanations I found on the internet made sense to me, so I struggled with it for a while.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [Axe] Plane deformations are fun
« Reply #7 on: January 23, 2014, 11:20:01 pm »
Ok I'll ask in due time. Mac Bernick made something looking similar to Mode 7, but I didn't check his code yet and it seems to lack support for horizontal scrolling (it just goes straightforward).
« Last Edit: January 23, 2014, 11:21:48 pm by DJ Omnimaga »

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: [Axe] Plane deformations are fun
« Reply #8 on: January 24, 2014, 10:40:44 am »
Woah that looks great! :O Also, screenshot 2 gave me some ideas since the tiles were from supersonic ball, but of course I would need to learn how to do mode 7 (and have it run fast) on the HP Prime. :P
Oh I didn't notice that :P

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Re: [Axe] Plane deformations are fun
« Reply #9 on: January 24, 2014, 11:09:20 am »
Actually now that I think about it, some Supersonic Ball tiles were taken from The Reign of Legends 3 and Metroid II Evolution :P

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: [Axe] Plane deformations are fun
« Reply #10 on: January 26, 2014, 09:47:47 am »
This does look awesome Matref! ;D Damn shame it isn't a bit faster though. :/
« Last Edit: January 26, 2014, 09:47:58 am by Art_of_camelot »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: [Axe] Plane deformations are fun
« Reply #11 on: January 26, 2014, 09:56:09 am »
That really does look cool! Is there a source? If I ever get free time, I might want to look into optimizing it with assembly or something.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: [Axe] Plane deformations are fun
« Reply #12 on: January 26, 2014, 11:03:00 am »
This does look awesome Matref! ;D Damn shame it isn't a bit faster though. :/
I swear I tried to make it fast though :/ I don't think there's much to be done about it in Axe.

That really does look cool! Is there a source? If I ever get free time, I might want to look into optimizing it with assembly or something.
I'm sure you can make it at least twice faster with ASM, because if I had to make the drawing code in C it would be (direct translation from Axe) :
Code: [Select]
for(y = 0; y < 64; y++)
  for(x = 0; x < 96; x++)
    plotSScreen[y * 96 + x] = texture[ (ylut[y * 96 + x] & 7) * 8 + xlut[y * 96 + x] ];

Lemme get on my PC and I'll attach the source.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: [Axe] Plane deformations are fun
« Reply #13 on: January 26, 2014, 12:01:55 pm »
Okay, cool, thanks!

Offline ClrDraw

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 627
  • Rating: +61/-2
    • View Profile
    • GitHub
Re: [Axe] Plane deformations are fun
« Reply #14 on: January 28, 2014, 11:21:05 am »
The third one...  O.O that's crazy.
Visit my GitHub for all my TI programs as well as other projects.
Also check out my website.