Voxel Engine

Post your own tutorials, guides and demos.

Post » Tue Oct 25, 2011 8:07 pm

Hi everyone.
I made a simple 3D engine based on voxels, it can find coloured points in 3d array and display it on 2d surface.
For now it's SLOW AS HELL (Rendering one frame on phenom II x4 3.5Ghz with radeon 6850 takes 8 seconds), but it works, maybe even works good :).
Screen Shot
And i have a favour to people who know math's good, to check maths in this cap, beacause math is not my strong point.
Free to do anything :) .

CAP
Engine
Map Generator
I add a map generator which generates an array with random (1-6) numbers on every point at y=64, map weight is 192 MB, and it takes 256 mb of ram.


Edit:
I changed view range to 256 and i saw... END OF THE WORLD, Rendering took only 29 seconds, very smooth :D , but now im know that maths are good ;).
Some explanations:
You can change view range by changing value in 10 expression
Position is in 3 variables: Position X, Y, Z
Y Axis is for looking left/right
X Axis is for looking Up/Down
FOV is field of view in degrees.

Looking for optimizations (29 secs to render a frame is little too much :/ ), if you know how to optimize it, improve speed, post it, maybe some day it can be used in games (yeah sure, when we have 100 Ghz processor, we must reduce rendering( rendering, TAKING A PHOTO BY 100 YEARS OLD CAMERA ) time from 29 secs to at least 100 ms :/ ).Satelita2011-10-25 22:17:31
B
3
G
1
Posts: 12
Reputation: 499

Post » Tue Oct 25, 2011 9:25 pm

voxel engines will never run fast made in CC, although i applaud you on the coolness of this
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Tue Oct 25, 2011 10:15 pm

Thanks.
I thinking about multi threaded rendering (afaik construct doesn't support multi-core, i dont think it uses one core to the maximum, but i can run 4 engines, every engine render part of image and results are stored in fast ramdisk and displayed in another app, maybe 4x or more speedup, but i think it still be too slow) and some optimizations ( engine when find and display point still check points after it and others like this), maybe i get 1fps with 60 pixels range :D, but i will try it tomorrow.Satelita2011-10-25 22:15:38
B
3
G
1
Posts: 12
Reputation: 499

Post » Wed Oct 26, 2011 1:53 am

Maybe if some of the loops were pre-compiled into a C++ plugin you'd see some large speed improvements. I'm pretty busy right now, but if you're in no rush then I'll see what I can do.
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Fri Oct 28, 2011 8:42 pm

I was thinking about a plugin, that may be good idea for that but i have no knowledge about c++, thats why i did it by events system.
But the problem is why it's so slow, when the only maths are so slow in construct, the idea with plugin can work but when it's because of slowly working array plugin or something like that it will not be that easy to do. So i must chceck that before we can start to write anything, i will give a reply with results.
B
3
G
1
Posts: 12
Reputation: 499

Post » Fri Oct 28, 2011 9:40 pm

in general satelita looping events with math are an easy way to slow things down, each time a plugin is called to evaluate an expression or perform an action, there's some overhead aside from the actual c++ running, just to make the event system work correctly. it's very fast in most situations, but looping thousands of things is not one of them.   c++ will almost undoubtedly be much faster, especially if you make the plugin draw your voxels as well. QuaziGNRLnose and I are working on converting his 3d events into a plugin. he probably has the specific numbers, but I believe even in it's unfinished state still pushing around thousands of construct objects it's already running much faster
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Sat Oct 29, 2011 10:44 pm

only the loop's (empty loops, just looping nothing) on 2ghz pentium dual core ( to do full rendering it needs 10 seconds, without array loaded ) takes 60 ms, its about 20 fps with doing nothing (my gps with 400mhz arm SoC can render voxel based terrain with almost same speed, checked with GAPI) :/, loop with only the maths takes 5 second ( without checking results in array, which takes next 5 seconds ), so in construct events system it will never be enough fast, i dont know what about c++. to check all points with one pixel range it must do 62 500 loops, to do it with 60 pixels range it needs 3 750 000 loops, i think its something wrong with the algorithm, i must check how other voxel engines are made :D.

Edit:
I think i have found the way how to optimize it and make a lot faster, i will post results and explanation when i done it.

Can someone check this cap, i have no idea why it doesnt work :/.
Optimized VFX
The main idea of this optimisation is to create smaller array where are stored info in which blocks of bigger array are stored coloured voxels, and i have added mechanicism to prevent checking next voxels after drawed one.
Map generator for smaller array.
Map generator A

Edit2:
Nevermind that project, it's working too slow, i'm currently working on engine based on polygons (for fun,nothing serious, but it may be usable ), today i have succesfully displayed ONE polygon :D. Satelita2011-11-04 19:10:00
B
3
G
1
Posts: 12
Reputation: 499


Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 0 guests