Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道可以通过写入 gl_FragDepth 来控制写入 GLSL 中深度缓冲区的内容,但是可以写入模板缓冲区吗?
另外,我可以从片段着色器中完全取消像素写入,就好像像素没有通过模板或深度测试一样?
谢谢
如果您使用正确的硬件,您可以写入模板缓冲区。所有 Radeon HD 硬件都可以使用 AMD_stencil_shader_export。有一个 ARB_stencil_shader_export,但我无法验证它是否特别普遍。
如果你想阻止一个片段写任何东西,你可以使用discard. 这有点像在概念上(但不是在行为上)抛出异常。
discard