I'd like to colorize two grayscale layers with two constant colors and then blend them additively. I understand that blending can be done via setting an alpha value on the ImageryLater, but this will result in the output pixel being weighed by the respective alpha values, i.e. OUTPUT_RGB = alpha * SOURCE_RGB + (1 - alpha) * DESTINATION_RGB.
I'd rather have it blended as OUTPUT_RGB = SOURCE_RGB + DESTINATION_RGB. Furthermore, the source color (SOURCE_RGB), i.e. the color of some layer's pixels, should be multiplied by a constant color (for example red), so that the layer's grayscale pixels will colorized.
In another application that used openlayers3 as its mapping framework, I managed to achieve this effect by providing a callback function that was called by the framework right before each rendering step. This callback was called for each layer separately. Using this hook, setting the following parameters worked:
var colorizationColor = [1, 0, 0]; // red
gl.blendColor(colorizationColor, colorizationColor, colorizationColor, 1);
gl.blendFunc(gl.CONSTANT_COLOR, gl.ONE); // multiply source color with above color, destination color with 1
and then in a similar callback that was called by the framework after the rendering for this layer was done, I reset the blending parameters to their default value.
My question is if something like this is possible in any way without directly modifying the source code? And if not, where the best place for such a modification would be.