-
Consider not naming variables in GLSL
vec3 rgb, since.rgbis an alternative to.xyzwhen reading vector components (ie. you can now dorgb.rgbwhich will quickly lead to endless amounts of confusion, and GLSL is confusing enough without that
) -
The issue is caused by the fact that you’re trying to pick a sample outside of the texture (and, by default, three will just clamp the sample to the edge color - docs.) You can check if the sample coordinates are within
0.0 - 1.0range and just don’t do the mixing in case they aren’t, for example:
if (slideCoord.x < 0.0 || slideCoord.x > 1.0 || slideCoord.y < 0.0 || slideCoord.y > 1.0) {
gl_FragColor = gray;
} else {
gl_FragColor = texture2D(u_texture, slideCoord) * vec4(slideColor, 1.0);
}