PDA

View Full Version : quick copy of stencil to color



V-man
12-16-2003, 03:34 PM
It looks like there is no efficient way to do this. No extensions to help?
I would have to do glReadPixels?

GL_NV_copy_depth_to_color comes close, but I would like to copy stencil to a texture.

GL_ARB_depth_texture has the right idea but GL_ARB_any_texture would be more valuable. http://www.opengl.org/discussion_boards/ubb/smile.gif

inet
12-17-2003, 05:07 AM
Maybe you can try to use stencil test to control your content in the dst alpha plane. Then copy it to a texture.

V-man
12-17-2003, 01:00 PM
That's one trick but it is limited.

If depth test fails then you cant modify the color buffers but you can do whatever you want with the stencil.

Do you have a way to make a exact copy of a 8 bit stencil into an 8 bit alpha?

inet
12-18-2003, 02:43 AM
>>If depth test fails then you cant modify the color buffers but you can do whatever you want with the stencil.

That's true.

>>Do you have a way to make a exact copy of a 8 bit stencil into an 8 bit alpha?

Once I used logic_op to write to different bitfields in the dst alpha plane. I don't know if it fits your need.

Csiki
12-18-2003, 12:46 PM
Originally posted by V-man:
That's one trick but it is limited.

If depth test fails then you cant modify the color buffers but you can do whatever you want with the stencil.

Do you have a way to make a exact copy of a 8 bit stencil into an 8 bit alpha?
It may possible to this in 8 passes.
Clear the color buffer, and use glBend with each stencil bit with the color values 128, 64, 32...
Or I'm wrong?

V-man
12-18-2003, 06:38 PM
I was thinking about this. It sounds nasty because of the number of passes but should work.

Inet, is this what you ment by logic_op?

inet
12-21-2003, 01:59 AM
What I mean is something like this:

glLogicOp(GL_OR);
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_TRUE);
glColor4ub(0,0,0,(1<<i)); //here encode what u want to set.
glEnable(GL_COLOR_LOGIC_OP);
DrawScreenQuad();
glDisable(GL_COLOR_LOGIC_OP);

By the way, just curious, what do u want to do with this stencil-buffer-to-texture copying?

V-man
12-24-2003, 03:37 PM
I was considering this for doing a feedback trick.