DEV Community

Discussion on: WebGL point sprites, a tutorial

Collapse
 
letochagone profile image
Letocha Torgue Philippe

By default, webgl treats colors as premultiplied.
here the "icon" image is not premultiplied. So you have to add the line
gl_FragColor.rgb *= gl_FragColor.a
if we don't, here is the result, note the white limit at the intersections of the icons
Image description

if we add this line, we see a better result :

void main() {
gl_FragColor = texture2D(spriteTexture, gl_PointCoord);
gl_FragColor.rgb *= gl_FragColor.a;
}

Image description