GLSL 检查片段是否在几何体上

发布于 2024-08-24 04:50:55 字数 191 浏览 3 评论 0原文

我目前正在将几何体的位置写入 gl_FragColor 的 RGB 通道,如果片段是几何体的一部分,我想将 1.0 写入 alpha 通道,如果片段为空,则将 0.0 写入 alpha 通道。

有没有一种简单的方法来判断片段是否是几何图形?也许通过gl_FragCoord.z

谢谢

I am currently writing the positions of my geometry to the RGB channels of gl_FragColor and I would like to write 1.0 to the alpha channel if the fragment is part of geometry, and 0.0 if its empty.

Is there a simple way to tell if a fragment is geometry or not? Maybe through gl_FragCoord.z?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哭泣的笑容 2024-08-31 04:50:55

每个处理的片段都是因为渲染几何体而生成的。不属于几何光栅化结果的片段不会被片段着色器处理。

所以,解决方案非常简单:

gl_FragColor.a = 1.0;

但是,您需要一个 RGBA 纹理。

Every processed fragment is generated because the geometry is rendered. Fragments not belonging to the geometry rasterization result are not processed by the fragment shader.

So, the solution is very simple:

gl_FragColor.a = 1.0;

However, you need an RGBA texture.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文