Advertisement

GPU Box Selection to also select occluded objects?

Started by August 06, 2019 11:08 AM
1 comment, last by MJP 5 years, 3 months ago

I can already do box selection of visible objects in a scene by assigning a unique color to each object and rendering to a separate frame buffer and reading it on the CPU.

But is there a way to do it such that both visible and occluded objects can be selected if they are within the selection box?

The only way I can come up with is to render in wireframe (or maybe points only?) and render multiple passes. After each pass, I go through the list of objects whose selection color appears in the selection buffer, and disable their rendering for the next pass. I keep doing this until the selection buffer is completely black (i.e. no selection), which means that there is nothing left to select. The final selection is the union of all previous selection passes.

The issue with this is I need to do at least 2 selection passes to make sure everything was selected. Realistically I would probably need to do even more.

Im curious if anyone has a better idea. What is the usual approach used for this in the industry?

"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "

Another option would be to bind a buffer as a UAV/output from your pixel shader, and then having your pixel shader write to that buffer if the pixel is within the selection box. This will effectively disable early-z optimizations which means that your pixel shader will still run if the pixel is occluded by the depth buffer, but that's exactly what you want in this case. You can also only do this for a subset of your scene by computing the (asymmetrical) frustum that represents the volume bounded by your screen-space selection box, and then using that frustum to cull out meshes that can't be selected.

This topic is closed to new replies.

Advertisement