Revision 42e08626
Added by Leszek Koltunski almost 8 years ago
src/main/res/raw/main_fragment_shader.glsl | ||
---|---|---|
33 | 33 |
// next describes the Region, i.e. area over which the effect is active. |
34 | 34 |
|
35 | 35 |
const vec3 LUMI = vec3( 0.2125, 0.7154, 0.0721 ); |
36 |
|
|
37 |
////////////////////////////////////////////////////////////////////////////////////////////// |
|
38 |
// MACROBLOCK EFFECT |
|
39 |
|
|
40 |
void macroblock(float degree, int effect, inout vec2 tex) |
|
41 |
{ |
|
42 |
vec2 one = vec2(1.0,1.0); |
|
43 |
vec2 a = degree*(fUniforms[effect].yz-one)+one; |
|
44 |
tex = ( max((1.0-degree)*tex,floor(tex*a)) + degree*vec2(0.5,0.5) ) / a; |
|
45 |
} |
|
46 | 36 |
|
47 | 37 |
////////////////////////////////////////////////////////////////////////////////////////////// |
48 | 38 |
// CHROMA EFFECT |
... | ... | |
91 | 81 |
|
92 | 82 |
void main() |
93 | 83 |
{ |
94 |
vec2 tex = v_TexCoordinate; |
|
95 |
vec4 col = texture2D(u_Texture, tex); |
|
84 |
vec4 pixel = texture2D(u_Texture,v_TexCoordinate); |
|
96 | 85 |
|
97 | 86 |
#if NUM_FRAGMENT>0 |
98 | 87 |
vec2 diff; |
... | ... | |
103 | 92 |
diff = (v_Position.xy - fUniforms[2*i+1].xy)/fUniforms[2*i+1].zw; |
104 | 93 |
pointDegree = max(0.0,1.0-dot(diff,diff)); |
105 | 94 |
|
106 |
if( fType[i]==MACROBLOCK ) macroblock(sign(pointDegree),2*i,tex); |
|
107 |
else if( fType[i]==CHROMA ) chroma (sign(pointDegree),2*i,col); |
|
108 |
else if( fType[i]==SMOOTH_CHROMA ) chroma ( pointDegree ,2*i,col); |
|
109 |
else if( fType[i]==ALPHA ) alpha (sign(pointDegree),2*i,col); |
|
110 |
else if( fType[i]==SMOOTH_ALPHA ) alpha ( pointDegree ,2*i,col); |
|
111 |
else if( fType[i]==BRIGHTNESS ) brightness(sign(pointDegree),2*i,col); |
|
112 |
else if( fType[i]==SMOOTH_BRIGHTNESS ) brightness( pointDegree ,2*i,col); |
|
113 |
else if( fType[i]==CONTRAST ) contrast (sign(pointDegree),2*i,col); |
|
114 |
else if( fType[i]==SMOOTH_CONTRAST ) contrast ( pointDegree ,2*i,col); |
|
115 |
else if( fType[i]==SATURATION ) saturation(sign(pointDegree),2*i,col); |
|
116 |
else if( fType[i]==SMOOTH_SATURATION ) saturation( pointDegree ,2*i,col); |
|
95 |
if( fType[i]==CHROMA ) chroma (sign(pointDegree),2*i,pixel); |
|
96 |
else if( fType[i]==SMOOTH_CHROMA ) chroma ( pointDegree ,2*i,pixel); |
|
97 |
else if( fType[i]==ALPHA ) alpha (sign(pointDegree),2*i,pixel); |
|
98 |
else if( fType[i]==SMOOTH_ALPHA ) alpha ( pointDegree ,2*i,pixel); |
|
99 |
else if( fType[i]==BRIGHTNESS ) brightness(sign(pointDegree),2*i,pixel); |
|
100 |
else if( fType[i]==SMOOTH_BRIGHTNESS ) brightness( pointDegree ,2*i,pixel); |
|
101 |
else if( fType[i]==CONTRAST ) contrast (sign(pointDegree),2*i,pixel); |
|
102 |
else if( fType[i]==SMOOTH_CONTRAST ) contrast ( pointDegree ,2*i,pixel); |
|
103 |
else if( fType[i]==SATURATION ) saturation(sign(pointDegree),2*i,pixel); |
|
104 |
else if( fType[i]==SMOOTH_SATURATION ) saturation( pointDegree ,2*i,pixel); |
|
117 | 105 |
} |
118 | 106 |
#endif |
119 | 107 |
|
120 |
gl_FragColor = vec4(col.rgb * 0.5 * (v_Normal.z+1.0), col.a);
|
|
108 |
gl_FragColor = vec4(pixel.rgb * 0.5 * (v_Normal.z+1.0), pixel.a);
|
|
121 | 109 |
} |
Also available in: Unified diff
Remove the MACROBLOCK Effect altogether.