Revision 94f6d472
Added by Leszek Koltunski about 7 years ago
src/main/res/raw/blur2_fragment_shader.glsl | ||
---|---|---|
19 | 19 |
|
20 | 20 |
precision lowp float; |
21 | 21 |
|
22 |
#if __VERSION__ != 100 |
|
23 |
#define TEXTURE texture |
|
22 | 24 |
in vec2 v_TexCoordinate; |
23 | 25 |
out vec4 fragColor; |
26 |
#else |
|
27 |
#define TEXTURE texture2D |
|
28 |
varying vec2 v_TexCoordinate; |
|
29 |
#endif |
|
30 |
|
|
24 | 31 |
uniform sampler2D u_ColorTexture; |
25 | 32 |
uniform sampler2D u_DepthTexture; |
26 | 33 |
uniform float u_Offsets[MAX_BLUR]; |
... | ... | |
31 | 38 |
|
32 | 39 |
void main() |
33 | 40 |
{ |
34 |
gl_FragDepth = 0.0;//texture(u_DepthTexture,v_TexCoordinate);
|
|
41 |
gl_FragDepth = TEXTURE(u_DepthTexture,v_TexCoordinate).r;
|
|
35 | 42 |
|
36 |
vec4 pixel= texture(u_ColorTexture,v_TexCoordinate) * u_Weights[0];
|
|
43 |
vec4 pixel= TEXTURE(u_ColorTexture,v_TexCoordinate) * u_Weights[0];
|
|
37 | 44 |
|
38 | 45 |
for (int i=1; i<=u_Radius; i+=1) |
39 | 46 |
{ |
40 |
pixel += ( texture(u_ColorTexture,vec2(v_TexCoordinate.x+u_Offsets[i],v_TexCoordinate.y)) +
|
|
41 |
texture(u_ColorTexture,vec2(v_TexCoordinate.x-u_Offsets[i],v_TexCoordinate.y)) ) * u_Weights[i];
|
|
47 |
pixel += ( TEXTURE(u_ColorTexture,vec2(v_TexCoordinate.x+u_Offsets[i],v_TexCoordinate.y)) +
|
|
48 |
TEXTURE(u_ColorTexture,vec2(v_TexCoordinate.x-u_Offsets[i],v_TexCoordinate.y)) ) * u_Weights[i];
|
|
42 | 49 |
} |
43 | 50 |
|
44 |
fragColor = pixel; |
|
51 |
#if __VERSION__ != 100 |
|
52 |
fragColor = |
|
53 |
#else |
|
54 |
gl_FragColor = |
|
55 |
#endif |
|
56 |
|
|
57 |
pixel; |
|
45 | 58 |
} |
Also available in: Unified diff
Make it more flexible; now it can run almost all apps on OpenGL 2.0 contexts; OpenGL 3.0 ( with GLSL 3.00) required for POSTPROCESSING.