Blending in the GLSL

hi

can i use blending in the my shaders whit out enabling GL_BLEND??

No, you can’t

Damn you NiCo, answers like that are my speciality! Dont you dare do that again :slight_smile:

I’ll try to restrain myself in the future :wink:

Well you cant fetch whats in the framebuffer, because naturally it aint there till you write to gl_FragColor. But you could custom blend textures and write to gl_FragColor.

So yes and no :wink:

ruytsch, it is not correct. Of course there is a value in the framebuffer before you write the output color — it is precisely the value that was there before (from last rendered triangle, for example). The problem is, due to massively parallel design of GPUs it is not possible to alow fast framebuffer reads. While it is possible to render to textures and then ping-pong between them, this approach is useless on practice, as you’ll basically have to render each triangle to different textures to handle overlaping triangles correctly.

Sure you can read from the frame buffer if its a frame buffer object you are using, but I am not sure you will like the results you see. Since you would essentially reading and writting to the same target.

So to correct you Zengar, you its allowable to read and write, but no no guaranties are provided by the driver.

Ok, I should have used “ensure fast and correct framebuffer reads” instead.

Still, this doesn’t change the fact that your previous post was just wrong. You can’t say “can’t fetch whats in the framebuffer” in one post and then “its allowable to read and write” a post later. It is just not good practice.

Well if your framebuffer is a texture, you can read and write to it at the same time, nothing wrong with that :slight_smile:

Still a programmable blend unit with the framebuffer might be a great idea for future extensions :wink:

Blending is not possible in GLSL because the shader run only a single time for all samples of a MSAA rendertarget, but blending will be calculated for each sample.

Except for the fact that the results of such operation are undefined.

To make reading the framebuffer reliable you need at the very least some form of communication path between the render backend and the texture unit and synchronization between the two. Hardware generally don’t write everything to memory immediately, and even if the render backend cache would be disabled, the hardware would still need a way for the render backend to poke around and invalidate the texture cache.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.