I can combine two images using below code. But is there any way to place the second image on bottom left of first image?
vec4 colorFirstImg = texture2D (sTexture_1, vec2(vTexCoord.x, vTexCoord.y));
vec4 colorSecondImg= texture2D (sTexture_2, vec2(vTexCoord.x, vTexCoord.y));
vec4 result = mix(colorFirstImg , colorSecondImg, colorSecondImg.a);
gl_FragColor =result;
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;