Adding an image over another image – OpenTK

Yes of course, you just have to scale the texture coordinates. If any component of the texture coordinates is > 1.0, skip the 2nd image, by passing 0.0 to the 3rd argument of mix:

vec4 colorFirstImg = texture2D(sTexture_1, vTexCoord.xy);

vec2 uv2 = vTexCoord.xy * 2.0;
vec4 colorSecondImg = texture2D(sTexture_2, uv2);

float a = (uv2.x <= 1.0 && uv2.y <= 1.0) ? colorSecondImg.a : 0.0;
vec4 result = mix(colorFirstImg , colorSecondImg, a);

gl_FragColor = result;

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top