-
Notifications
You must be signed in to change notification settings - Fork 8
/
firstPass.frag
33 lines (29 loc) · 1.01 KB
/
firstPass.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
#version 330 core
in vec4 clip_position;
//This means that when writing in the variable “color”, we will actually write in the Render Target 0,
//which happens to be our texture because DrawBuffers[0] is GL_COLOR_ATTACHMENTi, which is, in our case, renderedTexture.
layout(location = 0) out vec3 start_point;
layout(location = 1) out vec3 end_point;
//out vec4 FragColor;
/*
To store Front, Back Face in the correct texture of the framebuffer,
according to whether the fragment belongs to a front face or not,
and perform a conversion from two-unit cube coordinates (range [1,1])[NDC] to texture coordinates (range [0,1]).
*/
void main()
{
vec3 ndc_position = clip_position.xyz; // / clip_position.w;
if (gl_FrontFacing)
{
//start_point = 0.5 * (ndc_position + 1.0);
start_point = ndc_position + 0.5;
end_point = vec3(0);
}
else
{
start_point = vec3(0);
//end_point = 0.5 * (ndc_position + 1.0);
end_point = ndc_position + 0.5;
}
//FragColor = vec4(end_point, 1.0);
}