Voxel rendering 10.6 million cubes at 120 fps :)

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
yamashi
Halfling
Posts: 40
Joined: Sat Jan 23, 2010 11:27 pm
x 2

Re: Voxel rendering 10.6 million cubes at 120 fps :)

Post by yamashi »

I will post a screenshot of my voxel raytracer in OpenCL soon.
It uses bezier path to render the voxels and looks very very smooth !
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Voxel rendering 10.6 million cubes at 120 fps :)

Post by Kojack »

Since everyone else is posting pics, don't forget my crappy little experiment last year:
http://www.ogre3d.org/forums/viewtopic. ... 31#p405223
Low frame rate, but 16.7 million cubes rendered with just 96 triangles. :)
kattle1987
Gnoblar
Posts: 2
Joined: Tue Mar 15, 2011 2:28 pm

Re: Voxel rendering 10.6 million cubes at 120 fps :)

Post by kattle1987 »

Lee04 wrote:Anyone looking for the "next" thing in blocky world games, contact me I have some nifty ideas that will transform the blocky world to the next level.
the same goes for me: I'm working on more realistic structures an better water, and I'm perfectly fine to work for an open source project too (since I feel that an open source community might do wonders in a minecraft-like game), and I'm in fact looking for a team to show off my testings!
Dark_Oppressor
Gnoblar
Posts: 5
Joined: Mon Apr 11, 2011 9:30 am

Re: Voxel rendering 10.6 million cubes at 120 fps :)

Post by Dark_Oppressor »

yamashi, is this terribly difficult to do? I'm actually just now learning how to use OGRE, and everything else 3D. I'm working on a 3D game (as in, the world is three dimensional), but the graphics are currently 2D. Think recent versions of Dwarf Fortress. I actually think it might be cooler with 3D graphics in a Minecraft-esque style, but I don't much of anything about 3D graphics.

Do you think something like that would be too ambitious for someone like myself? This question is posed to all of you, actually. Thoughts?
User avatar
JamesKilton
Halfling
Posts: 87
Joined: Tue Jun 14, 2005 8:21 pm
x 1

Re: Voxel rendering 10.6 million cubes at 120 fps :)

Post by JamesKilton »

Nothing is too ambitious if you're willing to put in the time, effort, and learning to get done what you want. That said, Minecraft-esque graphics are very easy to implement ("easy" being relative of course, it's vastly easier than, say, Unreal Engine 3). You're only rendering boxes, very basic texturing, and some simple lighting. Going the voxel route also lets you get away with "programmer graphics" for much longer. The one hard problem with Minecraft is making sure you're not rendering more than you have to, and there are a lot of tools to help out with that (to start: octrees and frustum culling).

The rule for any type of development is to start simple and work up from there. Knowing what you want to accomplish is fine, but don't try to jump right there as you'll hit many walls and lose all motivation to continue.
Ogre.rb Project Lead
yamashi
Halfling
Posts: 40
Joined: Sat Jan 23, 2010 11:27 pm
x 2

Re: Voxel rendering 10.6 million cubes at 120 fps :)

Post by yamashi »

@JamesKilton : It's actually a lot harder than what you think, I don't render any box here... octrees and frustrum culling are handled by Ogre the "hard" part are Occlusion Queries, PVS computations...
Like you said it's not that hard to get something on screen BUT it's quite complicated to render it fast. I tried to implement real time shadows and it's wayyyy too slow, impossible for our current hardware...

@Dark_Oppressor : I wouldn't recommend starting with a minecraft look a like, get used to Ogre, learn shaders, understand the graphic pipeline and all the little tricks, make small games achievable very quickly to motivate yourself, then do like most of us here, make a game engine and then start a "big" project. The engine I use was intended to be used for a MMORPG only, I did some improvements and I can now make a minecraft like game in very few lines of code. Starting a game like that without a solid framework is suicide !
LBDude
Gnome
Posts: 389
Joined: Mon Jul 26, 2010 10:53 pm
x 22

Re: Voxel rendering 10.6 million cubes at 120 fps :)

Post by LBDude »

Well, it depends on what level you want to get to. I think, it's a nice project to learn things, provided you make things simply as possible starting and also that you know the basics of 3d programming. If you don't know anything about 3d programming then maybe try something simpler like messing around with the tutorials. But if you are dedicated I think you could hack this as a learning project.

Don't use Octree or anything. Just setup your volume as a 3D array both for simplicity and fast access. The trick to not rendering millions upon millions of cubes is to only extract visible surfaces. You can do this by iterating through the volume, for a single "row" of the data, look at it's neighbor voxel to in the "negative x" and "negative z" direction. If both are "the same", do nothing. If previous voxel is "larger" than current voxel, then render the faces of the previous voxel, otherwise render the faces of current voxel. I recommed the PolyVox library since it does a lot of this for you already in an easily accessible package.
My blog here.
Game twitter here
Dark_Oppressor
Gnoblar
Posts: 5
Joined: Mon Apr 11, 2011 9:30 am

Re: Voxel rendering 10.6 million cubes at 120 fps :)

Post by Dark_Oppressor »

Thanks for all the responses, guys. Programmer graphics are definitely what I seek to get away with, as my last project was a roguelike (ascii symbols for graphics). For reference, I have made several games, including one with networking and so forth. But I've always shied away from 3D, fearing complex maths and the like.

The game I am starting on now, however, I think would look much better 3D than 2D (I think, I'm still prototyping :). I've gone through all of the OGRE basic tutorials. I played with PolyVox a little, and got a sphere to show up, for what that's worth. I've actually already got a basic 3D game "essentially" made, I'm just trying to decide how to render it. Obviously, it will be a little different gameplay-wise, too, if I decide to render it in 3D and let the player move around with a first-person perspective.

I guess I technically have a (very) small bit of experience with some 3D stuff, since my recent 2D projects use SDL+OpenGL. I have piddled with it off and on, and made a cube appear or whatever.

Anyway, say I already have a 3D array of cubes setup, should I still look into using PolyVox, or am I far enough along that path that I should just roll my own rendering stuff? Basically, I've got a 3D world setup, and what would be nice would be if I could just say "ok OGRE+PolyVox+magic+etc., render these cubes to the screen, and only the faces that are seen by the camera." Thoughts?
LBDude
Gnome
Posts: 389
Joined: Mon Jul 26, 2010 10:53 pm
x 22

Re: Voxel rendering 10.6 million cubes at 120 fps :)

Post by LBDude »

"ok OGRE+PolyVox+magic+etc., render these cubes to the screen, and only the faces that are seen by the camera."
PolyVox has a CubicSurfaceExtractor which will extract only the visible surface into a triangle mesh. With the mesh on hand, you can now tell Ogre to render it. To do that, you need to either create a hardware buffer or use manual object. In my game I'm using a ManualObject, although it is my plan to eventually use a custom hardware buffer, somewhere down the road. Let's say you use ManualObject for now, then it's very easy to setup with PolyVox. In PolyVox there is a Material class (MaterialWithNormals or without normals) which have the triangle mesh that you extracted with the CubicSurfaceExtractor, from earlier. Then it's just a matter of looping through every vertex, copy it over to the ManualObject (tutorials available on wiki), then copy over the index. Attach the ManualObject to a scene node and render it. That's the general gist of it, although I probably glossed over some important details. You never know until you try it :).

Wait. There is one more thing--PolyVox's extractor assumes that you will compute the normals in a shader because doing so reduce bandwidth usage because one can share vertices if you compute normals in the shader. That could a big deal for you if you don't know anything about shaders. But I would say if you are dedicated enough you can probably pick up shaders from a few tutorials. After that you can look at example shaders on PolyVox's forum (search: cubicsurfaceextractor) that does the normal computation thing.
My blog here.
Game twitter here
Dark_Oppressor
Gnoblar
Posts: 5
Joined: Mon Apr 11, 2011 9:30 am

Re: Voxel rendering 10.6 million cubes at 120 fps :)

Post by Dark_Oppressor »

While designing the game, I actually came up with another idea that doesn't even require 3D graphics, which I am even more excited about. So for now, I think I will hide from the fearsome shaders! :-P

In the future, I still want to play around with this. And I still need to learn some shader stuff. Thanks!
Post Reply