I am curious of how the performance of color picking compares to ray casting. I am looking at the scenario when the mouse is clicked which means only then the scene is rendered in a backbuffer for color picking or ray-cating has to be applied.

Note: I have found this question which unfortunatly does not give any indication.

  • \$\begingroup\$ What would make a satisfactory answer to your question? Also, have you tried either option and found its performance to be unsatisfactory? \$\endgroup\$ – Seth Battin Jul 24 '15 at 21:20
  • \$\begingroup\$ I have not found unsatisfactory performance for color picking and have never ever implemented ray casting. But I very often find that people use ray casting so I wondered whether this is because of performance (hence this question). A satisfactory answer could be "Reading a framebuffer is so slow that ray-casting calculations is like ~10 times faster" or "generally the performance is similar". I know there is a lot depending on details. Maybe it depends on the case, maybe ray casting is always faster becaue framebuffer reading is a true bottleneck. \$\endgroup\$ – Sjoerd222888 Jul 24 '15 at 21:27
  • \$\begingroup\$ Maybe! Do you have more details about your particular scenario? \$\endgroup\$ – Seth Battin Jul 24 '15 at 21:53
  • \$\begingroup\$ A possible answer is also: "It highly depends on the scenario, no general statement can be made". This is also satisfactory (if that is the truth). In this case I am really looking for a most general statement. Though I would also be interested in how to answer depends on the case, e.g. what typical things would make one technique faster (and why). To give a scenario specif answer: what would you need to know exactly except from that it is a 3D scene with 3D objects and I want to do picking only on mouse click (not continuously). Would it depend on the number of objects? \$\endgroup\$ – Sjoerd222888 Jul 24 '15 at 22:02
  • 1
    \$\begingroup\$ Ray casting maintains the same fixed cost with varying screen resolution and field of view settings. Ray casting can query your spatial partitioning scheme with a much simpler intersection geometry (A ray, instead of a trapezoid.) to find meshes which need to processed. I say "more appropriate" because it's able to take better advantage of the known information (Where the user has clicked.) to process less candidate intersections. \$\endgroup\$ – MickLH Jul 25 '15 at 23:57

It depends on multiple factors including...

  1. How much geometry you are raycasting against (more = slower)
  2. The resolution you are rendering your color picking at (higher = slower)
  3. How you've implemented either solution (CPU raycasting? vs GPU color picking? or something else?).
  4. Resource constraints -> if your application is already CPU bound, and has plenty of GPU power to spare, doing a super efficient CPU ray cast is still going to be slower than doing an inefficient operation on the GPU.

There is a way to get an answer for your particular situation though - profile it and find out!

It's also important to note, either solution is a reasonable solution in many cases, so going one way or the other is likely not going to be a huge deal. If you aren't having performance problems, don't spend too much thought trying to choose between reasonable answers IMO!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.