我正在使用OpenGL> 3.3,我想知道是否有办法在片段Shader中轻松找出片段是否属于背景。 (我和#Version 330一起工作) 我使用多通道渲染,我必须与一个实际上不是背景的片段的邻居一起工作......(我正在使用pointcloud)。 所以我试着这样做:
uniform vec3 backGroundColor;
float dx = 1/screenwidth;
float dy = 1/screenHeight;
for (int i=-3; i<3; ++i){
for (int j=-3; j<3; ++j){
vec3 frag = texture(screenTexture, TexCoords + vec2(i*dx, j*dy)).xyz;
if (frag.x != backGroundColor.x && frag.y != backGroundColor.y && frag.z != backGroundColor.z)
do something...
else
do other Things...
}
}
但我相信这是不足之处...(而且由于浮动精度而不是正确的......) 有没有更好的方法来达到我想要的目标?