1 #ifndef VERTEX_SHADER_BLUR_RESIZE_HORIZONTAL_H
2 #define VERTEX_SHADER_BLUR_RESIZE_HORIZONTAL_H
3
4 ///////////////////////////////// MIT LICENSE ////////////////////////////////
5
6 // Copyright (C) 2014 TroggleMonkey
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25
26
27 ///////////////////////////// SETTINGS MANAGEMENT ////////////////////////////
28
29 // PASS SETTINGS:
30 // Pass settings should be set by the shader file that #includes this one.
31
32
33 ////////////////////////////////// INCLUDES //////////////////////////////////
34
35 //#include "../include/gamma-management.h"
36 //#include "../include/blur-functions.h"
37
38 #pragma stage vertex
39 layout(location = 0) in vec4 Position;
40 layout(location = 1) in vec2 TexCoord;
41 layout(location = 0) out vec2 tex_uv;
42 layout(location = 1) out vec2 blur_dxdy;
43
main()44 void main()
45 {
46 gl_Position = global.MVP * Position;
47 tex_uv = TexCoord;
48
49 // Get the uv sample distance between output pixels. Blurs are not generic
50 // Gaussian resizers, and correct blurs require:
51 // 1.) OutputSize.xy == SourceSize.xy * 2^m, where m is an integer <= 0.
52 // 2.) mipmap_inputN = "true" for this pass in .cgp preset if m != 0
53 // 3.) filter_linearN = "true" except for 1x scale nearest neighbor blurs
54 // Arbitrary upsizing will be acceptable if filter_linearN = "true", and
55 // arbitrary downsizing will be acceptable if mipmap_inputN = "true" too.
56 // Only the "resize" blurs can manage this though, and they still aren't
57 // proper Gaussian resizers (because they sample between texels and always
58 // blur after resizing, not during).
59 const vec2 dxdy_scale = params.SourceSize.xy * params.OutputSize.zw;
60 const vec2 dxdy = dxdy_scale * params.SourceSize.zw;
61 // This blur is horizontal-only, so zero out the vertical offset:
62 blur_dxdy = vec2(dxdy.x, 0.0);
63 }
64
65 #endif // VERTEX_SHADER_BLUR_RESIZE_HORIZONTAL_H