The Depth Shader
Now we are writing the depth shader to calcualte the depth from the light source.
Create simpledepth.vert and simpledepth.frag under the shaders directory.
The Vertex Shader
We only need M V P marices to calculate gl_Position in the vertex shader.
Remember, the view and projection matrices are from the light source instead of the eye.
// simpledepth.vert
#version 410
layout (location = 0) in vec3 aPos;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main()
{
gl_Position = projection * view * model * vec4(aPos, 1.0);
} The Fragment Shader
There is nothing actually needed in the fragment shader as we are not going to draw any colour pixels.
However, to help us debug we can render the colour as the depth. Darker colours correspond to smaller value in Z and closer to the light source.
Last updated