i have several objects in OpenGL and i want to mark the selected object. My idea was to use a GLSL shader to add the selected color.
How can I get the ‘original’ color of the pixel in the fragment shader?
I could look the color up in the texture, but when there’s more than one texture?
i have several objects in OpenGL and i want to mark the selected object.
Share
If you intent to render your selected object with a specific shader, then you have to create a shader that has the same behavior as the regular rendering of your objects (lighting, texturing, …). That means you have to compute that color of the pixel by yourself.
If you intent to render all your objects, and then add your selection, then it is impossible to retrieve the color of the framebuffer pixel from your fragment shader (you need to create a texture out of your framebuffer and use it, but it is out of scope, I think).