I wanted to simulate 'glow dodge' effect on clip studio using opengl and its shader. So I found out that following equation is how 'glow dodge' works.
final.rgb = dest.rgb / (1 - source.rgb)
Then I came up with 2 ways to actually do it, but neither one doesn't seem to work.
First one was to calculate 1 / (1 - source.rgb)
in the shader, and do multiply blending by using glBlendfunc(GL_ZERO, GL_SRC_COLOR)
, or glBlendfunc(GL_DST_COLOR, GL_ZERO)
.
but as khronos page says, all scale factors have range 0 to 1. which means I can't multiply the numbers over 1. so I can't use this method cuz most of the case goes more than 1.
Second one was to bring background texels by using glReadPixel()
, then calculate everything in shader, then do additive blending by using glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
.
regardless the outcome I could get, glReadPixel()
itself takes way too much time even with a 30 x 30 texel area. so I can't use this method.
I wonder if there's any other way to get an outcome as glowdodge blending mode should have.