diff options
| author | Mel <einebeere@gmail.com> | 2023-07-09 20:51:30 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2023-07-09 20:51:30 +0200 |
| commit | 680d9d5b7a61ac955fcec8a5622faa5cf4165c11 (patch) | |
| tree | 385ada2ac5e666ff4e89e073850c9e1a9b29c99e /assets | |
| parent | fe2baedc760c2f29e2c720f6b1132a2de33c5430 (diff) | |
| download | meowcraft-680d9d5b7a61ac955fcec8a5622faa5cf4165c11.tar.zst meowcraft-680d9d5b7a61ac955fcec8a5622faa5cf4165c11.zip | |
Ambient occlusion (without corners)
Diffstat (limited to 'assets')
| -rw-r--r-- | assets/shaders/fragment.glsl | 4 | ||||
| -rw-r--r-- | assets/shaders/vertex.glsl | 3 |
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 |
