[Solved] Slicing Mesh

Hi everyone, I’m currently developing an OptiX app in which I have to slice a mesh according to the lights position, similar to an ultrasound image. I’m kinda struggling with some of the OptiX concepts, since I’m not sure if my Ray Generation program should be the one casting those rays or if I should compute all this in my Closest Hit program, and how to show the computed image afterwards.

I’m using the OptiX 6.0 and the optixMeshViewer example as a base to try all this.

Thanks in advanced!

Please describe how the resulting output should look like or what algorithm needs to be solved.

Sorry for the delay. It’s hard to describe the output without posting an ultrasound image, but as for now, I have managed to load multiple meshes (different organs forming a scene: [url]https://drive.google.com/open?id=14faT6Q9iqQLUAGwPUC4AJRa3bZOX7gh1[/url] ). Now I need to slice that scene so I render a frame with the edges found in a specified direction with different rays (like a transducer for ultrasound, instead of Light Rays, these will be Sound Rays).
I don’t know if that’s clear enough, but please let me know if there’s a need for further description!

It’s still hard to say based on your description. Are you trying to dynamically exclude sections of your geometry from rendering? “Slicing a mesh” sounds like you maybe want to define moving regions of space where geometry shows up, and regions where geometry disappears?

The standard way to cut away parts of your geometry dynamically is to use an any-hit program, calculate whether the hit point is in your accept zone (visible) or reject zone (culled out), and then call rtIgnoreIntersection() for hit points in the reject zone. Be aware that any-hit programs have a cost, so keep them simple and only use them when you need to, if performance is critical.

If that doesn’t sound like what you need, then yes we’ll need some more details about the problem you’re trying to solve. Your description of rendering the edges found by sound rays sounds a little like shadowing to me - do you need to test visibility between the primary hit point and the transducer/light?

If you are wanting to slice geometry statically, in other words, hide & show different meshes or different parts of your meshes, there are a couple of other options depending on whether you’re using RTX hardware or not, so let us know if that sounds more like what you need.


David.

Hey David! Thanks for your answer. Reading this I’m guessing that the any-hit program approach is the ideal. If I recall correctly, I have to check visibility from the transducer, since it wouldn’t be able to recieve “echoes” from rays that go away. Your description sounds pretty accurate, I’ll try that! Sadly I don’t have any RTX hardware, as I’m with a Quadro P6000.

Anyways, thank you very much for your answer! I’ll mark the thread as solved.

Well good, I hope that helps. For what it’s worth, it does sound to me a little like it might be more complicated than just an any-hit shader, but feel free to reply to this thread or start another if you need more suggestions. Based on your first and last comment, it sounds like you may need secondary ray tests, and I should point out that you are allowed to do secondary ray tests either in ray-gen or in closest-hit. Putting the rtTrace() calls in your ray-gen is usually the preferred approach. If you cast secondary rays from closest-hit, then your OptiX programs might be recursive, and it consumes more stack space. Casting secondary rays iteratively from ray-gen is the approach we advise more often since you save GPU stack space.