3D engine... Much interest?

Bingo!

My original understanding of UV mapping was indeed wrong, but it doesn’t matter. @StarCrunch your link to the psx_retroshader turned out to be all I needed! Down at the bottom of that page is a screenshot that confirmed the results I was seeing are to be expected and that more triangles is all that’s needed, so I went with it. My cubes now consist 24 triangles per face, which is enough to both fix the checker map, AND add the perspective that I was hoping this number of UVs would give me. Perfect!

I’ll do a proper video of this running on Android, but for now https://development.qweb.co.uk/test4/

Not sure how well a HTML build of this will run… it seems fine for me, but in general the HTML builds never perform as good and this is now a 576 poly scene (48 each for the 3 cubes directly in front of the camera, 72 each for the other 6 because off-screen faces still aren’t culled yet). That front cube should rotate half a degree every 20ms, which is about one full rotation every 14.5 seconds.

There’s definitely room for optimisation in this now so if it’s already performing well enough for people in general, then that’s fantastic.

yeah HTML performance is shit compared to proper builds but seems you’ve fixed the UV issue.  Good job mate!

@richard11 Ah, great. Totally unintentional hint, but I’m glad it helped.  :smiley:

Exactly the same as the HTML build, but here’s an APK demo for Android users that properly shows the render quality and performance, even while totally unoptimised: http://development.qweb.co.uk/3D%20test.apk

And a screenshot for non-Android users:

the texture mapping itself is still affine, not perspective - but if no-one besides me notices then who cares?  the additional subdivision is enough to approximate it well enough at this scale.  perhaps you could make the degree of subdivision variable, in case someone needs significantly larger faces (fe, try a single cube at 9x scale in place of the 9 at 1x, would artifacts return yet?  at 16x?  etc)

The engine will eventually include functions to add all the basic shapes - cube, sphere, cone, pyramid, etc - but also a function to import .obj models, which would obviously mean proper control over UVs etc. There’ll likely also be an ability to edit object data on the fly, so it’d be possible to create something like a cube and then replace a particular side to have more vertices.

I think this is a target to aim for - https://www.youtube.com/watch?v=ZVylCqhs5B8.  Not sure if it is possible?

Or maybe more simple like - https://www.youtube.com/watch?v=0UaIKlpiOZg

Or - https://www.youtube.com/watch?v=XRgU1USrohQ

I think they’re all achievable =). Although that second one looks to be 2D sprites just being enlarged as they get closer to… potentially. Hard to tell at that speed!

The only bit that worries me now is shadows. It’d be great if I can make those work without killing performance but I’m a fair way off being able to get stuck into that I think…

Pushes Corona into new territory!

This might need core integration for render speed?

Into a new dimension really ;-).

This has become a weekend project now. I finally managed to drag myself back off of it to get some of our more important projects progressing, so updates might be a little slow now until it’s complete enough to hit the marketplace. Of course, at that point if the response is positive I’d be able to put more priority towards it again.

Anyway, to update, I’ve added in a bunch of the fundamental functions that make this more of a useful engine now, incorporated most of the general code optimisations that I’d been meaning to add (use of locals etc), added in an adjustable draw distance, and started documenting the existing functions.

I’ve come across a strange bug where if you rotate the camera so that it faces approximately 90 degrees away from an object, the rendering goes totally crazy… I was hoping to get some higher quality video demos online by now but this bug needs squatting first.

Ambient lighting and positioned lights are next on the list. Contrary to my earlier posts, I’ve even now conceptualised a method for casting shadows that might actually work reasonably well and with minimal overhead, but this will need to come later on…

Still need to better optimise the way vertices are defined and introduce more shapes than just the cubes, plus an obj import mechanic so that 3D models can actually be dragged in for rendering. And I still need to implement off-screen culling + probably re-think the way objects in the world are stored, for more efficient iteration of just the relevant area.

Oh, and there’s still intersecting faces to figure out. That’s the biggy.

Ambient lighting works =)

https://youtu.be/O4-dgfAVXpU

And an Android APK demo for anybody who wants to see it in actual quality… Seems the video recording left some odd artifacts annoyingly…

https://development.qweb.co.uk/3D%20test.apk

Wow! I am impressed. 

Yeah this is amazing stuff

Thanks. Those older screenshots look strangely pathetic now - amazing how much depth a bit of light can add.

Still a fair way from being a complete engine and still too early to benchmark lots of objects, but it’s definitely feasible to make at least simple games with 3D visuals using it.

Often when I’m creating something, my friends ask me: “But, why?”, to which the answer is usually a mix of “because I can”, “because I want to see if I can”, or “because It’d be cool”. 

Now, even I am thinking: “Why create 3D object rendering and lighting in Corona, a 2D game engine, when there are fully fledged 3D game engines out there?”, but in the back of my mind I already know… because it’d be cool and because you can :smiley:

Pretty much =)

This started as an itch more than anything else. We don’t have any games in the pipeline that it needed to be built for, but if we’re asked to do something in 3D I’d prefer that Corona was an option for that, and more often than not the bloat of a fully fledged engine like Unity is unnecessary. Of course, if we’re asked to do something huge in 3D, this is unlikely to ever be the better option.

Hopefully though, once ready for release it’ll be useful enough to at least some of you, and not just an interesting concept…

Well if a 3D engine can hack 2D why not the other way around?

You may have mentioned this at some point, but does the engine (or will the engine) support loading custom 3D models created in Blender, for instance. If I were to create some basic models consisting of 20-30 or even 100 polygons, would the engine be able to support them?

It’ll be able to import .obj files eventually, which Blender can export. They’re plain text so should be easy enough to use.

Although the engine only has cubes at the moment, the actual rendering doesn’t care what the shape is. It’s literally just that I haven’t mapped out the vertices for anything else yet.