Skip to main content


I was looking for a way to display mouse-over context information in a 3D scene, and the solution I came up with is to encode the ID of each object into colors, and render that to an off-screen framebuffer. Then, I can simply look up the pixel at the current cursor coordinates and get the ID!

It feels like a cheeky hack, but honestly I can't think of any other practical way for this - does anyone know how games and such do this?

#graphicsProgramming #webgl #opengl #3d

in reply to Draemmli

never coded something like this but from reading knowledge the usual way to do such things is a ray cast from camera/cursor to where you point together with something like collision detection or more like object intersect detection. with those keywords you might find what you want