Writing the Blend-Color in the fragment shader

Hi

OpenGL does have an extra blend-color, which can be used in the blend-function with GL_CONSTANT_COLOR (especially GL_CONSTANT_ALPHA). What i like about this is, that i can thus use my alpha-channel for other data, and still get blending with some blend-factor. I don’t waste the alpha-channel to write a value, that i will never ever use again.

The problem however is, that the color is indeed fixed. When i use the alpha-channel, i can modulate the blend-factor with textures etc., but when using the constant blend color, it is all the same over the entire rendered object.

Since we seem not to get the blend-shader any time soon, i would at least like to see this addition: Allow to write the blend-color in the fragment shader. It would actually only be a temporary factor for this particular fragment and will be discarded afterwards. If the FS does not write the value, use the value, that was set in the application.

Of course one would need to be able to write different values for each render-target (since the blend-function can be different for each RT on modern hardware).

This would allow to do proper blending with different factors per fragment, and use the alpha-channel for something completely different.

Jan.

Hi Jan. Sounds like a useful feature. Maybe post it in the Suggestions forum?