mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-30 20:13:22 +08:00
16 lines
336 B
GLSL
16 lines
336 B
GLSL
#version 330 core
|
|
in vec4 FragPos;
|
|
|
|
uniform vec3 lightPos;
|
|
uniform float far_plane;
|
|
|
|
void main()
|
|
{
|
|
float lightDistance = length(FragPos.xyz - lightPos);
|
|
|
|
// map to [0;1] range by dividing by far_plane
|
|
lightDistance = lightDistance / far_plane;
|
|
|
|
// write this as modified depth
|
|
gl_FragDepth = lightDistance;
|
|
} |