Approach to visibility samples per primitive.... dumb?

   2224   3   0
User Avatar
Member
8 posts
Joined: 5月 2014
Online
Approach: I am running a foreach loop on a bunch of prims.
For each prim I scatter a number of points. Still within the foreach loop, I run a point wrangle on those scatter points. In the wrangle I run intersect on each of the scatter points and if one hits I set an attribute on the prim (foreach loop piece) that the points were scattered on. In the end I don't need the scattered points, I just need the prims output with the attribute @keepage updated.
What I cant figure out is how to set up the forloop so that this works.

Obviously this loop will output points. The VEX for the wrangle “secondaryIntersect” seems valid, but I have no way of applying changes to the attribute keepage on the Forloop's iteration pieces (primitives).


VEX for “secondaryIntersect” running over primitives.
vector p;
vector hitprimuvw;
vector srcpt;


i@ptrefprim = prim(2, "refprim", 0);
srcpt = v@P + (normalize(v@rdir)*2);
i@hitprim  = intersect(1, srcpt, v@rdir, p, hitprimuvw);

if(@hitprim<5){
setprimattrib(2, "keepage", 0, 1, "set");      
}


This makes me think my approach is not possible.
https://www.sidefx.com/forum/topic/42999/ [sidefx.com]
Edited by Patrick Loughman - 2017年5月10日 22:19:59
User Avatar
Member
8833 posts
Joined: 7月 2007
Online
instead of trying to set prim attrib just set detail with max so that if any of the points satisfies the test detail will contain 1
then set that value to your prim and pass that to Block end

but I don't think you need for loop at all for what you are doing, you can as well post your file if you need more help
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
8045 posts
Joined: 9月 2011
Offline
Why not use pcwrite from mantra, and output the prim number to the pointcloud. any non-visible prims will not produce hits, and therefor no samples will be recorded to the point cloud. You can read it back in and remove prims that are not contained in the poincloud's value list.

Do a 1x1 render at a low resolution to limit the number of points in your pc.
User Avatar
Member
8045 posts
Joined: 9月 2011
Offline
I made an example of the approach using pcwrite/mantra to output visibility information, since it is a fairly advanced technique, and most users are not familiar with fog shaders.

Attachments:
pc_occlusion_test.zip (123.4 KB)

  • Quick Links