I am writing a straightforward image viewer for displaying images on a couple of triangles in OpenGL ES 2.0 on Android. There is a particular colour in these images that must be replaced with black in some way. The problem is that if GL_LINEAR is used for my min and maxifying filters, the outline of the colour that needs to be replaced remains visible. If I use GL_NEAREST for my filters, the shader is able to replace the colour without too much difficulty, however it doesn't render the images as smoothly and of course looks pixelated when zooming in and out.
I wonder if there is a better way to perform this type of task. Some ideas I've had are:
- Build another shader that runs only once on the texture pixels and replaces the colours before the texture is actually used during my fragment shader?
- Rewrite my shader so that it works even when GL_LINEAR is used.
Can anyone give me any clues as to how this is usually done? The reason I'd rather perform this operation in the shader is so that I can ensure that the mask pixel colour always stays black.
I am quite new to OpenGL ES 2.0 but I am trying to learn how things work. Please keep that in mind, and help me to learn. Thanks in advance.