diff options
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp index 9b88986..3d193c2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -68,6 +68,7 @@ void run() { auto projection_uniform = program.uniform("projection_matrix"); auto sun_direction_uniform = program.uniform("sun_direction"); auto sky_color_uniform = program.uniform("sky_color"); + auto mesh_alpha_uniform = program.uniform("mesh_alpha"); program.bind(); auto projection = Math::MVP::perspective_projection<F32>(ASPECT, FOV, 0.1f, 1000.0f); @@ -82,6 +83,9 @@ void run() { glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_CULL_FACE); glFrontFace(GL_CCW); glCullFace(GL_BACK); @@ -106,9 +110,15 @@ void run() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); for (auto chunk : world.get_visible_chunks(camera.position())) { - auto model = Math::MVP::model<F32>(chunk->chunk.value().position(), {}); - model_uniform.set(model); - render(chunk->mesh.value(), texture); + mesh_alpha_uniform.set(1.0); + auto land_model = Math::MVP::model<F32>(chunk->chunk.value().position(), {}); + model_uniform.set(land_model); + render(chunk->land_mesh.value(), texture); + + mesh_alpha_uniform.set(0.4); + auto water_model = Math::MVP::model<F32>(chunk->chunk.value().position() - Vector<3>{0, 0.2, 0}, {}); + model_uniform.set(water_model); + render(chunk->water_mesh.value(), texture); } time++; |
