I'd like to visualize Point Density cycles node in 3D view with python. Something basic - iterate through all vertices or particles and draw a (voxel?) sphere for each of them. How is smoke visualization done in real time in the viewport? Is that accessible from python?


1 Answer 1


Smoke visualization in the viewport is based on a 3D texture, which gets mapped on a stack of coplanar planes facing the camera and using alpha-blending. You can access the raw values for density, color, etc. from the smoke domain, but i doubt this is of much use for visualization.

The point density texture works differently. In cycles it is implemented in the same way as smoke, using a 3D volumetric texture. However, it's internal data (you cannot access Cycles' own data anyway) is in the form of a kd-tree. This data structure is not accessible from the texture directly, but you could construct an equivalent tree through the bpy.mathutils.kdtree module, depending on the texture settings.

  • $\begingroup$ Thank you for clarification, though I understand the differences on how smoke and point density texture are handled in Cycles. The part I'm really interested is how smoke is visualised in 3D viewport (I don't expect to show density etc. just rough representation - like smoke) $\endgroup$
    – kilbee
    Commented Oct 5, 2015 at 9:05
  • $\begingroup$ So from what I understand, the way to do it is through glBlendFunc? Generating a 100 or so (point density material resolution) planes and blending them in real time in viewport is the way to go? Is it comparable performance-wise with smoke visualisation? $\endgroup$
    – kilbee
    Commented Oct 5, 2015 at 9:55
  • 1
    $\begingroup$ @kilbee there is problem with alpha blending in Blender viewport. The alpha planes are not depth sorted like in Maya or game engines. I think stacking transparent planes in Blender won't work very well. $\endgroup$ Commented Oct 7, 2015 at 11:46
  • $\begingroup$ @kilbee It's not just comparable, it's exactly what smoke visualization does. developer.blender.org/diffusion/B/browse/master/source/blender/… The domain space is divided into 128 slices along the view direction. Each slice is constructed as a convex intersection of the domain box with the (infinite) plane. A GLSL shader then creates the smoke look by basically using alpha blending. I can't really say what else would be appropriate without knowing your goals. $\endgroup$
    – user436
    Commented Oct 11, 2015 at 6:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .