3
$\begingroup$

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?

$\endgroup$
5
$\begingroup$

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.

$\endgroup$
  • $\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 Oct 5 '15 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 Oct 5 '15 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$ – Jaroslav Jerryno Novotny Oct 7 '15 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$ – lukas_t Oct 11 '15 at 6:56

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.