#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.