Hello,
I had this idea for a while but could not implement it in Blender somewhat easily. With new geometry nodes I thought that finally it could be done. So what I want to do: I need to have an object which contains voxels in some way, colors of which could be accessed by Cycles volume shader.
The idea is to have some quite low-res 3D texture stored internally in blender object, which can be generated based on other geometry in the scene, etc. Think of it as of some modifier, so that during rendering this voxel data is fixed and has to be only read from the object and not calculated for each sample in shader. This kind of precomputation can significantly reduce render times if used correctly.
The simplest use-case is some distance field to several objects which you calculate only when objects are changed and in shader you just sample this distance field with some kind of interpolation.
This 3D voxel texture can be than combined with complex volume shader which through this texture can “interact” with objects etc.
As an example of how you could use it, you could generate a volumetric cloud using mix of noises in shader nodes and for color of this cloud you would use color of the closest voxel, color of which has been calculated as a mix of colors of nearby objects. In that case you can fake indirect lighting from these objects in a volume shader but without actually calculating any scattering. I hope that I made it clear
What I’ve tried to implement this kind of behaviour:
-
Creating voxels as a bunch of cubes where for each cube all its verticies have the same vertex color. Then I can access this voxel data via Point Density Texture node. With correct values of resolution and radius it could be rendered truly as voxels.
Problems with this approach: Vertex colors have to be painted manually or generated through python script, so this method is not interactive, which is unacceptable for my needs. I guess that there is a bug with Point Density Texture node or Geometry nodes which does not allow to use them together. Any geometry generated via Geometry nodes is not displayed properly by Point Density Texture -
Another way is to use Points to Volume node. From the user point of view it generates a very similar results to Point Density Texture - for each vertex it creates a sphere with some radius filled with volume. This approach seemed advantageous to me at first, as it ties with Geometry Nodes nicely. The problem with this approach is that there seems to be no way to generate custom attributes which can be used in volume rendering; and also as this node generates Volume object there is no way to render it as a usual mesh, so volume is only rendered where density is non-zero. But I also want to control density via some 3d texture which can not be done in that case.
So I really hope that anyone can help me and come up with some idea to implement this.
Thanks in advance