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
|
// Pass-2: AA on Texture
// Note: gcv_FboTexCoord is in center of sample pixels.
float sampleCount = gcu_FboTexSize.z;
vec2 psize = 1.0 / gcu_FboTexSize.xy; // pixel size
// Just poles (NW, SW, ..)
float sample_weight = 1 / ( 2 * sampleCount );
vec2 texCoord = gcv_FboTexCoord.st;
vec4 t;
// SampleCount 2 -> 4x
t = texture2D(gcu_FboTexUnit, texCoord + psize*(vec2(-0.5, -0.5)))*sample_weight; // NW
t += texture2D(gcu_FboTexUnit, texCoord + psize*(vec2(-0.5, 0.5)))*sample_weight; // SW
t += texture2D(gcu_FboTexUnit, texCoord + psize*(vec2( 0.5, 0.5)))*sample_weight; // SE
t += texture2D(gcu_FboTexUnit, texCoord + psize*(vec2( 0.5, -0.5)))*sample_weight; // NE
if( sampleCount > 2.0 ) {
// SampleCount 4 -> +4 = 8p
t += texture2D(gcu_FboTexUnit, texCoord + psize*(vec2(-1.5, -1.5)))*sample_weight; // NW
t += texture2D(gcu_FboTexUnit, texCoord + psize*(vec2(-1.5, 1.5)))*sample_weight; // SW
t += texture2D(gcu_FboTexUnit, texCoord + psize*(vec2( 1.5, 1.5)))*sample_weight; // SE
t += texture2D(gcu_FboTexUnit, texCoord + psize*(vec2( 1.5, -1.5)))*sample_weight; // NE
if( sampleCount > 4.0 ) {
// SampleCount 6 -> +4 = 12p
t += texture2D(gcu_FboTexUnit, texCoord + psize*(vec2(-2.5, -2.5)))*sample_weight; // NW
t += texture2D(gcu_FboTexUnit, texCoord + psize*(vec2(-2.5, 2.5)))*sample_weight; // SW
t += texture2D(gcu_FboTexUnit, texCoord + psize*(vec2( 2.5, 2.5)))*sample_weight; // SE
t += texture2D(gcu_FboTexUnit, texCoord + psize*(vec2( 2.5, -2.5)))*sample_weight; // NE
if( sampleCount > 6.0 ) {
// SampleCount 8 -> +4 = 16p
t += texture2D(gcu_FboTexUnit, texCoord + psize*(vec2(-3.5, -3.5)))*sample_weight; // NW
t += texture2D(gcu_FboTexUnit, texCoord + psize*(vec2(-3.5, 3.5)))*sample_weight; // SW
t += texture2D(gcu_FboTexUnit, texCoord + psize*(vec2( 3.5, 3.5)))*sample_weight; // SE
t += texture2D(gcu_FboTexUnit, texCoord + psize*(vec2( 3.5, -3.5)))*sample_weight; // NE
}
}
}
#if USE_DISCARD
if( 0.0 == t.w ) {
discard; // discard freezes NV tegra2 compiler
} else {
mgl_FragColor = t;
}
#else
mgl_FragColor = t;
#endif
|