Rikrok Posted September 29, 2015 Share Posted September 29, 2015 Is there any way for the ray sop to register a hit only on the front face of a primitive and pass through backfaces? Quote Link to comment Share on other sites More sharing options...
Atom Posted September 29, 2015 Share Posted September 29, 2015 Have you tried setting the Ray Combiner to "Shortest" ray? Quote Link to comment Share on other sites More sharing options...
Rikrok Posted September 30, 2015 Author Share Posted September 30, 2015 Have you tried setting the Ray Combiner to "Shortest" ray? That doesn't work (and I wouldn't expect it to, it's not how shooting multiple rays works). Quote Link to comment Share on other sites More sharing options...
anim Posted September 30, 2015 Share Posted September 30, 2015 (edited) you probably can't do that in Ray SOP but you can use intersect_all() VEX function or VOP to get all intersections along the line, then check in for loop for first one that is not back facing Edited September 30, 2015 by anim Quote Link to comment Share on other sites More sharing options...
acey195 Posted September 30, 2015 Share Posted September 30, 2015 Alternatively you can extract the hit normal and do a dot check against the the initial point normals (if dot is larger than 0, it is a backface) and if needed, you could start a new ray at this point to check for subsequent front/backfaces 1 Quote Link to comment Share on other sites More sharing options...
Fake Pilot Posted January 10, 2020 Share Posted January 10, 2020 Is it possible to write a VEX example of this? :-) Quote Link to comment Share on other sites More sharing options...
Fake Pilot Posted January 10, 2020 Share Posted January 10, 2020 Did it myself. Works. vector dir = v@N*1000; vector pos; vector uvw; int hit_prim = intersect(@OpInput2, @P, dir, pos, uvw); v@primN = prim_normal(1,hit_prim,uvw); if(dot(@primN,@N) < 0){ @P = pos; } Quote Link to comment Share on other sites More sharing options...
anim Posted January 10, 2020 Share Posted January 10, 2020 (edited) if you want your ray to continue through all backfaces and hit something behind you'd need to do something along the lines suggested in previous posts vector t = chv("t"); vector dir = normalize(chv("dir")); float maxlength = chf("maxlength"); // get all intersection int prims[]; vector hitPs[], primuvs[]; intersect_all(1, t, dir*maxlength, hitPs, prims, primuvs, .001, .001); // filter out backface intersections and stop at first frontface vector outP = t + dir*maxlength; foreach(int i; vector hitP; hitPs){ int prim = prims[i]; vector primuv = primuvs[i]; vector hitN = primuv(1, "N", prim, primuv); float dot = dot(dir, hitN); if (dot < 0){ outP = hitP; break; } } // create line int pt0 = addpoint(0, t); int pt1 = addpoint(0, outP); addprim(0, "polyline", pt0, pt1); ts_intersect_ignore_backfaces.hip Edited January 10, 2020 by anim 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.