summary refs log tree commit diff
path: root/assets
diff options
context:
space:
mode:
Diffstat (limited to 'assets')
-rw-r--r--assets/shaders/fragment.glsl4
-rw-r--r--assets/shaders/vertex.glsl3
2 files changed, 6 insertions, 1 deletions
diff --git a/assets/shaders/fragment.glsl b/assets/shaders/fragment.glsl
index a7f019d..cc60d65 100644
--- a/assets/shaders/fragment.glsl
+++ b/assets/shaders/fragment.glsl
@@ -6,6 +6,7 @@ uniform vec3 sky_color;
 
 in vec3 surface_normal;
 in vec2 frag_tex_coord;
+in float frag_ambient_occlusion;
 in float depth;
 
 out vec4 color;
@@ -18,6 +19,7 @@ void main() {
     if (texture_color.a < 0.5) {
         discard;
     }
-    color = vec4(diffuse, 1.0) * texture_color;
+    float ao = 1 - frag_ambient_occlusion / 2;
+    color = vec4(diffuse, 1.0) * texture_color * ao;
     color = mix(vec4(sky_color, 1.0), color, 1 - depth);
 }
\ No newline at end of file
diff --git a/assets/shaders/vertex.glsl b/assets/shaders/vertex.glsl
index 3ca1055..1e56809 100644
--- a/assets/shaders/vertex.glsl
+++ b/assets/shaders/vertex.glsl
@@ -7,8 +7,10 @@ uniform mat4 projection_matrix;
 layout (location = 0) in vec3 position;
 layout (location = 1) in vec3 normal;
 layout (location = 2) in vec2 tex_coord;
+layout (location = 3) in float ambient_occlusion;
 
 out vec2 frag_tex_coord;
+out float frag_ambient_occlusion;
 out vec3 surface_normal;
 out float depth;
 
@@ -19,6 +21,7 @@ void main() {
 
     gl_Position = clip_position;
     frag_tex_coord = tex_coord;
+    frag_ambient_occlusion = ambient_occlusion;
     surface_normal = (model_matrix * vec4(normal, 0.0)).xyz;
     depth = clamp((length(view_position) - 75) / 125, 0.0, 1.0);
 }
\ No newline at end of file