I'm trying to add two textures (.PNG) images in LibGDX to my own shader. Everything works great, except the math/ blending part. Hopefully someone can help me with this blending problem!
This is my base texture. (256 x 256 px, 32-bit texture)
This is my "ontop" texture. (256 x 256 px, 32-bit texture)
The effect I want. A simple base texture with another texture ontop, ofcouse with the transparency working.
And the current result. Blending between the textures, a bit brighter where the "dots" of the texture are.
I've tried several different solutions. This is from renderer, my class that implements the Shader of LibGDX:
Gdx.gl20.glEnable(Gdx.gl20.GL_BLEND); <-- Doesn't do any difference.
Gdx.gl20.glBlendFunc(Gdx.gl20.GL_ONE, Gdx.gl20.GL_ONE_MINUS_SRC_ALPHA); <-- Dosen't do any difference with the cube, but make vertices transparent on a more advanced mesh.
The fragment shader:
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 v_texCoord0;
uniform sampler2D u_texture1;
uniform sampler2D u_texture2;
void main() {
vec4 bodyColor = texture2D(u_texture1, v_texCoord0);
vec4 addColor = texture2D(u_texture2, v_texCoord0);
gl_FragColor = bodyColor + addColor;
}
Something is clearly wrong.