The Daily Click ::. Forums ::. Digital Works ::. Experiments with voxels...
 

Post Reply  Post Oekaki 
 

Posted By Message

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
23rd January, 2014 at 23/01/2014 16:58:47 -

While I generally don't think MMF2 is at all well-suited to making 3d games, I though it would be interesting to experiment with some ultra low resolution 3D voxel models, just for a bit of fun.

First things first - I needed a model to work with, and so I made this little Sopwith biplane, just like in the classic game "Sopwith", but in glorious technicolor and 3d:

Image

To start with, I just followed the ingenious article here: http://www.create-games.com/article.asp?id=1933
I was actually quite happy with the results I got, using just low quality rotation and no anti-aliasing:

Image

Unfortunately, the problem with this method is that although the model looks 3d, it can only rotate about one axis - which is going to seriously limit the kind of aerobatic manoeuvres our little Sopwith is capable of.

So, the next thing to try was storing the position of every single pixel (or "voxel" rather, since we're talking 3d now!), and doing complicated rotations on them.
Normally, when people use voxels, they're actually using proper cubes - but that would be an awful lot of work, so instead I'm just using individual pixels. That could have presented problems, since a pixel is a fixed size, and things generally get smaller the further away they are, so to get around this I'm using a parallel projection (like with isometric graphics) where there is no perspective and foreshortening.

Visually speaking, the results were not great, but if you squint, you can just about tell it's meant to be a plane:

Image

Unfortunately, even a tiny model like this contains a whopping three hundred voxels, and when you're doing complex 3d calculations on 300 points each frame, that doesn't make for good performance - by which I mean the framerate dropped to 10fps.
I'm sure there are ton of major optimizations I could make that would improve performance, but it's probably never going to be fast enough to use in a game. The one thing that might make a big difference would be to use a scripting extension such as Lua.

The last thing which I haven't tried yet, but feel might be worth a shot, would be to use the first method (the one in the article by 3kliksphilip), but combine that with hardware accelerated scaling / stretching of the individual slices, to give the impression of true 3d rotation. That way, my Sopwith model would be made from just 9 slices instead of 300 voxels, and the complex rotation maths could be handled by the graphics card.

Anyway, just thought I'd share what I've been up to...

 
n/a

Pan-tosser



Registered
  24/10/2008
Points
  520

Has Donated, Thank You!
23rd January, 2014 at 23/01/2014 18:40:49 -

That is to cool. Sketchy your like some sort of media fusion evil genius. The 3d model reminds me a lot of fez



 
https://www.facebook.com/nathon.brown.7

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
23rd January, 2014 at 23/01/2014 21:01:52 -

Thanks, and yeah, I saw Fez in "Indie Game: The Movie", but I've never actually played it - I do like the graphical style though

 
n/a

Pan-tosser



Registered
  24/10/2008
Points
  520

Has Donated, Thank You!
23rd January, 2014 at 23/01/2014 23:30:59 -

Watching that movie is the same place i found out about fez. And I have come across a lot of people who found it the same way. Makes me wonder just how many people here have netflix accounts ...lol

 
https://www.facebook.com/nathon.brown.7

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
24th January, 2014 at 24/01/2014 00:22:56 -

I don't have a netflix account - just saw it on regular TV a few months ago.

 
n/a

Alonso Martin



Registered
  29/12/2010
Points
  294
24th January, 2014 at 24/01/2014 02:58:36 -

This is pretty neat! I do figure it's very taxing to calculate positions for every pixel in 3 dimensions. Couldn't you do this with a shader instead and just skew the textures? It wouldn't really be volumetric, but it would achieve the same effect you've got there, at that scale. Or is it that it was intention to make a voxel/3dpixel based engine?

If so, it would be interesting to see if you can translate this to the surface object, or even the textblitter. I guess the textblitter would be faster since all the blitting happens in c, and you'd be able to use the callback functions to place characters bigger than 1x1 on the surface. Don't know exactly how the z-layering would work, though, since all characters are rendered from left to right and top to bottom.

Anyway, pretty interesting! I'd love to see where you go with this.

Edit: Actually, it would be 100x better to do that with a shader, if one exists that's basically a reproduction of the surface object in HLSL. At least one with which you can draw textures, or just shapes/vertices.

Edited by Alonso Martin

 
www.hfalicia.com
www.alonsomartin.mx

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
24th January, 2014 at 24/01/2014 18:17:30 -

The surface object has a callback function and is actually pretty fast - the bottleneck at the moment is all the calculations. I can remove the drawing events altogether, and it only raises the framerate by around 2fps.

The aim is to create a true 3D voxel engine, so simply skewing one image wouldn't cut it. If someone wanted to make a Fez clone though, that would be easy and fast using shaders.

Shaders might still have potential, but I can think of a few problems. It would be nice if the whole plane could be made from one object, with each of the slices as a shader image parameter. Unfortunately, I don't think MMF2 supports multi-pass shaders, which would make this impossible (no way to handle depth sorting).
Even if it were possible, if there were multiple voxel objects in a frame, it wouldn't be possible to sort them correctly (imagine a voxel landscape, where the nearest part is in front of the plane, and other parts are behind it), and you'd still need some way to handle collision detection, etc.

Really, I think the main reason it's slow (apart from being badly coded) is that MMF2 lacks any suitable data storage object - that's why I'm confident a scripting extension would make a big difference, and is probably what I'll be trying next. In fact, I might just ditch MMF2 for a while, and see what kind of performance I get using Javascript and the canvas element, since I don't remember Lua any more...

 
n/a

nim



Registered
  17/05/2002
Points
  7233
24th January, 2014 at 24/01/2014 23:47:57 -

Sketchy, this is amazing! I love seeing pseudo-3D effects. Reminds me of early 16-bit games.

I'd also be interested in the voxel editor you probably had to make to build that plane in 3D.

 
//

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
25th January, 2014 at 25/01/2014 01:48:01 -

Thanks, and no, it's not exactly cutting edge technology (unlike some voxel-based engines: http://www.atomontage.com/?id=gallery ).

I don't really have a proper editor yet - just a tiny and very ugly app that scans an image and writes the coordinates & color of every pixel. I'll definitely need to make a better one before I move onto larger models.

Anyway, as promised, I've made an all Javascript / Canvas version, and it runs a *lot* more smoothly than the MMF2 version:

Image

You can try it for yourself here: http://sdrv.ms/1aTwaAp (click "download" at the top; best viewed in Opera 12 - it looks bad in Chrome, as I haven't been able to disable anti-aliasing when scaling the canvas)

Edited by Sketchy

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
25th January, 2014 at 25/01/2014 13:12:14 -

Getting a bit more ambitious now - starting with this 2d sprite I did a while back:

Image

...and 3600+ voxels later:

Image

HTML file download: http://sdrv.ms/1mW2c70


Edited by Sketchy

 
n/a

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
25th January, 2014 at 25/01/2014 13:38:05 -

You can render your GFX with this voxels engine, come up with a dozen or so different explosions and whatnot for the player and enemy planes (AND the enemy cow), then use the graphics in MMF2 to build your Sopwith clone.

Truly visionary stuff here Sketchy, as always.

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
25th January, 2014 at 25/01/2014 21:38:14 -

I was thinking that too - it would be handy for animating barrels rolls and maybe the odd cutscene. I'd quite like to make an HTML5 game anyway though. And of course, if you want to just pre-render voxel graphics, there are already good editors out there.
Anyway, I've just started on a course (with a *lot* of homework), so my time is likely to be rather limited for the next little while, and I probably won't be doing much of anything.

 
n/a

Jenswa

Possibly Insane

Registered
  26/08/2002
Points
  2722
26th January, 2014 at 26/01/2014 17:09:57 -

That looks nice Sketchy and is cool in canvas. Too bad MMF2 is slow at it.

Chrome isn't the best browser for displaying (manipulated) pixel art, others are better like Firefox.

 
Image jenswa.neocities.org

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
27th January, 2014 at 27/01/2014 01:58:20 -

I still think MMF2 will be able to handle it via a scripting extension - it's really just the lack of sortable multi-dimensional arrays that's causing problems.

Firefox is soooo slow. Opera 12 is the best of both worlds - the speed of Chrome and the scaling options of Firefox. It's such a shame they ruined it by switching to webkit.

Are you still dabbling in HTML5 games? I learned a lot from your articles on the subject.
I'm finding non-accelerated Canvas a bit slower than I would like, so I'm considering making the move to WebGL, but it looks crazy complicated, requiring lines and lines of code even for the very simplest of tasks, like drawing a square.

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
27th January, 2014 at 27/01/2014 17:12:02 -

Grrr... stupid image host

Well, I've tried the MMF2 & Lua combo...
I'm getting 300+ FPS with just the small Sopwith model, which is pretty good - but it's dropping to just 45 FPS with the larger Hellcat

What I'm now thinking, is that the original Sopwith game only ran at a very low framerate (something like 15 FPS iirc), so maybe I could create kind of a 3D clone (maybe even with CGA graphics).

 
n/a

Jenswa

Possibly Insane

Registered
  26/08/2002
Points
  2722
27th January, 2014 at 27/01/2014 20:02:46 -

I see imagehost isn't being nice towards you at the moment.

Yes still coding in html5/js, at the moment I working on the same demo for html5/js, TGF and the gba.

I am in the progress of moving towards webGL too, it does add some overhead but it gives a rather nice speed boost.

Isn't there some kind of array object which you can use to boost speed? Three 1D arrays for example?

Cheers and keep up the good work

 
Image jenswa.neocities.org

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
28th January, 2014 at 28/01/2014 17:06:35 -

Ah, well if you ever find a simple way to do stuff with WebGL, feel free to write another article...
Even the simplest example I could find (doing nothing more than drawing a triangle and a square) was pretty long - http://learningwebgl.com/blog/?p=28
I don't want to use a library, and I'm actually still only really interested in using it for 2d stuff.

Anyway, I've nearly finished a B24 Liberator, to go with the Hellcat:
Image

 
n/a

Jenswa

Possibly Insane

Registered
  26/08/2002
Points
  2722
28th January, 2014 at 28/01/2014 20:33:09 -

Can't do better than that tut (started following them this summer, haven't finished all of it yet, maybe this or next summer).

I like your models

 
Image jenswa.neocities.org

Hagar

Administrator
Old klik fart

Registered
  20/02/2002
Points
  1692

You've Been Circy'd!Teddy Bear
6th February, 2014 at 06/02/2014 17:49:06 -

Really impressed with your work Sketchy. I love voxel engines...

Would love to see a voxel B17

Edited by an Administrator

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
6th February, 2014 at 06/02/2014 22:33:13 -

Thanks
It's a shame this doesn't seem to have any practical applications - at least not in MMF2.
Unfortunately, I really don't have the time for it right now - I'm really just here procrastinating, because writing essays on government legislation and various policies & procedures relating to child protection in schools, is making me lose the will to live.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click