forked from dmnsgn/glsl-smaa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmaa-weights.vert
More file actions
executable file
·44 lines (33 loc) · 1.22 KB
/
smaa-weights.vert
File metadata and controls
executable file
·44 lines (33 loc) · 1.22 KB
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
#define mad(a, b, c) (a * b + c)
#if defined(SMAA_PRESET_LOW)
#define SMAA_MAX_SEARCH_STEPS 4
#elif defined(SMAA_PRESET_MEDIUM)
#define SMAA_MAX_SEARCH_STEPS 8
#elif defined(SMAA_PRESET_HIGH)
#define SMAA_MAX_SEARCH_STEPS 16
#elif defined(SMAA_PRESET_ULTRA)
#define SMAA_MAX_SEARCH_STEPS 32
#endif
#ifndef SMAA_MAX_SEARCH_STEPS
#define SMAA_MAX_SEARCH_STEPS 16
#endif
attribute vec2 aPosition;
uniform vec2 resolution;
varying vec2 vTexCoord0;
varying vec2 vPixCoord;
varying vec4 vOffset[3];
void main() {
vec4 SMAA_RT_METRICS = vec4(1.0 / resolution.x, 1.0 / resolution.y, resolution.x, resolution.y);
vTexCoord0 = vec2((aPosition + 1.0) / 2.0);
vPixCoord = vTexCoord0 * SMAA_RT_METRICS.zw;
// We will use these offsets for the searches later on (see @PSEUDO_GATHER4):
vOffset[0] = mad(SMAA_RT_METRICS.xyxy, vec4(-0.25, -0.125, 1.25, -0.125), vTexCoord0.xyxy);
vOffset[1] = mad(SMAA_RT_METRICS.xyxy, vec4(-0.125, -0.25, -0.125, 1.25), vTexCoord0.xyxy);
// And these for the searches, they indicate the ends of the loops:
vOffset[2] = mad(
SMAA_RT_METRICS.xxyy,
vec4(-2.0, 2.0, -2.0, 2.0) * float(SMAA_MAX_SEARCH_STEPS),
vec4(vOffset[0].xz, vOffset[1].yw)
);
gl_Position = vec4(aPosition, 0.0, 1.0);
}