Rendering a box made of about one million spheres

Hi,



I am relative new to 3D graphics development and so I need your advise on how to solve my problem.



I have a cube made of about ten thousand up to one million spheres. Each sphere shall only have a single color - nothing fancy here should only look nice. The cube should be fully visible and rotatable around its middle/center. Also it shall be possible to move the camera through the cube to see inner layers.



My brute force method was to add every single sphere to the scene and as you can imagine the performance was … a desaster.



It would be nice to get some technics on how to solve this performance problem. I need only some hints for further reedings to get started.



Any suggestions are appreciated. Many thanks in advance.

look at BatchNode, seems perfect for this

No, with all the visually covered spheres not being rendered you only increase the fill rate and make your GPU work overtime. Check the forum for “voxels”. Basically what you want is the surface mesh of the spheres put together, everything else is just too much. If it was possible all games would simulate the molecules instead of going with smoke and mirrors all the time…

@normen said:
If it was possible all games would simulate the molecules instead of going with smoke and mirrors all the time..


Like this? :P
http://www.youtube.com/watch?v=00gAbgBu8R4&feature=related
@Tumaini said:
Like this? :P
http://www.youtube.com/watch?v=00gAbgBu8R4&feature=related

That example does exactly what I said, its a voxel engine. There is no molecules rendered "inside" the objects, they are hollow. The molecules only describe the volume so the surface can be rendered.

@Tumaini: i saw this long time ago, but i never read more about it, becouse for me it is too far future for actual hardware.



But if you want to share somethin more, do it :wink: It’s a very interesting and popular topic.

As far as I remeber this only works because there are less unique features. Everything is just repeated over and over again. Otherwise it would take too much disk space, RAM, VRAM and so on^^

Like this?

if this tech will try to simulate its every "voxel", it will also end up with 0 fps.

I have a cube made of about ten thousand up to one million spheres

If you would ask what could be the coolest way to do it, I would answer that you should look for such "effect" or.. or i just do not know how to define it.. called "metaballs", which is working prety fast by using geometry shaders, but since geometry shader isn't yet implemented in jme and since you probably won't have in mind modifying some sphere in your cube, yeah, the best solution for you is to make a single mesh out from the vertex data of all your spheres, and attach this single mesh to the (root)Node.

oh man, just give him a link:



http://hub.jmonkeyengine.org/groups/free-announcements/forum/topic/simple-voxel-engine-starter-kit/

All the voxel/bloxel engines like in minecraft use cubes to construct the world. Is it possible to redesign the engines to render “beautiful” spheres with a gloss or will it also end in a perfromance cut.



BTW I have tried the BatchNode and like normen said is the result sobering.



Are there any methods or algorithms known which can calculate hidden/invisible objects in JME?

All the voxel/bloxel engines like in minecraft use cubes to construct the world. Is it possible to redesign the engines to render “beautiful” spheres with a gloss or will it also end in a perfromance cut.


no they dont use Cubes... Only render look like created from cubes(but it is not). Read about voxel engines, before telling "this".

i would never name "something using cubes to create world" as "engine".
1 Like

@oxplay2 is right, voxel is what you want and box worlds don’t consist of boxes. Learn about voxel engines, theres a lot of info on the forum and web.

1 Like
@oxplay2 said:
But if you want to share somethin more, do it ;) It's a very interesting and popular topic.

As normen notes, it doesn't render all the molecules, it just calculates what each pixel on the screen would look like and renders that image, not all the molecules inside or behind the models. In a later interview, their lead programmer stated that they only use the graphics card to display this final image, everything else runs on a low-end CPU.
However, that technology is definitely not ready yet (as they also state in the interview), so who knows when/if it will be available for use.
it just calculates what each pixel on the screen would look like and renders that image

so they propably take "surface" molecules and calculate pixel color of them? ok but the whole scene have milions of molecules, so its RAM killer. checking what molecules take to render pixel would take very long.
@oxplay2 said:
so they propably take "surface" molecules and calculate pixel color of them? ok but the whole scene have milions of molecules, so its RAM killer. checking what molecules take to render pixel would take very long.

Yeah, they probably have good optimization for that. Think about how quickly google can gather search results nowadays.. And then its being made a mesh that can be displayed with OpenGL, just like the "smaller" voxel engines.
Yeah, they probably have good optimization for that. Think about how quickly google can gather search results nowadays.. And then its being made a mesh that can be displayed with OpenGL, just like the “smaller” voxel engines.


I rather think how popular JME is, and then its being made of voxel molecular system :D
@atreus said:
Hi,

I am relative new to 3D graphics development and so I need your advise on how to solve my problem.

I have a cube made of about ten thousand up to one million spheres. Each sphere shall only have a single color - nothing fancy here should only look nice. The cube should be fully visible and rotatable around its middle/center. Also it shall be possible to move the camera through the cube to see inner layers.

My brute force method was to add every single sphere to the scene and as you can imagine the performance was ... a desaster.

It would be nice to get some technics on how to solve this performance problem. I need only some hints for further reedings to get started.

Any suggestions are appreciated. Many thanks in advance.


Do you really need that many spheres? Can't you reduce the number somehow? This sounds like a hugely overkilled way of making a cube!

If you do need them you are going to need to get clever and work out roughly which ones are visible and limit your rendering to those. For example identify the three faces of the cube facing you and just add the spheres that are near those faces. As you move into the cube move a "virtual" face back to select the spheres to put in the scene.

You don't need to be accurate though. Err in favour of including more - just let the z buffer work out which ones are in front.