diff options
author | pryazha <pryadeiniv@mail.ru> | 2025-01-19 17:33:44 +0500 |
---|---|---|
committer | pryazha <pryadeiniv@mail.ru> | 2025-01-19 17:33:44 +0500 |
commit | bd49bd525f4c6c6c15c4142bf42d1dd38be6fc16 (patch) | |
tree | 9e69f473c34b53e9e57d8af1873c39698bf5c80e /depth/shaders/depth.fs |
initial commit
Diffstat (limited to 'depth/shaders/depth.fs')
-rw-r--r-- | depth/shaders/depth.fs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/depth/shaders/depth.fs b/depth/shaders/depth.fs new file mode 100644 index 0000000..2f3d9ca --- /dev/null +++ b/depth/shaders/depth.fs @@ -0,0 +1,27 @@ +#version 330 core + +out vec4 frag_color; + +in vec2 tex_coords; + +uniform sampler2D our_texture; + +float near = 0.1f; +float far = 100.0f; + +float +linearize_depth(float depth) +{ + float ndc_z = 2.0f*depth-1.0f; + return((2.0f*near*far)/(far+near-ndc_z*(far-near))); +} + +void +main(void) +{ + /* + frag_color = texture(our_texture, tex_coords); + */ + float depth = linearize_depth(gl_FragCoord.z)/far; + frag_color = vec4(vec3(depth), 1.0f); +} |