Full 3D Proof of Concept


nathanielbabiak 2021-12-28 13:30 (Edited)

Just a quick update on this.

There's plenty of speed for 10 polys at 20 to 30 fps (so the math was right, not a surprise). I've got 12 polys at 30+ FPS, plenty of speed remains for the skybox, plane, and game. There's still a page-flip bug (commented-out on line 103). If fixed, the program would run faster in cases when the CPU isn't max'd out.

Arrow keys adjust camera/object/projection settings, hold A, B, or A+B to change what's adjusted. Angles are degrees... I'm not yet sure what the units are for position X/Y/Z adjustments, because the z-position changes dynamically with adjustments to field-of-view.

On line 17 you can adjust the test from 3D to 2D. For that one, use touchscreen and keyboard 'C' and 'R'. Even the 2D test is improved from the last one.

As before, there's still two pre-calc arrays I'm not super-comfortable with. They're 16k and 20k elements each. I think it breaks the spirit of LowRes NX, but I've left them in for speed to save a few clock cycles.

star3D 2021-12-29.nx | Open in app
2021-12-29 06:17
star3D 2021-12-28.nx | Open in app
2021-12-28 13:30

McPepic 2021-12-28 15:27

Thanks so much for sharing! I’m super excited about this project and can’t wait to see what comes of this. Keep up the good work, Nate! (I’m not entirely sure how this works, so I’ll just have to look over the code some more to understand it)

G-9 2021-12-28 16:21 (Edited)

whoah truly amazing

was8bit 2021-12-28 16:26

( ◠‿◠ )

nathanielbabiak 2021-12-28 17:21 (Edited)

Thank you all!


The display driver ("sprite expansion") is described here in the three paragraphs containing "technique" (use CTRL+F).

The upload here is kind'a similar, although I intend a few significant differences.

nathanielbabiak 2021-12-29 06:30 (Edited)

Today's upload rasterizes triangles crazy-fast, pixel-perfect, and with screen clipping. This proof of concept is actually faster than predicted by my initial estimates.

Perspective projection (3D) is next. I've been thinking about using LowRes for old-school projection for two years, ever since I uploaded this. At the time, I was planning a game in the style of 1984's Elite Dangerous using the Pxl Library, but that display driver is just too slow.

The rotation, projection, and HSD (hidden surface determination) code is actually written already, just not imported, checked, or optimized.

More to come...

nathanielbabiak 2021-12-29 06:39 (Edited)

Ultimately, I'm hoping others might take attempt developing in 3D also. Towards that goal, here's a quick write-up. My next upload will do all this, but the narrative just makes it easier to follow along.

(There's two separate topics that won't be addressed here: rotation and projection. For rotation, I'm not sure yet if matrices or quaternions will be faster.)

Super-simplified Hidden Surface Determination

Objects are made of triangles. The goal is to determine which triangles to draw, which to skip drawing, and how to layer them on-screen overtop one another.

  1. Only allow rigid objects. For example, an airplane could have wings, but the control surfaces would not move.

  2. Group the triangles of a single object together, and clip entire objects (groups of triangles) if the whole object is off-screen. (Don't attempt to predict if individual triangles will be clipped. LowRes is pretty slow, so the best we can hope for is something looking like 1993's Star Fox. LowRes is too slow for full scenes, so just don't worry about it.)

  3. Limit all objects to convex polyhedron. These polyhedron have a special property: their triangles facing towards the camera get shown, their triangles facing away from the camera don't, and their triangles never overlap.

  4. Perform back-face culling (the determination of which surfaces are facing away from the camera). With your mind's eye, imagine viewing each triangle from the outside of the object, then order the three points of the triangle counter-clockwise (X1,Y1,Z1), (X2,Y2,Z2), and (X3,Y3,Z3).

  1. For multiple objects on-screen simultaneously, pre-calculate each object's centroid (BX0,BY0,BZ0). At runtime, rotate/translate during step 4.3 above to get (BX,BY,BZ) relative to the camera, then use the painter's algorithm to draw objects layered farthest to closest by their BZ value.
  1. Convex polyhedron are boring, but they can be decorated, by way of an example... Imagine a 3D satellite floating in space. It's just a cube (a convex polyhedron), but it's got an antenna anchored perpendicular to a triangle facing outwards and it's got a dot (pixel pattern) anchored on another triangle facing outwards.

That's everything! Basically just keep track of the different types of coordinate triples and you'll be good-to-go.

moechofe 2022-01-01 22:24

good stuff

nathanielbabiak 2022-01-05 06:02 (Edited)

Today's upload implements #1 through #4. For rotations, ultimately matrices were faster, they're shown in the M_ROTATE_xxxx subprograms. For projection, that's shown in M_PROJECT_DRAW.

LowRes isn't fast enough to multiply homogenous 4x4 matrices, so I couldn't copy-paste the code from legacy OpenGL. I was forced to cobble together a state machine using 3x3 matrices instead (I still referenced legacy OpenGL tutorials to get the math right, but it was much harder than I expected!)

More to come...

Mrlegoboy 2022-02-09 19:04

this is way better than anything previous. i wish i never got an android so i could do something with this.

GAMELEGEND 2022-04-08 05:25 (Edited)

woah woah hold on there Mrlegoboy

just take a look at this https://lowresnx.inutilis.com/topic.php?id=2323#post-16194

i got the linux version of lowres running on my android device and these are the steps

the best part is is that works on a non rooted device

Log in to reply.