影响片段着色器内部的深度或模板缓冲区?
我知道可以通过写入 gl_FragDepth 来控制写入 GLSL 中深度缓冲区的内容,但是是否可以写入模板缓冲区?
另外,我是否可以从片段着色器中完全取消像素写入,就好像像素未通过模板或深度测试一样?
谢谢
I know it is possible to control what is written to the depth buffer in GLSL by writing to gl_FragDepth, but is it possible to write to the stencil buffer?
Also, can I cancel a pixel write completely from within the fragment-shader, as if the pixel had failed a stencil or depth test?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用正确的硬件,则可以写入模板缓冲区。所有 Radeon HD 硬件都可以使用 AMD_stencil_shader_export。有一个ARB_stencil_shader_export,但我无法验证它是否特别普遍。
如果您想阻止片段写入任何内容,可以使用
discard
。这有点像概念上抛出异常(但不是行为上)。If you are using the right hardware, you can write to the stencil buffer. All Radeon HD hardware can use AMD_stencil_shader_export. There is an ARB_stencil_shader_export, but I can't verify if it is particularly widespread.
If you want to stop a fragment from writing anything, you can use
discard
. It's sort of like throwing an exception conceptually (but not behaviorally).