Reputation: 501
continue to this question :
GLSL : accessing framebuffer to get RGB and change it
Is it possible to develop program based on GLSL as follows?
I confirmed this algorithm which distinguishes object 1 is hidden by other object using glut functions. I used glReadbuffer, glDrawbuffer functions. However those are too slow, I want to use GLSL.
Upvotes: 2
Views: 457
Reputation: 22167
If the only goal is to render object1 with a different color set when it is hidden behind object2 (which are the pixels of object1 where depth has changed) I would go for a completely different approach.
glDrawBuffer(GL_NONE)
or glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE)
)glDepthFunc(GL_GREATER)
and the coloring you want when object1 is behind object2glDepthFunc(GL_LESS)
and the coloring you want when object1 is in front of object2.In contrast to the algorithm you described in the question, there is no need for any read-back operations or additional framebuffers
Upvotes: 2