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
37uniform vec2 texSize;
38
39/* VERTEX_SHADER */
40void main()
41{
42 gl_Position = position;
43
44 vec2 ps = vec2(1.0) / texSize;
45 float dx = ps.x;
46 float dy = ps.y;
47
48 // A1 B1 C1
49 // A0 A B C C4
50 // D0 D E F F4
51 // G0 G H I I4
52 // G5 H5 I5
53
54 texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
55 TEX1 = texCoord.xxxy + vec4( -dx, 0, dx,-2.0*dy); // A1 B1 C1
56 TEX2 = texCoord.xxxy + vec4( -dx, 0, dx, -dy); // A B C
57 TEX3 = texCoord.xxxy + vec4( -dx, 0, dx, 0); // D E F
58 TEX4 = texCoord.xxxy + vec4( -dx, 0, dx, dy); // G H I
59 TEX5 = texCoord.xxxy + vec4( -dx, 0, dx, 2.0*dy); // G5 H5 I5
60 TEX6 = texCoord.xyyy + vec4(-2.0*dx,-dy, 0, dy); // A0 D0 G0
61 TEX7 = texCoord.xyyy + vec4( 2.0*dx,-dy, 0, dy); // C4 F4 I4
62}