View Full Version : Stencil access from fragment shaders
03-11-2005, 04:02 PM
Can I get access to the value in the stencil buffer at the fragment I am evaluating?
That is, can I do something like:
int st = gl_StencilValue;
int c1 = st%2;
int c2 = (st%4)/2;
vec4 color = color1*c1 + color2*c2;
The above, of course, isn't exactly what I would be doing, but it's enough to give you an idea.
Anyway, is this possible?
03-11-2005, 04:40 PM
AFAIK, it is not posible on current hardware. Please read Issue 7 - Is alpha blending programmable? in GLSLangSpec.Full.1.10.59.pdf GLSLangSpec.Full.1.10.59.pdf (http://oss.sgi.com/projects/ogl-sample/registry/ARB/GLSLangSpec.Full.1.10.59.pdf) on page 75.
03-15-2005, 01:07 AM
It's clearly stated in chapter 2.2 Fragment Processor that this is not possible today.
The fragment processor does not replace the fixed functionality graphics operations that occur at the back end of the OpenGL pixel processing pipeline such as:
• Shading model
• Pixel ownership test
• Alpha test
• Depth test
• Stencil test
• Alpha blending
• Logical ops
03-15-2005, 05:34 AM
Right, thanks for pointing out the relative sections of the docs. I think I'll have to render into a texture buffer, and use that instead of the stencil buffer. Then, I can just bind it to one of the texture units, and my shaders can be reasonably happy :)
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.