iterating over / writing back to vdb's with the openCl sop

   1130   2   1
User Avatar
Member
17 posts
Joined: 2月 2018
Offline
hey all, got some volumevop vex code (that interpolates between multiple, same sized potentialflow vdb's) which i want to implement in opencl. Through this post [www.sidefx.com] it is clear how to load the nanovdb library and access grid data:

#include "interpolate.h" 
#include "CVDButil.h" 

float lerpConstant( constant float * in, int size, float pos);

kernel void kernelName( 
                 int P_length, 
                 global float * P ,
 global void * vdb_dens 
)
{
    int idx = get_global_id(0);
    if (idx >= P_length)
        return;
    const global cnanovdb_griddata *grid = (const global cnanovdb_griddata *) vdb_dens;
    cnanovdb_readaccessor acc;
    //check for vdb type
    if(cnanovdb_griddata_validF(grid)) {
        cnanovdb_getreadaccessor(grid, &acc);
        float3 sampleP;
        sampleP.x = P[(idx*3) +0];
        sampleP.y = P[(idx*3) +1];
        sampleP.z = P[(idx*3) +2];
        float dens = cnanovdb_sampleF(grid, &acc, sampleP);
        P[(idx*3) +1] += dens;
    }
}

But it's hard to find further information or an api reference for this so i can figure out how to:

1) write back to the vdb that is accessed
2) have the opencl kernel run over the voxel positions or indices (at least this video [vimeo.com] example it seems like running over P will sample only at geometry points, not voxels)
3) check for active voxels. although that might be solved with question 2

Had a look at CVDButil.h and CNanoVDB.h but there's no obviously named method i could find.
Edited by nvki - 2023年8月4日 18:05:43

Attachments:
reynoldsFlowCurl.png (417.0 KB)

User Avatar
Member
17 posts
Joined: 2月 2018
Offline
so after looking into this for a bit it might not be able to write to vdbs. the pyrosopsolver kinda gave me that hint since internally it seems to be using classic houdini volumes.
with those accessing and storing data in grids is pretty straightforward, 'generate kernel' also returns a good baseline how to set up the volume indexing.
User Avatar
Member
4672 posts
Joined: 2月 2012
Offline
In Houdini 20, OpenCL SOP and Gas OpenCL DOP can write to VDBs;
https://www.sidefx.com/docs/houdini/news/20/vex.html [www.sidefx.com]
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
  • Quick Links