Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL Blend Modes vs Shader Blending

I'm currently doing some research on OpenGL and Shaders but I can't seem to figure out if there are any fundamental differences between blending using the glBlendMode or writing your own blend modes in a shader.

What are the reasons to choose the former or the latter? Are there any performance bottlenecks by choosing the one over the other? Or is this just a matter of personal preference?

like image 678
polyclick Avatar asked Jul 24 '12 15:07

polyclick


1 Answers

Traditional blending with glBlendFunc can't be replicated in a shader. Blending requires sampling the destination framebuffer before modifying it, which isn't something that can be done on current hardware.

Currently you can only pass along a color, and choose one of a limited selection of blending modes (glBlendFunc/glBlendEquation) which will be applied by the GPU's rasterizer before writing to framebuffer.

like image 197
Tim Avatar answered Oct 14 '22 21:10

Tim