Reputation: 488
I'm trying to draw a circle on the screen, where the circle's color is always the opposite of the color of what was there before. Similar to the crosshairs in Minecraft, which are always a different color than what they are currently focused on. Is there a way to access the current fragment color in GLSL?
Upvotes: 1
Views: 1760
Reputation: 45322
In GLSL, there is no such thing. I can think of a couple of ways to achieve that effect in the GL:
GL_ARB_TEXTURE_BARRIER
, you can sample from the same texture you are writing to, if you only sample from exactly that texel the fragment shader will write to. So this is basically exactly what you asked for: you get the actual color value your framebuffer has, at that fragment's location, and can do whatever operation you like on it. It does require a render-to-texture setup, though.Upvotes: 1