dislekcia
19-04-2008, 12:52 AM
Some of you may have heard of Ken Silverman... If you were into game development back in the day you'd have heard of how he wrote the Build Engine (which powered Duke Nukem3D, among others) at a wonderfully young age.
Years ago Miktar and I were messing around with 2D voxels when this came out and completely blew us all away. Enjoy.
http://www.advsys.net/ken/voxlap/voxlap03.htm
10 points to the first to tell us all how he did it ;)
-D
Thaumaturge
19-04-2008, 02:18 AM
Ooh, very interesting! It's also a rather impressive demo. ^_^
(Heh, with this topic you reminded me of Ken's Labyrinth. ^_^)
Rambling musings follow; I've spoilered them just in case I'm onto something, and others want to work these things out for themselves. ^_^
Hmm... According to the startup console, at least two grids of some sort are used. The sizes of each grid were, in my first run, ~18,600kb and ~10,400kb. The numbering is odd, however - they are given as grid 0 and grid 2. Perhaps they are only selected grids from a greater number?
It also notes a number of points per cell. So, whatever a "cell" is, it contains more than one point. Since the scene can change such that a static cell (static in both size and position, that is) could take up varying portions of screen-space, the cells are either dynamic in some way, or the points are not screen points - voxels, perhaps? In any case, the number of points per cell is given as an average, indicating that the number per cell may vary.
Finally, I note that the startup console gives numbers for three other values: "Air" "Solid" and "AirSolid". "AirSolid" does not appear to be "Air" + "Solid". In my first run "Air", "Solid" and "AirSolid" were 254,051, 107,065 and 163,172 respectively.
Hmm... The total of all three is 524,288, which, divided by 8 and then 1024 is 64 - or, put another way, it is 512 x 1024 (I'm starting to sound like I'm trying to prove that all of this adds up to some number of terrible numerological significance - shall I attempt to prove that the Voxlap engine is destined to bring about the end of the world? ;)).
That could work for a 2D grid, but it doesn't seem to be enough for a 3D grid...
However, if those values are numbers in kilobytes, then the total becomes 4,294,967,296 bits, I believe, which is 4x1024x1024x1024. From this I guess that the world is a 3D grid, 1024x1024x1024 in size, in which each grid element takes up 4 bits (although why so many, I'm not sure - perhaps to allow for a variety of material types - 16, if I'm not much mistaken).
That kilobyte value, however, is, again in the case of my initial run, 18.1 times the total of the two grid sizes in kilobytes. Given the "number of points per cell" numbers, however, I wonder whether a run-length system of some sort might not be being used, with the space split up into manageable chunks, perhaps helping to keep the potential run-length fairly low, in order to reduce required space for the run-length number.
In fact, given that two grids are mentioned, perhaps the grids store run positions and lengths, with a separate grid each for air and solid terrain.
After a second play, and a little more thought, I suspect that he doesn't actually render all of the scene at once - note the rather heavy fog, which hides terrain from a fairly low distance on, I would say. I'm guessing that cells also serve to chunk up the world for rendering.
And that, is my guess.
dislekcia
19-04-2008, 10:26 AM
Yes, he does indeed render the world in chunks, but that's not the core of how this works. Read up on voxels and what they do - you're nearly there ;)
Did you find the red blaster? If not, I suggest you go and look for it again, it's the real core of the whole demo! Plus this was written in 2003 and was very CPU intensive back then, these days I think the fog could be quite a bit further away.
-D
FuzzYspo0N
19-04-2008, 12:13 PM
i played around a lot and i did find the red blaster. its interestingly made but i have seen and read through the source of that and the engine before :) i love the sounds in there though, brings back memorys
Gazza_N
21-04-2008, 10:33 AM
First full-3D Voxel engine I've ever seen (yes, I know there were others during the 90's, but I never played any of 'em ;)), and boy am I impressed. The only gripe was with the resolution - the terrain was really "voxellated" and grainy.
As for how it works, well, I only have a conceptual understanding of how voxel engines function. I'll leave the technical details to the Carmacks of the forum. ;)
kurtkz
21-04-2008, 10:57 AM
As far as I'm aware, the voxels are rendered with an optimized 3D grid-stepping ray casting function (can be done with a modified Bresenham line algorithm)...at least, that's how I did way back (as did the author of the Trixels demo) :P
Miktar
21-04-2008, 02:15 PM
*salutes Voxels - the finest innovation in gaming since 2D sprites*
Powered by vBulletin® Version 4.2.4 Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.