PRT volume strangeness

I am having strange issue with PRT volume, I am just filling a sphere with some particles and deleting particles outside the camera view, but the rendering is slow and I keep getting white screen. Is there an issue with using PRT volume with large objects.
zr__Shot2b_fog01.max (476 KB)

Yes, but you first need to understand what you are asking it to do :wink:

PRT Volume has two main processing steps: Level Set Conversion and Per-Voxel Particle Generation.
In the first step, the mesh is raytraced and converted into a 3D grid (not inlike the grids of FumeFX or Stoke 2). As you are probably aware, voxel grids tend to eat up a lot of memory because you have a grid of voxels in all 3 dimensions and a mere 10x10x10 grid is already 1000 voxels. Obviously, the smaller the voxel, the more voxels will be produced in the grid, and the more memory will be allocated.
In the second step, each voxel gets one or more particles distributed inside of it, as long as the particle is not outside the mesh surface. Each voxel can be subdivided into a number of sub-voxels (we call them regions). This is very easy to do with a voxel, so it does not require much calculation or memory, and each sub-region can get its own set of particles.

When you use the PRT Volume button/menu item in the Krakatoa menu, the script takes the size of the mesh’s bounding box and adjusts the viewport voxel size to produce the same number of voxels from the same shape regardless of its size in generic units. So making a sphere with a radius of 10,100 or 1000 would produce the same voxel count in the viewport. The script does NOT affect the render time spacing (voxel size) though. So in your case, you have a sphere with a Radius of more than 1000, but your render spacing is only 2.5. This is asking for a grid of 400x400x400 voxels just to fill a volume with points and then delete most of them, especially those around the mesh surface! The level set conversion process shoots rays along all 3 axes to determine how the surface passes through each one of these voxels, so this adds a lot of CPU load too, and it is one of the few remainging single-threaded processes in Krakatoa. So you are really asking for trouble :slight_smile:

Since you are interested in the inside particle distribution and not in capturing the exact curvature of the sphere on the outside, you don’t really need that many voxels! Just like the Viewport Spacing shows, a spacing of 40.0 (about 25x25x25 voxel grid) gives you enough data to fill the volume with particles. The second stage lets you sub-divide each one of these large 40.0 units voxels into as many sub-regions as you want without allocating memory to store the sub-regions themselves! So if you enable the subdivisions option and set it to 1, the 40.0 units sized voxel will be turned on the fly into 2x2x2=8 20.0 units sub-regions, each getting its own particles. If you set the subdivisions to 2 you get 3x3x3 = 27 sub-regions, 3 subdivisions produce 4x4x4 = 64 sub-regions each with voxel size of 10.0 units and so on. To produce a sub-region size of 2.5 units from 40.0 units sized voxels, you would need 15 subdivisions. This will turn each of the large voxels into 16x16x16=4096 sub-regions, but without the memory overhead of actually storing them in memory!

On top of that, you can create more than one particle per sub-region. So it might not be necessary to subdivide that much and create only one particle in each resulting cube. Instead, you could subdivide just a few times (since you don’t really care about the detail of the surface), and produce a thousand particles in each sub-region. So a combination of a few sub-divisions and a lot of particles in each one of the resulting sub-regions could produce the same amount of particles you were after…

Hope this helps.

EDIT: I just rendered your scene with 15 subdivisions. It produced 21.0952 million particles and used 563.302 MB RAM. Rendering took 4 minutes and 7 seconds.
Next I disabled the “Subdivide Region” option and enabled Multiple Per Region. Entered 4096 in both Count and Distinct Values and rendered again. The result was comparable - 21.1065 million particles using 563.603 MB RAM rendered in 4 minutes and 4 seconds. But the rendered image showed some particle patterns because the same random distribution of 4096 particles was used for each large voxel.
So while the two methods produce the same amount of particles in about the same time, using more subdivisions with less particles per region is the right way to go.

Wow! That was some explanation. Thanks for taking the time.

Yes I am with you now , its better to subdivide the regions rather than decrease the spacing to increase particle count.