Join us on Discord!
You can help CodeWalrus stay online by donating here.

X3D - A 3D engine for TI68k & Nspire Calculators

Started by catastropher, June 27, 2015, 02:37:43 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

catastropher

Earlier this year I posted on Omnimaga about X3D, my 3D engine for the 68k calcs. After a month hiatus for health reasons, I resumed work on it in May :D Some of you may recall the dazzling light bridge from earlier this year:



Currently, I am in the process of rewriting the engine to support more complex geometry. It's been a long and slow process (I'm currently interning full time as a software engineer), but I've started to make some progress. The last version had levels which were constructed of interconnected cubes. The player could walk around inside the resulting structure, which proved to be very efficient. However, my whole goal of starting X3D was to get Descent to run on the 68k calcs, and many rooms in Descent are constructed of 20 or more cubes, which is just too much to handle. So, this new version will allow levels to be constructed of prisms instead of just cubes. What do I mean by prisms? Here's an example of an octagonal prism:



The idea is you have two bases, each with the same number of points. However, the bases can be stretched, skewed, and rotated, so long as the resultant 3D shape is convex. My ultimate goal for Descent 68k is to merge the cubes in complex rooms into large convex prisms. This is several times more efficient to render than the same room partitioned into cubes.

So far, I have created a new clipping algorithm that clips prisms against a 2D polygon. A fast algorithm for this is crucial for a portal renderer like X3D. So far so good!



Anyway, this time around, it's going to have a lot of cool features. I'm hoping to get some people involved on the project or at least make some games with it once complete (it will be a TIGCC/GCC4TI C library). Let me know if you're interested!
  • Calculators owned: TI-83+, TI-83+ SE, TI-84+ SE, TI-Nspire CX, TI-92+, TI-89 Titanium
Creator of X3D, a 3D portal rendering game engine for Nspire, 68k, and PC

CKH4

Holy cow thats impressive. This looks great. Maybe we'll get some cool 3d stuff.
  • Calculators owned: TI-83+, TI-84+


catastropher

Hey thanks! I may even write a scaled down version in Z80 assembly if I can get it fast enough. Unlike most 3D renderers for the calculators, X3D only ever draws lines for the level geometry. Thus, everything is solid without filling any polygons. This makes it really really fast :D I may also write a tutorial on how to do this type of rendering as it's a bit involved and I'd really like to teach other people all the techniques I've found or discovered myself.
  • Calculators owned: TI-83+, TI-83+ SE, TI-84+ SE, TI-Nspire CX, TI-92+, TI-89 Titanium
Creator of X3D, a 3D portal rendering game engine for Nspire, 68k, and PC

CKH4

So are the things solid? I'm confused by the third screenshot.
  • Calculators owned: TI-83+, TI-84+


catastropher

Yup things are solid, it's just easier to work in wireframe as I'm developing the clipping algorithm :D
  • Calculators owned: TI-83+, TI-83+ SE, TI-84+ SE, TI-Nspire CX, TI-92+, TI-89 Titanium
Creator of X3D, a 3D portal rendering game engine for Nspire, 68k, and PC

CKH4

So instead of polygon filling you just don't draw the lines that are covered up?
  • Calculators owned: TI-83+, TI-84+


catastropher

Exactly! To achieve this, I use a modified version of portal rendering. Pretty much, you have a 3D polygon that is your portal (such as a doorway). Through this portal you clip any lines against the portal. So longs as your rooms are convex, you can draw them in any order and it makes things solid! Suppose we have this level (the camera is blue and the portal is colored orange, also please forgive my mspaint skills and crappy 3D drawing skills :P):

Basic Portal Rendering


Suppose you were rendering this scene in wireframe from the perspective of the camera. What do you think you'd see? Something like this (the portal is still orange and the red lines are those outside of the portal):



Now, just clip out the lines outside your portal polygon and viola, you have a solid rendering of both rooms!



Obviously, the process is much more complex (especially when multiple rooms are visible, geometry is behind the camera, etc) but that's the general idea. The most expensive part of rendering is the clipping. But, with it in place we don't have to do any Z-sorting or polygon filling! :D
[close]
  • Calculators owned: TI-83+, TI-83+ SE, TI-84+ SE, TI-Nspire CX, TI-92+, TI-89 Titanium
Creator of X3D, a 3D portal rendering game engine for Nspire, 68k, and PC

CKH4

But with this method you would theoretically have to split up some lines right? In your diagram you have that but what do you do to accomplish it?
  • Calculators owned: TI-83+, TI-84+


Dream of Omnimaga

That really looks impressive Catastropher. Thanks for sharing this project. I am curious about what kind of game could be done using this engine. :)

Also sorry about your health issues. I hope it's nothing too bad.
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

catastropher

Quote from: CKH4 on June 27, 2015, 05:05:09 AM
But with this method you would theoretically have to split up some lines right? In your diagram you have that but what do you do to accomplish it?

Indeed you do. There are a few different algorithms to accomplish this. The canonical polygon clipping algorithm is Sutherland-Hodgman (https://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm). For a prism, you'd have to clip each polygon separately (a prism has n + 2 polygon, so for an octagonal prism you'd have to clip 10 polygons) and then draw the visible edges after clipping. Worse, it has a time complexity of O(n^2), and you're running it for each polygon. I'm working on a better algorithm for prism clipping, but I'm still working out all the details. I'll make a post when it's done :)

Quote from: DJ Omnimaga on June 27, 2015, 05:29:24 AM
That really looks impressive Catastropher. Thanks for sharing this project. I am curious about what kind of game could be done using this engine. :)

Thanks! I hope people will get interested in it and make some cool stuff! But I'm still developing the core, so it may be a bit before it's ready.

Quote from: DJ Omnimaga on June 27, 2015, 05:29:24 AM
Also sorry about your health issues. I hope it's nothing too bad.
Thanks for the concern, that's really nice of you :) It's nothing too bad, just some rheumatoid arthritis that flares up every once in a while (yup, I have it at 20 :()
  • Calculators owned: TI-83+, TI-83+ SE, TI-84+ SE, TI-Nspire CX, TI-92+, TI-89 Titanium
Creator of X3D, a 3D portal rendering game engine for Nspire, 68k, and PC

Lionel Debroux

Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TIEmu and TILP.
Co-admin of TI-Planet.

Snektron

Whoa, awesome! So how good does this compete against glib for example?
Also i thought Portal used FrameBuffers and all that advanced stuff for portals :P
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


TheMachine02

Quote from: Cumred_Snektron on June 27, 2015, 09:49:44 AM
Whoa, awesome! So how good does this compete against glib for example?

You should note that the screen is a 68K screen  :P  It hasn't been writed for z80 yet.

Also, I did try that few year ago on z80, it worked, (1 portal bring down the whole scene to about 9 fps) but the main issue that I encounter is that the cliping is a very expensive method to use on z80 (that is, no div or mul command), and should be evited. But it is still definitly doable.

Duke "Tape" Eiyeron

I'm amazed at the speed and the quality of the screenshot you gave us. 3D untextured solid? Collisions? Cinematics? Mazette!
  • Calculators owned: A lot.

Snektron

Next thing you know someone made Assassins Creed Unity for calculators :P
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Powered by EzPortal