A point wrangle grouping points inside a camera's frustum with an extra check for visibility / occlusion.
toNDC()
creates normal device coordinates, X and Y between 0.0 and 1.0 will be inside the frustum. To check for visibility, intersect()
shoots a ray from each mesh point towards the camera position.
string cam = chs('camera');
vector ndc = toNDC(cam, v@P);
int in_frustum = ndc[0]>=0.0 && ndc[0]<=1.0 && ndc[1]>=0.0 && ndc[1]<=1.0;
i@group_visible = 0;
if(in_frustum){
vector pos_cam = ptransform( cam, "space:object", {0,0,0} );
vector dir_cam = pos_cam - v@P;
vector pos_ray = v@P + normalize(dir_cam) * 1e-3;
int pr_hit = intersect(0, pos_ray, dir_cam, set(0), set(0));
i@group_visible = pr_hit < 0;
}