diff options
| author | Mel <einebeere@gmail.com> | 2023-07-21 02:17:03 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2023-07-21 02:17:03 +0200 |
| commit | 23d88e5f1c8f0c8652a07050fcfa8ff126e85d4a (patch) | |
| tree | d2979c12a9675885b7ed969d5f51dbd69d969286 /assets/shaders | |
| parent | c0556f76fc5c8271c2eaa7ca91ad1c92c691d8bc (diff) | |
| download | meowcraft-23d88e5f1c8f0c8652a07050fcfa8ff126e85d4a.tar.zst meowcraft-23d88e5f1c8f0c8652a07050fcfa8ff126e85d4a.zip | |
Extremely simple chunk-limited lighting
Diffstat (limited to 'assets/shaders')
| -rw-r--r-- | assets/shaders/fragment.glsl | 5 | ||||
| -rw-r--r-- | assets/shaders/vertex.glsl | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/assets/shaders/fragment.glsl b/assets/shaders/fragment.glsl index 7532036..c7ecf97 100644 --- a/assets/shaders/fragment.glsl +++ b/assets/shaders/fragment.glsl @@ -7,6 +7,7 @@ uniform vec3 sky_color; in vec3 surface_normal; in vec2 frag_tex_coord; +in float frag_light; in float frag_ambient_occlusion; in float depth; @@ -20,9 +21,11 @@ void main() { if (texture_color.a < 0.5) { discard; } + float ao = 1 - frag_ambient_occlusion / 2; + float light = frag_light; - vec3 opaque_color = diffuse * texture_color.xyz * ao; + vec3 opaque_color = diffuse * texture_color.xyz * ao * light; opaque_color = mix(sky_color, opaque_color, 1 - depth); color = vec4(opaque_color, mesh_alpha); diff --git a/assets/shaders/vertex.glsl b/assets/shaders/vertex.glsl index 1e56809..6902ad4 100644 --- a/assets/shaders/vertex.glsl +++ b/assets/shaders/vertex.glsl @@ -7,9 +7,11 @@ 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; +layout (location = 3) in float light; +layout (location = 4) in float ambient_occlusion; out vec2 frag_tex_coord; +out float frag_light; out float frag_ambient_occlusion; out vec3 surface_normal; out float depth; @@ -21,6 +23,7 @@ void main() { gl_Position = clip_position; frag_tex_coord = tex_coord; + frag_light = light; 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); |
