Start code re-work Advanced OpenGL chapter.

This commit is contained in:
Joey de Vries
2017-04-17 20:40:26 +02:00
parent fee7580547
commit 4b6b4d6377
63 changed files with 2419 additions and 686 deletions

View File

@@ -0,0 +1,16 @@
#version 330 core
out vec4 FragColor;
float near = 0.1;
float far = 100.0;
float LinearizeDepth(float depth)
{
float z = depth * 2.0 - 1.0; // back to NDC
return (2.0 * near * far) / (far + near - z * (far - near));
}
void main()
{
float depth = LinearizeDepth(gl_FragCoord.z) / far; // divide by far to get depth in range [0,1] for visualization purposes
FragColor = vec4(vec3(depth), 1.0);
}