简体   繁体   中英

Photoshop “blend modes” with OpenGL

I am planning to make a simple drawing tool, which supports multiple layers and all blend modes from Photoshop.

I am considering to do the blending on the GPU (put each layer into a texture and draw 2 triangles to render each layer). But I am not sure, if it is possible to implement all the blend modes with OpenGL's blendFunc / blendEquation etc.

Another opiton is to pass all the textures + blend mode flags to one fragment shader and blend them just as I wish, but I will have to recompile FS when adding / removing some layer (sampler2D).

So what do you think? Is it possible? Are there some better ways how to use GPU for blending? Sohould I care about it now, or should I make it all on CPU and care about enhancements in the future?

BTW. it will be JavaScript program using WebGL, but I think it does not matter.

Of course you can. But it need to be done in sharers.

Load two pictures (actually can be more), render triangles. But then just use your shaders to probe both textures and mix those values with equation that is dependent on current blend mode (provided as uniform).

PS do not forget to turn off mipmaps, and filtering.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM