SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
Shaders/AAScale2x.fsh
1 STATIC vec4 scale2x(sampler2D image, vec2 position, vec2 input_resolution, vec2 output_resolution)
2 {
3 // texel arrangement
4 // A B C
5 // D E F
6 // G H I
7 // vec4 A = texture(image, position + vec2( -o.x, o.y));
8 vec4 B = texture_relative(image, position, vec2( 0, 1));
9 vec4 D = texture_relative(image, position, vec2( -1, 0));
10 vec4 E = texture_relative(image, position, vec2( 0, 0));
11 vec4 F = texture_relative(image, position, vec2( 1, 0));
12 vec4 H = texture_relative(image, position, vec2( 0, -1));
13 vec2 p = position * input_resolution;
14 // p = the position within a pixel [0...1]
15 p = fract(p);
16 if (p.x > .5) {
17 if (p.y > .5) {
18 // Top Right
19 return equal(B, F) && inequal(B, D) && inequal(F, H) ? F : E;
20 } else {
21 // Bottom Right
22 return equal(H, F) && inequal(D, H) && inequal(B, F) ? F : E;
23 }
24 } else {
25 if (p.y > .5) {
26 // Top Left
27 return equal(D, B) && inequal(B, F) && inequal(D, H) ? D : E;
28 } else {
29 // Bottom Left
30 return equal(D, H) && inequal(D, B) && inequal(H, F) ? D : E;
31 }
32 }
33 }
34
35 STATIC vec4 scale(sampler2D image, vec2 position, vec2 input_resolution, vec2 output_resolution)
36 {
37 return mix(texture(image, position), scale2x(image, position, input_resolution, output_resolution), 0.5);
38 }
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.