Voxel - Visibility

Previous topic - Next topic

Slydog

Looking great!  :good:

I see now you are drawing each visible face of each cube each frame? 
Wouldn't this cause major performance issues? 
Opposite of a chunking system where you are trying to minimize the number of objects rendered.
I think before you were creating the chunk model prior to the main game loop, and only displaying that one chunk object each frame.

And, I think you can simplify your Render() function down to this code:
Code (glbasic) Select
FUNCTION Render:
X_MOVEMENT -CHUNKSIZE/2-CUBESIZE/2, -CHUNKSIZE/2-CUBESIZE/2, -CHUNKSIZE/2-CUBESIZE/2
X_PUSHMATRIX
FOR x = 1 TO CHUNKSIZE
FOR y = 1 TO CHUNKSIZE
FOR z = 1 TO CHUNKSIZE
IF self.cubes[x][y][z].bin = 0 THEN CONTINUE

ALIAS bin AS self.cubes[x][y][z].bin
X_MOVEMENT x, y, z

IF bAND(bin, CUBE_TOP)    > 0 THEN X_DRAWOBJ FACE_TOP, 0 // Draw TOP
IF bAND(bin, CUBE_BOTTOM) > 0 THEN X_DRAWOBJ FACE_BOTTOM, 0 // Draw BOTTOM
IF bAND(bin, CUBE_FRONT)  > 0 THEN X_DRAWOBJ FACE_FRONT, 0 // Draw FRONT
IF bAND(bin, CUBE_BACK)   > 0 THEN X_DRAWOBJ FACE_BACK, 0 // Draw BACK
IF bAND(bin, CUBE_RIGHT)  > 0 THEN X_DRAWOBJ FACE_RIGHT, 0 // Draw RIGHT
IF bAND(bin, CUBE_LEFT)   > 0 THEN X_DRAWOBJ FACE_LEFT, 0 // Draw LEFT
   
NEXT
NEXT
NEXT
X_POPMATRIX
ENDFUNCTION


But, I love it so far!  Great screenshot.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Schranz0r

#16
hmm i thinks its OK if we use frustrum culling, but the big question here is: HOW! :D
:S
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

erico

Uau! A Borg Assimilation Cube! Great!

Some faces look flipped, is that correct? (maybe my eyes are tricking me)

Schranz0r

the faces are right!!!111one :D
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

mentalthink

Joder!!! :noggin: this it's really interesting... I think if multiply the cubes a lot of times then you can do another Zbrush , I suppose the CPU will begin to launch flames but for try it  =D =D =D

Out of jokes, but this for make nice games with another style can be a good ppoint for start... a nice thing will be explode any cube in some cube more littles...

Thanks to both for the work... about the Fustrum I leave in someplace I don't know where is, how do all fustrum, chunks, water , physics... a lot of things... I try to search again...

Thanks for the hard work!!!  :booze: :booze:

Slydog

#20
I had fun with this for the past day or so (using my code as a base (but stole an idea or two from Schranz0r!). I found a few bugs in my original code postings - oops!).

Only exposed faces are added to the mesh, as expected.

I added an automatic chunking mechanism.
This means that a 16,16,16 map with a chunk size of 8,8,8 will generate 2x2x2 (eight) chunk meshes.
This reduced my 16x16x16 map generation from 10seconds to 1second!.
It seems the more triangles in a mesh, the longer it takes for GLBasic (or OpenGL) to generate and finalize the mesh.
Same total triangles, but as 1 mesh took 10+seconds, but as 8 different meshes, takes just over a second, total.


I included the project files as a zip, instead of posting each file (4 files) contents.
I tried commenting the main Voxel TYPE as best I could, so hopefully it is easy to follow and understand.

To Do:
- Perlin Noise Generator for MineCraft style landscapes
- UpdateVoxel(x,y,z, cubeType) -> To allow dynamic voxel editing.  Will regenerate the affected chunk(s)
- Interface to delete or add a new voxel to the map, and display the new map
- Texture Map: Use an external texture map tool to design the voxel textures, allow multiple voxel types (dirt, grass), auto map the textures to the model
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Hark0

Great work!

What is the limit of cube size?

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

erico

Gave a go, looks and moves about great. :good:

Ian Price

I came. I saw. I played.

Schranz0r

#24
OK... complete rewrite of the code, rendering in realtime with OpenGL (gl.gbas)
Texturemapping added.
More improvements incomming!  :whip:

4x4x4_chunks.png is a screenshot of a "World" with 4x4x4 Chunks each chunk = 16x16x16


Source see attachment!
Anyone interested to make a Minecraftstyle game?!
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Ian Price

While I'm no fan of Minecraft, I love to see things like this being done with GLB.

Keep up the excellent work chaps :)
I came. I saw. I played.

Hark0

I'm thinking in "voxatron"....  :P
http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic

Schranz0r

I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

mentalthink

Like Erico says this things are absolutely awesome... again I do the same question, this it's the same techique for do a Zbrush or a Voxel Modeler... I think in a Voxel Modeler you using millions at the same time, this it's possible in GLbasic, I think Using OpenGl, can't be too much problem?¿...

Slydog

I was going to stop updating this, as I have no immediate use for it, but doing this is too much fun.

Here's my latest update, which includes a Perlin Noise generator, to create a MineCraft-ish landscape.
I use this to create a height map: anything below is dirt, anything above is air.
(MineCraft's algorithm is much more complex, with random caves, with minerals, etc).

It is much faster this way than completely random dirt/air cubes, as there are a lot less exposed faces.
I simply used a random shade of green for the top (grass), and a random brown for the dirt sides.

The main line that gets the perlin height is this:
Code (glbasic) Select
//x#, y#, maxHeight#, frequency#, amplitude#, persistance#, octaves%
height = noise.GetRandomHeight(x,z, 1, 0.1, 1, 0.15, 3)


I don't know much about the specific perlin input values, but I found that frequency seems to make it spaced out more, and lower looks better.

Here's the site I derived this Perlin Noise TYPE from:
http://ploobs.com.br/?p=1742

I attached a screeny and the source project.  Have fun.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]