WebGL中的AlphaFunctions? [英] AlphaFunctions in WebGL?

查看:93
本文介绍了WebGL中的AlphaFunctions?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以实现透明效果,即丢弃alpha小于0.5的片段,并使alpha大于0.5的片段变得不透明?根据我的阅读,

Is it possible to achieve an transparency effect where fragments with alpha lower than 0.5 are discarded and fragments with alpha higher than 0.5 are rendered rendered opaque? From what I've read,

glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.5); 

将是我正在寻找的东西,但是不幸的是,WebGL中没有定义AlphaFunction.有解决方法吗?

would be what I'm looking for but unfortunately, AlphaFunction is not defined in WebGL. Is there a workaround?

我的问题是,透明片段会写入深度缓冲区,从而阻止其他片段被渲染: alpha_error http://gebackene-ente.at/nudelsalat/sonstiges/pointcloud_alphaerror.jpg

My problem is, that transparent fragments write into the depth buffer and thus prevent farther fragments from beeing rendered: alpha_error http://gebackene-ente.at/nudelsalat/sonstiges/pointcloud_alphaerror.jpg

排序不可行,因为积分太多.

Sorting is not an option because there are way too much points.

推荐答案

使用着色器执行此操作.设置输出颜色后,在片段着色器的底部:

Use your shader to do it. At the bottom of your fragment shader, after setting the output color:

if(gl_FragColor.a < 0.5)
  discard;

这篇关于WebGL中的AlphaFunctions?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆