Voxels, meshes combining and performance.

Post your questions, suggestions and experiences regarding to Image manipulation, 3d modeling and level editing for the Irrlicht engine here.
Post Reply
Neirdan
Posts: 39
Joined: Tue Aug 14, 2012 10:29 pm

Voxels, meshes combining and performance.

Post by Neirdan »

inb4:
Yet another minecraft clone thread? No.
Go do something easier that 65536 people already have done like pong/tetris: No, I already made some 2d games, I want something new and challenging.
Use Volumes of fun? No.
Have you heard about minetest by celeron55? Yes, and I studied his code.
Do a forum search for "minecraft". Done, I've read everything.

Summary:
I'm working on an engine that can be summarized as a minecraft-like, BUT:
-There are not only squares shapes
-There are much more meshes displayed (your character is not 1x2x1 but rather 1x4x2 and might be 2x7x3 depending on the performance/results)
-It is not based on digging/building, but that's a feature implemented.

Problem:
Displaying blocks as individual meshes create a shitton of queries which has a huge impact on the FPS.

Potential solutions:
-Mesh combining / batching
-Back face culling
-Only draw visible triangles

My solutions:
I am considering mesh combining using this method:
-A "cube" is composed of 6 faces, each composed of 2 triangles
-A "rectangular triangle" is composed of 5 faces, 2 composed of 1 triangle and 3 composed of 2 triangles.

Image

When both are placed close to eachother, an alogithm will check which "faces" are in contact and remove useless S3DVertex, to create a bigger mesh, this will reduce the number of calls.

Then, if there are squares close to eachother, instead of having 4 rectangular triangles, it'll combine it in bigger rectangular triangles. This will reduce the number of triangles to draw.

Image

I want to display 1024x2048 (considering a 180° view angle) terrain tiles (each tile contains a "shape") so that's (for a flat surface) 4.194.304 visible triangles.
By regrouping tiles in 16x16 blocks, that will reduce the numbers to 64x128 blocks: 16.384 visible triangles.
By regrouping them in 32x32 blocks, that will reduce numbers to 32x64 blocks: 2.048 visible triangles.
And so on.

When it comes to back face culling, from what I've seen, it's automatically done, but still, what would be the point of displaying "invisible" triangles, that's why I thought of testing if there is an "obstacle" between the camera and the target vertex/triangle (of course after cleaning them with both previous functions). For this part, I don't know how to do it, I lack knowledge.

Questions:
Do you guys think I am "doing it right" or is there something easier, more elegant, less time consuming or whatever better than my method?
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Voxels, meshes combining and performance.

Post by serengeor »

So basically you want to create cube2 engine clone? As far as I know, it does all those things and it is opensource :wink:
Working on game: Marrbles (Currently stopped).
Neirdan
Posts: 39
Joined: Tue Aug 14, 2012 10:29 pm

Re: Voxels, meshes combining and performance.

Post by Neirdan »

I didn't know about cube2 and I don't want to use it because what I mentioned above is only a part of the project.
I've checked it a bit and it doesn't seem to be an appropriate solution because it lacks things I'll require.

So if they did the same thing as what I'm planning, I'm guessing I'm somewhat right, am I?
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: Voxels, meshes combining and performance.

Post by devsh »

its already been done

you will be yet another copy cat

go.. equip yourself with geometry and tessellation shaders and some compute extensions in opengl and implement sparse voxel octrees
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Voxels, meshes combining and performance.

Post by Mel »

That seems like the marching cubes algorithm.

This video is simple, but ilustrative of that concept. The problem isn't to generate the mesh, the problem is to update it in real time in the most efficient way

http://www.youtube.com/watch?v=LfttaAepYJ8

This video shows an engine of the previous idea working.

http://www.youtube.com/watch?v=qIGgUFP33fc

But the complete algorithm can provide much better results than those.

http://http.developer.nvidia.com/GPUGem ... _ch01.html
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: Voxels, meshes combining and performance.

Post by devsh »

BEWARE OF PATENT TROLLS

Marching cubes has a retarded patent on it

use marching tetraheadrons instead
CuteAlien
Admin
Posts: 9633
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Voxels, meshes combining and performance.

Post by CuteAlien »

The marching cubes patent is now expired, so no more risk there.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Voxels, meshes combining and performance.

Post by Mel »

It expired in 2005,
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Post Reply