summaryrefslogtreecommitdiff
path: root/advanced_opengl/1.depth/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'advanced_opengl/1.depth/shaders')
-rw-r--r--advanced_opengl/1.depth/shaders/depth.frag (renamed from advanced_opengl/1.depth/shaders/depth.fs)10
-rw-r--r--advanced_opengl/1.depth/shaders/depth.vert (renamed from advanced_opengl/1.depth/shaders/depth.vs)7
2 files changed, 6 insertions, 11 deletions
diff --git a/advanced_opengl/1.depth/shaders/depth.fs b/advanced_opengl/1.depth/shaders/depth.frag
index a515c15..710b0d2 100644
--- a/advanced_opengl/1.depth/shaders/depth.fs
+++ b/advanced_opengl/1.depth/shaders/depth.frag
@@ -9,19 +9,15 @@ uniform sampler2D our_texture;
float near = 0.1;
float far = 100.0;
-float
-linearize_depth(float depth)
+float linearize_depth(float depth)
{
float ndc_z = 2.0*depth-1.0;
return((2.0*near*far)/(far+near-ndc_z*(far-near)));
}
-void
-main(void)
+void main(void)
{
- /*
- frag_color = texture(our_texture, tex_coords);
- */
+ /* frag_color = texture(our_texture, tex_coords); */
float depth = linearize_depth(gl_FragCoord.z)/far;
frag_color = vec4(vec3(depth), 1.0);
}
diff --git a/advanced_opengl/1.depth/shaders/depth.vs b/advanced_opengl/1.depth/shaders/depth.vert
index 62e71a2..68b8fe2 100644
--- a/advanced_opengl/1.depth/shaders/depth.vs
+++ b/advanced_opengl/1.depth/shaders/depth.vert
@@ -4,13 +4,12 @@ layout(location = 1) in vec2 atex_coords;
uniform mat4 model;
uniform mat4 view;
-uniform mat4 projection;
+uniform mat4 proj;
out vec2 tex_coords;
-void
-main(void)
+void main(void)
{
- gl_Position = projection*view*model*vec4(apos, 1.0);
+ gl_Position = proj*view*model*vec4(apos, 1.0);
tex_coords = atex_coords;
}