-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathpixellate.glsl
175 lines (169 loc) · 4.49 KB
/
pixellate.glsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// GLSL shader autogenerated by cg2glsl.py.
#if defined(VERTEX)
#if __VERSION__ >= 130
#define COMPAT_VARYING out
#define COMPAT_ATTRIBUTE in
#define COMPAT_TEXTURE texture
#else
#define COMPAT_VARYING varying
#define COMPAT_ATTRIBUTE attribute
#define COMPAT_TEXTURE texture2D
#endif
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
COMPAT_VARYING float _frame_rotation;
struct input_dummy {
vec2 _video_size;
vec2 _texture_size;
vec2 _output_dummy_size;
float _frame_count;
float _frame_direction;
float _frame_rotation;
};
vec4 _oPosition1;
vec4 _r0005;
COMPAT_ATTRIBUTE vec4 VertexCoord;
COMPAT_ATTRIBUTE vec4 TexCoord;
COMPAT_VARYING vec4 TEX0;
uniform mat4 MVPMatrix;
uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
void main()
{
vec2 _oTex;
_r0005 = VertexCoord.x*MVPMatrix[0];
_r0005 = _r0005 + VertexCoord.y*MVPMatrix[1];
_r0005 = _r0005 + VertexCoord.z*MVPMatrix[2];
_r0005 = _r0005 + VertexCoord.w*MVPMatrix[3];
_oPosition1 = _r0005;
_oTex = TexCoord.xy;
gl_Position = _r0005;
TEX0.xy = TexCoord.xy;
}
#elif defined(FRAGMENT)
#if __VERSION__ >= 130
#define COMPAT_VARYING in
#define COMPAT_TEXTURE texture
out vec4 FragColor;
#else
#define COMPAT_VARYING varying
#define FragColor gl_FragColor
#define COMPAT_TEXTURE texture2D
#endif
#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
COMPAT_VARYING float _frame_rotation;
struct input_dummy {
vec2 _video_size;
vec2 _texture_size;
vec2 _output_dummy_size;
float _frame_count;
float _frame_direction;
float _frame_rotation;
};
vec4 _ret_0;
vec2 _TMP11;
vec4 _TMP9;
vec2 _TMP8;
vec4 _TMP7;
vec2 _TMP6;
vec4 _TMP5;
vec2 _TMP4;
vec4 _TMP3;
vec2 _TMP2;
float _TMP1;
float _TMP0;
uniform sampler2D Texture;
input_dummy _IN1;
float _a0016;
float _a0018;
vec2 _x0020;
vec2 _c0022;
vec2 _x0024;
vec2 _c0026;
vec2 _x0028;
vec2 _c0030;
vec2 _x0032;
vec2 _c0034;
vec2 _TMP35;
vec2 _a0036;
vec2 _x0038;
vec2 _TMP39;
vec2 _b0040;
vec2 _x0040;
vec2 _a0040;
COMPAT_VARYING vec4 TEX0;
uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
void main()
{
vec2 _texelSize;
vec2 _range;
float _left;
float _top;
float _right;
float _bottom;
float _totalArea;
vec3 _averageColor;
_texelSize = 1.00000000E+00/TextureSize;
_a0016 = InputSize.x/(OutputSize.x*TextureSize.x);
_TMP0 = abs(_a0016);
_a0018 = InputSize.y/(OutputSize.y*TextureSize.y);
_TMP1 = abs(_a0018);
_range = vec2(_TMP0, _TMP1);
_range = (_range/2.00000000E+00)*9.99000013E-01;
_left = TEX0.x - _range.x;
_top = TEX0.y + _range.y;
_right = TEX0.x + _range.x;
_bottom = TEX0.y - _range.y;
_x0020 = vec2(_left, _top)/_texelSize;
_TMP2 = floor(_x0020);
_c0022 = (_TMP2 + 5.00000000E-01)*_texelSize;
_TMP3 = COMPAT_TEXTURE(Texture, _c0022);
_x0024 = vec2(_right, _bottom)/_texelSize;
_TMP4 = floor(_x0024);
_c0026 = (_TMP4 + 5.00000000E-01)*_texelSize;
_TMP5 = COMPAT_TEXTURE(Texture, _c0026);
_x0028 = vec2(_left, _bottom)/_texelSize;
_TMP6 = floor(_x0028);
_c0030 = (_TMP6 + 5.00000000E-01)*_texelSize;
_TMP7 = COMPAT_TEXTURE(Texture, _c0030);
_x0032 = vec2(_right, _top)/_texelSize;
_TMP8 = floor(_x0032);
_c0034 = (_TMP8 + 5.00000000E-01)*_texelSize;
_TMP9 = COMPAT_TEXTURE(Texture, _c0034);
_a0036 = TEX0.xy/_texelSize;
_x0038 = _a0036 + 5.00000000E-01;
_TMP35 = floor(_x0038);
_x0040 = _TMP35*_texelSize;
_a0040 = vec2(_left, _bottom);
_b0040 = vec2(_right, _top);
_TMP11 = min(_b0040, _x0040);
_TMP39 = max(_a0040, _TMP11);
_totalArea = 4.00000000E+00*_range.x*_range.y;
_averageColor = (((_TMP39.x - _left)*(_top - _TMP39.y))/_totalArea)*_TMP3.xyz;
_averageColor = _averageColor + (((_right - _TMP39.x)*(_TMP39.y - _bottom))/_totalArea)*_TMP5.xyz;
_averageColor = _averageColor + (((_TMP39.x - _left)*(_TMP39.y - _bottom))/_totalArea)*_TMP7.xyz;
_averageColor = _averageColor + (((_right - _TMP39.x)*(_top - _TMP39.y))/_totalArea)*_TMP9.xyz;
_ret_0 = vec4(_averageColor.x, _averageColor.y, _averageColor.z, 1.00000000E+00);
FragColor = _ret_0;
return;
}
#endif