VolumePrimitive

H9 introduce a new “volume” primitive that can live inside an object node.
the idea here was to see how much I could do without having to rely on i3d files on disk.

One way to create a volume primitive is to use the isooffset node.
nodes.jpg

a cookie node is used to have a “closed” object that is easier to convert
cookiemagic1.jpg

the isooffset node generates a sdf (signed distance field) from his inputs.
the sdf can be converted to a mesh (this was the only option in H8)
isosurf1.jpg
but now you can also output a volume primitive , which shows up in the view port as a set of slices.
primitive1.jpg
isooffset also give you the option to directly save the sdf values , ie distance from the surface , inside the volume primitive.

volume primitives can be filtered like i3d with the filtertype/filterwidth parameters.

for the moment it’s not possible to create/edit attributes at “voxel” level (from a sop) like you could do with other primitives so I had to switch back to regular i3d to inject colors in my volume.There is a new vex (and vop) command “volumesample” that let you access the volume primitive data.

this is the i3d shader I used to create an i3d file of my previous reconstructions.
it takes the color from a pointcloud , density from the volume object and also use the sdf to fill the inside with a constant color:

#pragma hint ColorPointCloudFile file
#pragma hint VolumeDensityFile file
#pragma hint VolumeSdfFile file
#pragma hint Cd invisible
#pragma hint InsideColor color

image3d
R3DtoI3d
(
string ColorPointCloudFile = “”;
string VolumeDensityFile = “”;
string VolumeSdfFile = “”;
vector InsideColor=1;
float searchradius = 1;
int maxpoints = 10;
export vector Cd = 1;
)
{
//Color
int handle;
handle = pcopen(ColorPointCloudFile, “P”, P , searchradius , maxpoints , “preload”, 1);
Cd = pcfilter(handle, “Cd”);
if ( Cd == {0,0,0} )
{Cd = InsideColor;}

//Sdf
float distance=volumesample(VolumeSdfFile,0,P);

//Density
//density=volumesample(VolumeDensityFile,0,P);
if (distance <= 0)
{density=1;}
else
{density=0;}

//verbose
//printf(“dist:%f dens:%f\n”,distance,density);
}

Volume primitives can now intersect with objects in the scenes , cast shadows correctly

volumeintersection1.jpg

you can also have multiple primitives intersecting with no problems .

multiplevolumeprim1.jpg

I did a lot of volumic work in H8 and all I can say is that I wish I had all this back then !

Next I’m planning to spend some time in the shading department to see what’s new there.

Advertisements

About this entry