The shoutbox is currently out of service. Join us on Discord instead.
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 1 Guest are viewing this topic.

catastropher

June 27, 2015, 02:37:43 am Last Edit: February 11, 2016, 08:38:16 pm by DJ Omnimaga
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!
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.


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.
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.


catastropher

Yup things are solid, it's just easier to work in wireframe as I'm developing the clipping algorithm :D
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?


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: ShowHide


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
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?


DJ 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.

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 :()
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
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!

Snektron

Next thing you know someone made Assassins Creed Unity for calculators :P
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Powered by EzPortal