forked from LukasBanana/LLGL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostProcess.450core.vert
More file actions
47 lines (40 loc) · 882 Bytes
/
PostProcess.450core.vert
File metadata and controls
47 lines (40 loc) · 882 Bytes
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
// GLSL post-processor vertex shader
#version 450 core
layout(location = 0) out vec2 vTexCoord;
out gl_PerVertex
{
vec4 gl_Position;
};
/*
This function generates the coordinates for a fullscreen triangle with its vertex IDs:
(-1,+3)
*
| \
| \
| \
| \
(-1,+1) (+1,+1)
*----------*\
| | \
| screen | \
| | \
*----------*--------*
(-1,-1) (+1,-1) (+3,-1)
*/
vec4 GetFullscreenTriangleVertex(int id)
{
return vec4(
(id == 2 ? 3.0 : -1.0),
(id == 0 ? 3.0 : -1.0),
1.0,
1.0
);
}
void main()
{
// Generate coorindate for fullscreen triangle
gl_Position = GetFullscreenTriangleVertex(gl_VertexIndex);
// Get texture-coordinate from vertex position
// -> Don't flip U-tex-coord here (like in HLSL), due to different coordinate system
vTexCoord = gl_Position.xy * vec2(0.5, -0.5) + 0.5;
}