Setting blending-function in GLSL

Hello!

Would it be possible to set the blending-functions to be used for a fragment from withing a fragment shader to allow constructs like


if(someCondition) gl_DstBlendFactor = X;
else gl_DstBlendFactor = Y;

Searching for this I’ve found this old thread and wonder what happened. Nonetheless something like the above, which I deem much simpler, would be enough for my needs.
Or is there already such functionality which google won’t show me?

Would it be possible

Not in any hardware currently existing. Or at least, not in any hardware currently existing that isn’t capable of implementing blending in the fragment shader.

Now, you can use dual source blending. This won’t let you change the actual blending factor, but it will give you a second color output, which could be applied to the destination color. You can affect the value, but of course, it has to be a value accessible/computeable from the fragment shader (ie: not based on the destination color).

Searching for this I’ve found this old thread and wonder what happened.

What do you mean “what happened?” Posting things on this forum has little if any bearing on what actually gets into OpenGL. Just because someone asked for something doesn’t mean that it was ever going to happen.

What do you mean “what happened?” Posting things on this forum has little if any bearing on what actually gets into OpenGL. Just because someone asked for something doesn’t mean that it was ever going to happen.

That’s clear. Nonetheless the extension you linked is a proof that thought has already been spent on the issue be it for whatever reason.
Altough - that’s an oppinion - I’d say that - if going to make blending programmable - this should definitely be done in a pipeline-stage for it’s own.

Regarding the extension you linked: This is an ES-extension. Are those actually ever intended to be available in general GL?

I’ll have a closer look on dual-source blending. I cannot intuitively say if/how this is going to solve the issue. Maybe I’ll have to use the stencil and render things twice.

Nonetheless the extension you linked is a proof that thought has already been spent on the issue be it for whatever reason.

Or that a particular piece of hardware just so happened to be able to provide the functionality as an outgrowth of the basic hardware design (being a tile-based renderer, for example).

Are those actually ever intended to be available in general GL?

No. I was simply pointing out that there is hardware that can pull off programmatic blending directly. I could not simply say “no hardware can do what you want”, because hardware that implements that extension can.

Okay. Thank you.

I’ve often asked myself the question if there’re documents publicly available that describe the actual functionality of graphics-hardware in how they work exactly. There seems to be much consideration about intellectual property rights in this area - at least the last times I googled for such things. This makes judgeing many aspects that a programmer is confronted with when using an API like OpenGL quite difficult. The CPU and the hardware in general seems to be a lot better documented - at least when looking at PC hardware - from a public point of view.