Multiple spheres per object (~500k)

Hello all

I need to generate 500k spheres in a reasonable amount of time and render them
the sphere positions are loaded from a file
script to generate:


spherelist=[None]*500000
baseMesh = Mesh.Primitives.UVsphere(3,3,s_radius*2.0)
for i in range(500000):
    ob = Object.New("Mesh")
    ob.link(baseMesh)
    spherelist[i]=ob     #store reference to edit positions later
    scene.link(ob)

This takes a ridiculous amount of time, is there a faster way?
I need to be able to individually position the spheres.

If the overhead associated with this is due to the object creation, can I add multiple meshes per object,or have one giant object with 500k sphere meshes?

particles would be ideal but they apparently are not designed for this type of usage

Thanks

Uh… that’s still 500,000 spheres… that’s 6,000,000 tris with 3 segments and 3 rings per sphere. Are you absolutely sure your hardware can take that?

I should be able to create the objects, I can’t render them however.
I’m currently focusing on generating the objects. Once I can do that I’ll worry about rendering :slight_smile:

I’m trying to migrate from pov-ray, being a raytracer it represents spheres by a point and a radius. I can render a scene with 500k spheres with no problem.

If it’s possible to specify a sphere this way, I’d love to know.

I am hoping to move to blender so that I could use more advance features (GI, renderfarming, etc)

I have 12GB of ram to work with on my machine

This is the fastest code that I know. It is 20% faster than your code, but still it slows down after object 4000 or so.


import time
from Blender import *

starttime = time.time()

nr = 10000

scene = Scene.GetCurrent()
s_radius = 1

spherelist=[None]*nr
baseMesh = Mesh.Primitives.UVsphere(3,3,s_radius*2.0)
for i in range(nr):
    if not (i+1) % 1000: print i+1, time.time() - starttime   
    ob = scene.objects.new(baseMesh)
    spherelist[i]=ob     #store reference to edit positions later


Compiled with Python version 2.6.2.
Checking for installed Python... got it!
1000 0.405239105225
2000 1.12614107132
3000 2.1709280014
4000 3.80991697311
5000 6.16953706741
6000 9.29146099091
7000 13.2044150829
8000 17.8085391521
9000 23.1621110439
10000 29.1768341064
Execution time: 29.1834819317

make only 1 object, and use the data for the position of each vertex. use a hard halo for the material, and you have it.

I don’t think you can do it. 500,000 spheres. What you have now is only a spindle, 3,3. Try upping that value to 14,14 and then do the math.

The only way to really do this is to consider the camera. You need to cull the objects that the camera is not looking at, filter them out somehow. The camera can not see 500,000 spheres at one time anyway, so figure out how many will fit in the view port at any given time then only create those spheres along the path the camera travels. You can still use your positional data to compute which spheres to show at which time. Say you figure out the camera can realistically see 8,000 spheres at once, then design your code to reuse those 8,000 spheres so that they always fall within the camera viewport at the positions defined in your external file.

thanks everyone,

I got the mesh/halo method working so it’s better than nothing.

Doesn’t really look like gravel though