Simple Visibility Check?

I’m new to Optix and I need it for a fairly simple purpose: I just want to see if a set of somewhat arbitrary points on my facets are visible or not. So, I have a list of rays which start at those arbitrary points and end at the viewer. That viewer is infinitely far away (the rays are parallel). That arbitrary point is visible iff the ray intersects no other facet.

Can the above be done with Optix or with Optix Prime? If so, is there an example that does something very close to this? I’ve been reading the Optix Programming Guide, and my general sense is that it’s possible, but it’s a long read and I’m hoping someone has already programmed most of this code.

Thanks in advance to anyone that replies.

Does your scene consist of opaque triangles only? If so, then OptiX Prime might be a quick way get started. Check the “primeSimplePP” sample in the SDK. The main function loads a mesh, creates a batch of ortho rays from a viewer, runs a query, and shades the hits.

You might start with the following changes:

  • simplify the shadeHits() function slightly. The current version constructs a geometry normal for shading, which you may not need. Just do something like return (1,1,1) or (0,0,0) for a hit/miss, based on the t-value of the hit record.
  • change the model->createQuery() call to RTP_QUERY_TYPE_ANY. This should be a little faster since it allows early termination of rays.
  • change createRaysOrtho to create (random?) points on your triangles and shoot ortho rays in a fixed direction. This one you’ll probably need to write entirely yourself, but also check the occlusion baking sample on github, which has code for distributing random points on a mesh:

You can certainly do this with OptiX or OptiX Prime. However, it may be even faster to use an occlusion query through OpenGL. This is most effective if your points form some regular grid or can somehow be thought of as pixels.

Yes, my scene is all opaque triangles. I’m looking into the PrimeSimplePP example, but I’m not sure what to do about the ‘context’. That example uses a different context then RTPcontext, which is what’s described in the Optix Prime section of the Optix Programming Guide. Since that is really a different question then my original question, I created another post on this forum here

Hopefully that’s okay.