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
|
[require]
GLSL >= 1.10
[vertex shader]
#version 120
#extension GL_ARB_texture_rectangle : enable
#define flat
#define texture2DRectOffset(sampler, coords, offset) texture2DRect(sampler, coords + vec2(offset))
#define shadow2DRectOffset(sampler, coords, offset) shadow2DRect(sampler, coords + vec2(offset))
attribute vec4 vvertex;
attribute vec2 vtexcoord0;
uniform float offsets[8];
varying vec2 texcoord0, texcoord1, texcoord2;
varying vec2 texcoord3, texcoord4;
varying vec2 texcoord5, texcoord6;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
vec2 tc1 = vtexcoord0.xy, tc2 = vtexcoord0;
tc1.y += offsets[1];
tc2.y -= offsets[1];
texcoord1 = tc1;
texcoord2 = tc2;
tc1.y = vtexcoord0.y + offsets[2];
tc2.y = vtexcoord0.y - offsets[2];
texcoord3 = tc1;
texcoord4 = tc2;
tc1.y = vtexcoord0.y + offsets[3];
tc2.y = vtexcoord0.y - offsets[3];
texcoord5 = tc1;
texcoord6 = tc2;
}
[fragment shader]
#version 120
#extension GL_ARB_texture_rectangle : enable
#define flat
#define texture2DRectOffset(sampler, coords, offset) texture2DRect(sampler, coords + vec2(offset))
#define shadow2DRectOffset(sampler, coords, offset) shadow2DRect(sampler, coords + vec2(offset))
#define fragdata(loc, name, type)
#define fragcolor gl_FragData[0]
uniform float weights[8];
uniform float offsets[8];
uniform sampler2DRect tex0;
varying vec2 texcoord0, texcoord1, texcoord2;
varying vec2 texcoord3, texcoord4;
varying vec2 texcoord5, texcoord6;
fragdata(0, fragcolor, vec4)
void main(void)
{
#define texval(coords) texture2DRect(tex0, (coords))
vec4 val = texval(texcoord0) * weights[0];
val += weights[1] * (texval(texcoord1) + texval(texcoord2));
val += weights[2] * (texval(texcoord3) + texval(texcoord4));
val += weights[3] * (texval(texcoord5) + texval(texcoord6));
val += weights[4] *
(texval(vec2(texcoord0.x, texcoord0.y + offsets[4])) + texval(vec2(texcoord0.x, texcoord0.y - offsets[4])));
val += weights[5] *
(texval(vec2(texcoord0.x, texcoord0.y + offsets[5])) + texval(vec2(texcoord0.x, texcoord0.y - offsets[5])));
val += weights[6] *
(texval(vec2(texcoord0.x, texcoord0.y + offsets[6])) + texval(vec2(texcoord0.x, texcoord0.y - offsets[6])));
val += weights[7] *
(texval(vec2(texcoord0.x, texcoord0.y + offsets[7])) + texval(vec2(texcoord0.x, texcoord0.y - offsets[7])));
fragcolor = val;
}
|