Voxel - Visibility

Previous topic - Next topic


Gasp! this is incredible! :O
We really should put it to good use inside a game.


Double dragon post!

I also noticed you have smooth shade going on even though it is all made of cubes.
Was that on purpose? Is is controllable?


The actual colours are random shades of green and brown, but what makes it look so different is that I turned on a spot light.  Just comment out the spot light line (in main loop of VoxelLand.gbas) to go back to solid colours (but doesn't look as good IMO). See first shot for an example.

Or, the 2nd shot has a spot light directly above the level, using this command:
Code (glbasic) Select
X_SPOT_LT 1, RGB(255,255,255),  32, 160, 32, 32,0,32, 100

My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]


That code is in japonese for me :P

What I meant has to do with X_AUTONORMALS, lights should not bother it.
Mode 1 for cubes and mode 2 for less then 90 degrees connected surfaces.

It all felt like it was rendered in mode 2 with the lights.

Now usually, on a 3d package, we can control that and set groups to smooth or not...and sometimes set a threshold angle, let´s say, smooths only below 59.9 degrees.
In older discussions, I remember while doing the objects inside GLB things are controllable, while importing OBJ or the likes, you can´t.

But that is only aesthetics, is it too hard to mess with the terrain? Let´s say can you explode things and delete cubes out of the map?
A 3d ballistic (monkey) game with 3d winds could be a good project to give this a try.

Excellent work Slydog!


Ok, I turned on X_AUTONORMALS (Before generating the terrain), and see how it looks.
I also bumped the world to 128x128, and it still handles it no problem.

I suck at lighting (and modeling!), and always have a hard time getting a 3d world to look awesome.

It should be trivial to create an UpdateVoxel(x, y, z, newCubeType) function.
It would have to recalculate the surrounding chunk array in case they are affected, then regenerate this chunk and the surrounding.  Maybe this is next on my list.

You could create an ExplodeTerrain(x, y, z, radius) function to change all voxels in that radius range to air.  Then add an explosion animation if you want (perhaps using 1x1x1 voxel pixel models). Fun stuff!
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]


Lookin good!  :good:


"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Ian Price

You know what, as awesome as this is, I can't help but think it would be even better as an updated version of the Geoff Crammond classic The Sentinel -

I came. I saw. I played.


New Update!

Added UpdateVoxel(x, y, z, newCubeType)
- Auto calculates new faces for voxel, plus updates any voxels touching this voxel
- Auto generates updated chunk belonging to this voxel, plus any chunks affected by neighbor face changes

Added an FPS display for testing (just made it up, hope it's semi-accurate).

Test project removes a random voxel each frame (the top most grass voxel for a random x,z location).
This still yields about 20FPS, after regenerating all affected chunks.
I think my FPS calculation is wrong though!

Restructured my code to allow for specific voxel updates without having to regenerate entire map.

The screenshot is the map eroded after about 10 seconds (at 1 voxel deleted per frame).

I think this is as far as I'm going to go with this (except bug fixes!).  I had my fun. 
I have a couple voxel world games ideas in my head - maybe will continue this in the future.
This should give anybody a quick start to use in their own game, if desired.  Or for learning.

Project zip at bottom.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]


Looks really great!

Now I want to play GL - Craft ^^
AMD X2 4600, 2 GB Ram, ATI X1950 XTX, XP PRO SP2: GLB Premium 10.beta_dingsi, <(´.´<) Kirby Dance (>`.`)>
alea iacta est


AWESOME! :good:

It yells 17fps around here but I´m sure everything is moving at 60fps.

What is really funky, I kept looking at it for quite a while and when I starred away real life things were twisting the opposite direction :D :D
Seriously, I got quite a kick from that visual effect.

I can´t understand 3d coding as of yet and most likely nothing from the code :( I will get there someday!


The Master Coders.. my fuc.. (love sorry)  =D =D , this it's really interesting to see very vomplex, at least for me... running in GLBasic , when I boutght I never thinked I see this kind of projects... Really Really fun and interesting...

Thanks for sharing the code. the part for hidde faces in models can be very usefull for me... Thanks. :booze: :booze:


Wow!  :O

litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic


Hey Slydog...you are not retiring from this project?
Such marvelous stuff, maybe an user inteface, walking around, anything!

It just looks too good to be truth (but it is, I tried it :))
I bet standard bit old computers can handle 9x that easily? ( I get that figure from the performance here)

Could something gamewise be done about it? Even a 3d balistick explosive pong with lava....heck I´d wish I knew my ways around this up-level of coding!


Very good piece of code :good: Really clear code, easy to read..
The biggest problem is that X_ object generation is so slow, but it's simpler to draw and quite fast.

Note that fps drawing function is wrong :p just change
Code (glbasic) Select
fps = timer / frames to
Code (glbasic) Select
fps = framesSo if you had 20fps earlier truely it was 50fps..

Even more it's working on Android, just add icon.png to folder and compile.. app needed more than 5 minutes to load :D but my chinese single core 1Ghz tablet with Mali400 on bigger map (-> voxelMap.Generate(128, 12, 128,  16, 12, 16)) has ~33fps, of course only small portion of cubes are visible.. Needed to comment lines that randomly delete chunks.

Some time ago I was also working on cube style engine, but mostly to see what rendering method would be faster, each have some pro and cons, and it would be great if you would add vertices and visible sides counting to your code. My project is a total mess, and when I will have some free time to rewrite it I will post it on forum.
Check my source code editor for GLBasic - link Update: 20.04.2020


Very nice code here!
Btw. Slydog your FPS code must be wrong. Fraps says its 60 FPS, your counter says its 17 FPS.
This code is working correctly, just replace your function:
Code (glbasic) Select
FUNCTION DisplayFPS: x%, y%
STATIC frames#, fps#
STATIC time1#, time2#
INC frames, 1000
IF time1 > time2
fps = frames/(time1-time2+500)
time2 = time1+500
frames = 0

PRINT "FPS: " + FORMAT$(3, 0, fps), x, y

Btw. is there a reason why you didnt use GENX_OBJ(), but created your own?
All in all its nice code, but it has much room to get bigger: currently only using color for cube type (texture is a bit limited, since uv are always set to same value for all sides), add automatic handling for chunks in chunks in chunks in... and it would be better (way faster) to render in native Opengl, not GLBasic, but its the best that we have seen so far and a really good base for further development (and considering that it was done such a short time!), I hope you will go on with this project.

EDIT: dreamerman was faster than me :/
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64