What performs a ray pick?

I’m heavily relying on many line-of-sight checks and using scene.pickWithRay to do so. I may end up having to do hundreds per second in high-traffic scenarios, but I’m noticing that it’s not exactly the fastest thing in the world. Some loose benchmarking has 10000 rays (not actually hitting anything and only going 50 units straight up) taking around 6 seconds.

I’m wondering if this operation is purely CPU-based or if this can this be GPU accelerated at all.


And perhaps, but that would take some facey shaderwork to get any valid data back from a GPU raycast. Besides being tricky to even substantiate what the ray should test against then passing it back ooof. I mean it can be done but it would be tricky and limited.

Good points. I wonder if it would still be a net gain to not try to qualify it’s “hits”, but just send everything back and let the user filter it down from there.

how would you send the info back though?

You would have to come up with a tricky conversion method and pass a texture buffer back to the cpu from the gpu, like a ping pong simulation method. Remember the GPU has no memory other then textures.

Dunno. That’s for people smarter than me to figure out lol.

Could you tell us more about what you’re checking with pay picking ? Maybe is there another better way to do ?

1 Like

Mainly related to pathfinding. When starting a path, I need to know the nearest node that is also within LOS. I have all nodes stored in a quadtree for quick proximity detection, but they still have to be validated as being in LOS to be a real starting point candidate. After I have the start and end node, I can request a path from a dijikstra’s function. After that, I can walk the path and eliminate nodes that are in LOS to their neighbors.

Lots of picking…

What might help you is to use an ellipsoid, move forward before render. Check for collisions and only render those new coordinates if not colliding otherwise revert to previous coordinates. Ellipsoid can be offset too so you can poke it out a bit if needed. I have found Rays useful but I only ever use the bare minimum because of performance issues.