-
Notifications
You must be signed in to change notification settings - Fork 3
/
smaaEdge.frag
123 lines (73 loc) · 2.95 KB
/
smaaEdge.frag
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
Copyright (c) 2015-2024 Alternative Games Ltd / Turo Lamminen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#version 450 core
#include "shaderDefines.h"
#define SMAA_RT_METRICS screenSize
#define SMAA_GLSL_4 1
#define SMAA_INCLUDE_PS 1
#define SMAA_INCLUDE_VS 0
#ifdef VULKAN_FLIP
#define SMAA_FLIP_Y 0
#endif
#ifndef EDGEMETHOD
#define EDGEMETHOD 0
#endif
#define SMAA_PREDICATION_THRESHOLD predicationThreshold
#define SMAA_PREDICATION_SCALE predicationScale
#define SMAA_PREDICATION_STRENGTH predicationStrength
layout(set = 0, binding = 1) uniform sampler LinearSampler;
layout(set = 0, binding = 2) uniform sampler PointSampler;
#include "smaa.h"
layout (location = 0) out vec4 outColor;
#if EDGEMETHOD == 2
layout(set = 0, binding = 3) uniform SMAATexture2D(depthTex);
#else // EDGEMETHOD
layout(set = 0, binding = 3) uniform SMAATexture2D(colorTex);
#endif // EDGEMETHOD
#if SMAA_PREDICATION
layout(set = 0, binding = 4) uniform SMAATexture2D(predicationTex);
#endif // SMAA_PREDICATION
layout (location = 0) in vec2 texcoord;
layout (location = 1) in vec4 offset0;
layout (location = 2) in vec4 offset1;
layout (location = 3) in vec4 offset2;
void main(void)
{
vec4 offsets[3];
offsets[0] = offset0;
offsets[1] = offset1;
offsets[2] = offset2;
#if EDGEMETHOD == 0
#if SMAA_PREDICATION
outColor = vec4(SMAAColorEdgeDetectionPS(texcoord, offsets, colorTex, predicationTex), 0.0, 0.0);
#else // SMAA_PREDICATION
outColor = vec4(SMAAColorEdgeDetectionPS(texcoord, offsets, colorTex), 0.0, 0.0);
#endif // SMAA_PREDICATION
#elif EDGEMETHOD == 1
#if SMAA_PREDICATION
outColor = vec4(SMAALumaEdgeDetectionPS(texcoord, offsets, colorTex, predicationTex), 0.0, 0.0);
#else // SMAA_PREDICATION
outColor = vec4(SMAALumaEdgeDetectionPS(texcoord, offsets, colorTex), 0.0, 0.0);
#endif // SMAA_PREDICATION
#elif EDGEMETHOD == 2
outColor = vec4(SMAADepthEdgeDetectionPS(texcoord, offsets, depthTex), 0.0, 0.0);
#else
#error Bad EDGEMETHOD
#endif
}