top of page
Search

Voxel Size Calculator

Writer: Manav Gala
Manav Gala
Sep 18
3 min read

Updated: Oct 9

Download it for free HERE ! The Voxel Size Calculator is an idea I got from a LinkedIn comment talking about this concept. It boils down to calculating the world-space size of a pixel from the shot camera at a specified distance. This allows precise control over the voxel size in terms of pixel scale to maximize the detail in volumes, while making sure that no memory and storage is being wasted for volume elements that are placed far away from the camera which don't actually need sub-pixel detail.





How To Use This Tool:


The tool can be used in two ways:

a. To calculate the optimal voxel size for a simulation.

b. To continuously resample an existing volume element


As I developed this tool and actively tested it, I added some much needed quality of life features.


The very first inputs that the tool needs are your shot camera and object for distance sampling. Choose between static and animated sample frame for both, the camera and the sampling object. This maximizes control over whether objects and cameras are static or if they're animated with a big change in distance values, which in turn would need the voxel size to be recalculated every frame.


The tool accepts points or primitives as input, and the two main controls are 'X Resolution' and 'Voxel Scale'. The X resolution of the camera helps the tool determine a baseline resolution, and the voxel scale is a multiplier on that value. a 1:1 pixel:voxel ratio is often too high resolution, so a voxel scale value of 2-4 generally works pretty well for me.


The sampling object can be used as is, or converted into a bounding box for efficiency.


The 'Clamp Voxel Size' is especially useful for resampling a simulation. In my personal tests, I found that it can often be beneficial for the voxel scale to be a lower value while resampling than while simulating, especially for situations where the camera is far away from the simulation. In such a case, it's important to clamp the voxel size to that of the simulation to avoid excessive processing when the camera reaches close to the volume.


Finally, the calculated voxel size will be displayed on the node itself and stored as a detail attribute, making it easy to link into other nodes. 'Truncate Voxel Size' simply reduces the lengthy float value down to five decimal places for simplicity.



The Difference


In my test project, the cache size difference between the raw simulation and optimized simulation was 4.38GB compared to 0..996GB respectively. Such massive savings in storage and memory, especially compounded over multiple simulations, shots and projects are a game changer for me, The visual fidelity is near identical, and completely indistinguishable with motion blur.



How It Works


The tool runs multiple checks over the input to make sure that it functions exactly the same way.




The next step is to run distance sampling. A problem I ran into early on is that simply using the distance from the camera center to the closest point on the onject doesn't work to calculate distance accurately. Since the line can be at any angle in the world, it doesn't match the distance between camera and the viewing plane, which is always drawn from the middle of the camera plane. Hence, I had to use some vex to ensure accuracy of distance. The below images illustate the difference between direct distance and actual distance.





The distance sampling is done using a multi-directional shape surrounding the camera to ensure that the tool works regardless of direction. This allows distance sampling to remain accurate throughout complex animation.




Finally, A voxel size is calculated using the accurate distance and taking camera information.



Thanks!


Thank you very much for reading through the breakdown for my Voxel Size Calculator tool. Again, you can grab it for free from HERE


Feel free to email me or leave a comment under this post if you have any questions, concerns or things to share.


Cheers!

 
 
 

Comments


bottom of page