Imaging & Videochevron_right
Softwarechevron_right
Hardwarechevron_right
Realizar la conversion de una imagen a un foto mosaico por Hardware.
1link> precision mediump float;
2link>
3link> uniform sampler2D image;
4link>
5link> uniform sampler2D symbol1;
6link> uniform sampler2D symbol2;
7link> uniform sampler2D symbol3;
8link> uniform sampler2D symbol4;
9link> uniform sampler2D symbol5;
10link> uniform sampler2D symbol6;
11link> uniform sampler2D symbol7;
12link> uniform sampler2D symbol8;
13link> uniform sampler2D symbol9;
14link> uniform sampler2D symbol10;
15link> uniform sampler2D symbol11;
16link> uniform sampler2D symbol12;
17link> uniform sampler2D symbol13;
18link> uniform sampler2D symbol14;
19link> uniform sampler2D symbol15;
20link> uniform sampler2D symbol16;
21link> uniform sampler2D symbol17;
22link> uniform sampler2D symbol18;
23link> uniform sampler2D symbol19;
24link> uniform sampler2D symbol20;
25link> uniform sampler2D symbol21;
26link> uniform sampler2D symbol22;
27link> uniform sampler2D symbol23;
28link> uniform sampler2D symbol24;
29link> uniform sampler2D symbol25;
30link> uniform sampler2D symbol26;
31link> uniform sampler2D symbol27;
32link>
33link> uniform bool debug;
34link>
35link> uniform float resolution;
36link>
37link> varying vec4 vVertexColor;
38link>
39link> varying vec2 vTexCoord;
40link>
41link> void main() {
42link>
43link> vec2 symbolCoord = vTexCoord * resolution;
44link> vec2 imageCoord = floor(symbolCoord);
45link> symbolCoord = symbolCoord - imageCoord;
46link> vec4 col = texture2D(image, vTexCoord) * vVertexColor;
47link> float grayLuma = dot(col.rgb, vec3(1, 1, 1));
48link> float r = col.r * 255.0;
49link> float g = col.g * 255.0;
50link> float b = col.b * 255.0;
51link>
52link> if(r > 170.0)
53link> if(g > 170.0)
54link> if(b > 127.0)
55link> gl_FragColor = texture2D(symbol21, symbolCoord) * vVertexColor;
56link> else
57link> gl_FragColor = texture2D(symbol13, symbolCoord) * vVertexColor;
58link> else if(g > 85.0)
59link> if(b > 127.0)
60link> gl_FragColor = texture2D(symbol18, symbolCoord) * vVertexColor;
61link> else
62link> gl_FragColor = texture2D(symbol21, symbolCoord) * vVertexColor;
63link> else if(b > 127.0)
64link> gl_FragColor = texture2D(symbol23, symbolCoord) * vVertexColor;
65link> else
66link> gl_FragColor = texture2D(symbol11, symbolCoord) * vVertexColor;
67link> else if(r > 85.0)
68link> if(g > 170.0)
69link> if(b > 127.0)
70link> gl_FragColor = texture2D(symbol17, symbolCoord) * vVertexColor;
71link> else
72link> gl_FragColor = texture2D(symbol23, symbolCoord) * vVertexColor;
73link> else if(g > 85.0)
74link> if(b > 127.0)
75link> gl_FragColor = texture2D(symbol15, symbolCoord) * vVertexColor;
76link> else
77link> gl_FragColor = texture2D(symbol7, symbolCoord) * vVertexColor;
78link> else if(b > 127.0)
79link> gl_FragColor = texture2D(symbol25, symbolCoord) * vVertexColor;
80link> else
81link> gl_FragColor = texture2D(symbol5, symbolCoord) * vVertexColor;
82link> else if(g > 170.0)
83link> if(b > 127.0)
84link> gl_FragColor = texture2D(symbol25, symbolCoord) * vVertexColor;
85link> else
86link> gl_FragColor = texture2D(symbol9, symbolCoord) * vVertexColor;
87link> else if(g > 85.0)
88link> if(b > 127.0)
89link> gl_FragColor = texture2D(symbol27, symbolCoord) * vVertexColor;
90link> else
91link> gl_FragColor = texture2D(symbol3, symbolCoord) * vVertexColor;
92link> else if(b > 127.0)
93link> gl_FragColor = texture2D(symbol8, symbolCoord) * vVertexColor;
94link> else
95link> gl_FragColor = texture2D(symbol1, symbolCoord) * vVertexColor;
96link> }