How to Implement Overlay blend method using opengles 1.1
        Posted  
        
            by 
                Cylon
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Cylon
        
        
        
        Published on 2011-01-08T14:09:15Z
        Indexed on 
            2011/01/09
            8:54 UTC
        
        
        Read the original article
        Hit count: 345
        
Blow is the algorithm of overlay. and i want using it on iphone, but iphone 3g only support opengles 1.1, can not using glsl.
can i using blend function or texture combine to implement it.
thank you
/////////Reference from OpenGL Shading® Language Third Edition ///////////
19.6.12 Overlay
OVERLAY first computes the luminance of the base value.
If the luminance value is less than 0.5, the blend and base values are multiplied together.
If the luminance value is greater than 0.5, a screen operation is performed.
The effect is that the base value is mixed with the blend value, rather than being replaced.
This allows patterns and colors to overlay the base image, but shadows and highlights in the base image are preserved.
A discontinuity occurs where luminance = 0.5. To provide a smooth transition, we actually do a linear blend of the two equations for luminance in the range [0.45,0.55].
float luminance = dot(base, lumCoeff);
if (luminance < 0.45)
result = 2.0 * blend * base;
else if (luminance > 0.55)
result = white - 2.0 * (white - blend) * (white - base);
else {
vec4 result1 = 2.0 * blend * base;
vec4 result2 = white - 2.0 * (white - blend) * (white - base);
result = mix(result1, result2, (luminance - 0.45) * 10.0);
}
© Stack Overflow or respective owner