all repos — mgba @ e08087a682c011bd8893803939b67419fdd61b18

mGBA Game Boy Advance Emulator

res/shaders/xbr.shader/xbr.vs (view raw)

 1/*
 2   Hyllian's xBR-lv3 Shader
 3   
 4   Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
 5
 6   Permission is hereby granted, free of charge, to any person obtaining a copy
 7   of this software and associated documentation files (the "Software"), to deal
 8   in the Software without restriction, including without limitation the rights
 9   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10   copies of the Software, and to permit persons to whom the Software is
11   furnished to do so, subject to the following conditions:
12
13   The above copyright notice and this permission notice shall be included in
14   all copies or substantial portions of the Software.
15
16   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22   THE SOFTWARE.
23
24   Incorporates some of the ideas from SABR shader. Thanks to Joshua Street.
25*/
26
27varying vec2 texCoord;
28varying vec4 TEX1;
29varying vec4 TEX2;
30varying vec4 TEX3;
31varying vec4 TEX4;
32varying vec4 TEX5;
33varying vec4 TEX6;
34varying vec4 TEX7;
35attribute vec4 position;
36
37/*    VERTEX_SHADER    */
38void main()
39{
40	gl_Position = position;
41
42	vec2 ps = vec2(1.0/240.0, 1.0/160.0);
43	float dx = ps.x;
44	float dy = ps.y;
45
46	//    A1 B1 C1
47	// A0  A  B  C C4
48	// D0  D  E  F F4
49	// G0  G  H  I I4
50	//    G5 H5 I5
51
52	texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
53	TEX1 = texCoord.xxxy + vec4( -dx, 0, dx,-2.0*dy); // A1 B1 C1
54	TEX2 = texCoord.xxxy + vec4( -dx, 0, dx,    -dy); //  A  B  C
55	TEX3 = texCoord.xxxy + vec4( -dx, 0, dx,      0); //  D  E  F
56	TEX4 = texCoord.xxxy + vec4( -dx, 0, dx,     dy); //  G  H  I
57	TEX5 = texCoord.xxxy + vec4( -dx, 0, dx, 2.0*dy); // G5 H5 I5
58	TEX6 = texCoord.xyyy + vec4(-2.0*dx,-dy, 0,  dy); // A0 D0 G0
59	TEX7 = texCoord.xyyy + vec4( 2.0*dx,-dy, 0,  dy); // C4 F4 I4
60}