• nGL - a fast (enough) 3D engine for the nspire 5 4
Currently:  

Author Topic: nGL - a fast (enough) 3D engine for the nspire  (Read 240613 times)

0 Members and 1 Guest are viewing this topic.

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #90 on: February 23, 2014, 11:08:36 pm »
The problem with the texture atlases is that you can't wrap the coordinates, which will eliminate all the out-of-texture-bounds artifacts you are getting. An optimization to the switching textures problem would be to group the triangles with each texture together.
Consider the following atlas:
AABB
AABB
CCDD
CCDD
It would get stored as AABBAABBCCDDCCDD. An array would get stored AAAABBBBCCCCDDDD - all the information for each individual texture is together in memory. I don't actually know how big the cache is in the Nspire's CPU and whether it would make a difference, but it can't hurt.

Another thing that might help is to set GCC to the highest optimization level if you haven't already.
« Last Edit: February 23, 2014, 11:11:47 pm by fb39ca4 »

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #91 on: February 24, 2014, 08:57:00 am »
Quote
The problem with the texture atlases is that you can't wrap the coordinates, which will eliminate all the out-of-texture-bounds artifacts you are getting
No, it won't. It would just look different!

Quote
Consider the following atlas:
AABB
AABB
CCDD
CCDD
It would get stored as AABBAABBCCDDCCDD. An array would get stored AAAABBBBCCCCDDDD - all the information for each individual texture is together in memory.
Could work, but wouldn't make a huge difference. 2*16*16 = 512 Byte, no problem for the cache to store multiple textures.

Quote
Another thing that might help is to set GCC to the highest optimization level if you haven't already.
My flags: -O3 -Wall -W -marm -ffast-math -mcpu=arm926ej-s -fno-math-errno -fno-tree-vectorize -fomit-frame-pointer -fno-exceptions
any suggestions?

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #92 on: February 24, 2014, 01:48:16 pm »
It's weekend again, so some more progress:
  • Replaced terrain.png with original terrain.png from Minecraft (Copyright Mojang AB)
  • Trees
  • Infinite world generation (The trees are the only thing changing for now)
  • Faster startup (cos uses sin_lut)
  • Faster

With textures it's smooth now also with some more blocks visible (~25 fps):


I had to use imgur for that one as I couldn't upload it to img.ourl.ca.
The file was probably too large and every file I try to upload now (name doesn't matter)
doesn't get uploaded and it shows "crafti_world.gif" (the old file name!) was uploaded successfully and a 404 NOT FOUND next to it...

Without textures we can expand the viewable distance a bit further and we get to ~11 fps:


But for comparision fps-wise with the same distance as with textures above (~40 fps):


Known bugs:
-Weird lines if textures enabled
-Sometimes a triangle hitting the right screen border shows random data if textures enabled
-Sometimes it displays garbage if perfectly aligned to Z axis
Woah, if you or someone else can pull off a Minecraft game running this fast, this will be an HUGE milestone for the TI-Nspire and I bet this would be quite popular too. I am particularly amazed at how fast it runs even with textures and such viewing distances. The non-textured version with short view distance still looks very nice too, though. O.O

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #93 on: February 25, 2014, 01:16:33 am »
Ok, looks like you have already turned them on.

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #94 on: February 25, 2014, 11:16:55 am »
Is this demo optimized for cubes or will it run as fast when it's smooth terrain with the same amount of vertices?
« Last Edit: February 25, 2014, 11:17:09 am by Keoni29 »
If you like my work: why not give me an internet?








Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #95 on: February 25, 2014, 12:29:03 pm »
Quote
Is this demo optimized for cubes
Kind-of. I generate a list of Positions (x,y,z) and a list of IndexedVertices (a reference to a position, a color and uv-coordinates).
As it's likely that a position is used multiple times (flat area: each position 4 times), I don't have to transform it more than once.

But as "transformation" also includes perspective, I can't do z-clipping before perspective projection, which is bad
as divisions / 0 or a really small value can happen. And they do happen if I increase the cube size or the camera is in a bad spot.
I'll have to fix this, although it may get slower. I don't know what dominates here, the few "perspective divide"s I don't have to do because of z-clipping
or the "perspective divide"s I will have to do because of z-clipping (If you know what I mean)

Quote
will it run as fast when it's smooth terrain with the same amount of vertices?
It depends on how much triangles are visible. The "benchmarks" I performed earlier in this thread were totally wrong as my line drawing is slooooowwww.
Even slower than triangles. I don't now how I did that...


Offline mdr1

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 303
  • Rating: +21/-2
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #96 on: February 27, 2014, 03:01:11 pm »
It is really great! But it only makes my calculator crash... =/
It is a TI-Nspire CX CAS. Crashes when I launch it.



Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #97 on: February 27, 2014, 03:03:04 pm »
That's weird. Which version of ndless and crafti are you using?

Offline pbfy0

  • LV2 Member (Next: 40)
  • **
  • Posts: 31
  • Rating: +7/-0
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #98 on: February 27, 2014, 04:43:35 pm »
I'd like to try this, but it also causes my calculator to crash.
I have a nspire CX CAS and i'm using ndless 3.1 r914 and crafti 0.3. I'm using Nlaunchy to dual boot with OS 3.6, if that matters.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #99 on: February 27, 2014, 04:51:36 pm »
I'm testing on the emulator under the exact same conditions. My calc currently runs on OS 3.6 and switching just takes so long...
Could you try this version?

Offline pbfy0

  • LV2 Member (Next: 40)
  • **
  • Posts: 31
  • Rating: +7/-0
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #100 on: February 27, 2014, 05:00:37 pm »
No, it still crashes. Sorry.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #101 on: February 27, 2014, 05:02:25 pm »
You don't have to apologize ;)
I'll try it on my calc tomorrow.

Offline mdr1

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 303
  • Rating: +21/-2
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #102 on: February 28, 2014, 09:33:36 am »
Sorry, it crashed because I had ndless r877. With the r914, it works, but after a short trip, the calculator crashed. I don't have nLaunch. I'm using crafti 0.3.



Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #103 on: February 28, 2014, 10:00:46 am »
Maybe adding some assert_ndless_rev() would prevent crashes on old Ndless versions?
Ndless.me with the finest TI-Nspire programs

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #104 on: February 28, 2014, 10:46:32 am »
I went through the code again and found a call to vprintf in my substitute to the irq-disabling printf...
I'll upload when I'm done with a better clipping algorithm and nicer perspective calculations.
Both should result in fewer artifacts and crashes, if they were related to drawing across the screen borders and thus overwriting some innocent memory which didn't seem to hurt the emulator.
« Last Edit: February 28, 2014, 10:46:43 am by Vogtinator »