I am trying to visualize the electron density of some simulations. The data would consist of a file with the density of electrons at each point in space. From reading documentation I have found that the voxel data structure would be great for this kind of data and allows for multiple frames as well.

enter image description here

Is it possible to use voxel data or something similar to apply a material with volume scattering? Currently I cannot find a way to use this kind of data (only image textures are allowed). Resources I have looked at typically mention that it is only possible in the blender renderer.

  • $\begingroup$ Related: blender.stackexchange.com/questions/14995/voxel-data-in-cycles $\endgroup$ – Carlo Apr 22 '17 at 17:06
  • $\begingroup$ Related: blender.stackexchange.com/questions/62110/…. Do you have some sample data file? $\endgroup$ – lemon Apr 22 '17 at 17:25
  • $\begingroup$ So I actually stumbled upon those posts and what was disappointing is that they only offered work arounds. It looks like the community is just waiting for a voxelnode to be implemented. My hope was that a straightforward solution would be possed. It's fair to mark this as a duplicate. $\endgroup$ – costrouc Apr 22 '17 at 17:50
  • 2
    $\begingroup$ Support for voxels still isn't here, but support for point clouds has since been added. You could try using such a point cloud, but I'm not sure how well it would work for this. $\endgroup$ – gandalf3 Apr 22 '17 at 18:05
  • $\begingroup$ It looks like the holy grail is once openvdb is fully implemented in Blender. Not ideal but I will try out point clouds. $\endgroup$ – costrouc Apr 22 '17 at 18:28

For those wondering since there are not really any supported volume formats (as of spring 2016) supported in Blender Cycles hacks must be used. I settled on a solution that used the answer posted in a related question. It is important to note this solution is a general method to create 3d image from a 2d image and is gpu accelerated. I was able to use this method to create 3d volume scattering.

enter image description here

Here is an ugly but fully working one that I produced with the following python code to create the input image. I found this approach to also be very memory intensive as expected since each image was 200x200x200 pixels.

import numpy as np
import png # using pypng

n = 200
x = np.linspace(0, 10, n)
array = np.zeros(n**3).reshape(n, n**2)
for i in range(n):
    for j in range(n):
        for k in range(n):
            array[i, j+k*n] = (np.sin(x[i]) * np.sin(x[j]) * 
np.sin(x[k]))**2 * 2**16
array = np.floor(array).astype(np.uint16)
image = png.from_array(array, 'L')

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.