开发者

GLSL check if fragment is on geometry

开发者 https://www.devze.com 2022-12-22 13:45 出处:网络
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 e开发者_J

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 e开发者_JS百科mpty.

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

thanks


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号