I'm working on a paint app for Android that allows users to draw using their finger. It's built using OpenGL ES 2.0 using point sprite technique as well as an FBO for quick rendering. I am having an issue blending the individual point sprites together where the transparent regions are correctly rendered on the FBO but when the sprites overlap I can see the transparent areas being rendered on the previous sprite. Here's how it looks currently:
This is with this blending equation:
GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA);
If I change the drawing color to white or black it works perfectly:
I've also tried this blending function:
GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_DST_ALPHA);
Which results in this:
Which is almost perfect but instead to white the main color should darken. Any ideas on what the correct blending function should be to achieve this?
Note: I have an idea of how the blending function works by taking fractions of the source and destination color and in my case adding them together so it makes sense that the color would go towards white. So I'm wondering if what I would like to achieve can be done with blending function only or would I need something else? I can provide code from the fragment shader if necessary but it doesn't look like a fragment problem to me.