From 859cdf691629b20a942aba024e3647b0eb85693f Mon Sep 17 00:00:00 2001 From: "C. J. Howard" Date: Wed, 30 Aug 2023 19:24:13 +0800 Subject: [PATCH] Set OpenGL depth range to [0, 1]. Remove obsolete ground pass --- CMakeLists.txt | 1 + src/engine/gl/rasterizer.cpp | 20 ++ src/engine/render/passes/ground-pass.cpp | 187 ------------------ src/engine/render/passes/ground-pass.hpp | 69 ------- src/engine/render/passes/material-pass.cpp | 5 +- src/engine/render/passes/shadow-map-pass.cpp | 9 +- src/engine/scene/camera.cpp | 4 +- src/engine/scene/directional-light.cpp | 21 +- src/engine/scene/directional-light.hpp | 10 +- src/game/controls/camera-controls.cpp | 1 + src/game/game.cpp | 8 +- src/game/game.hpp | 2 - .../treadmill-experiment-state.cpp | 2 - src/game/states/main-menu-state.cpp | 2 - src/game/states/nest-selection-state.cpp | 2 - src/game/states/nest-view-state.cpp | 1 - src/game/states/nuptial-flight-state.cpp | 2 - src/game/world.cpp | 6 +- 18 files changed, 47 insertions(+), 305 deletions(-) delete mode 100644 src/engine/render/passes/ground-pass.cpp delete mode 100644 src/engine/render/passes/ground-pass.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 21ca183..73e1a79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required(VERSION 3.25) + option(APPLICATION_NAME "Application name" "Antkeeper") option(APPLICATION_VERSION "Application version string" "0.0.0") option(APPLICATION_AUTHOR "Application author" "C. J. Howard") diff --git a/src/engine/gl/rasterizer.cpp b/src/engine/gl/rasterizer.cpp index 2ad63cd..1dab386 100644 --- a/src/engine/gl/rasterizer.cpp +++ b/src/engine/gl/rasterizer.cpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include namespace gl { @@ -63,7 +65,25 @@ rasterizer::rasterizer(): // Bind default framebuffer bound_framebuffer = default_framebuffer.get(); + // Enable seamless filtering across cubemap faces glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + + if (GLAD_GL_ARB_clip_control) + { + // Improve depth buffer precision by setting depth range to `[0, 1]`. + glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE); + } + else + { + debug::log::error("glClipControl not supported"); + throw std::runtime_error("glClipControl not supported"); + } + + // glClipControl alternative for OpenGL < v4.5 (need to adjust shadow scale-bias matrix too) + // glDepthRange(-1.0f, 1.0f); + + // Set clear depth to `0` for reversed depth + glClearDepth(0.0f); } rasterizer::~rasterizer() diff --git a/src/engine/render/passes/ground-pass.cpp b/src/engine/render/passes/ground-pass.cpp deleted file mode 100644 index 9793be5..0000000 --- a/src/engine/render/passes/ground-pass.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (C) 2023 Christopher J. Howard - * - * This file is part of Antkeeper source code. - * - * Antkeeper source code is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Antkeeper source code is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Antkeeper source code. If not, see . - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace render { - -ground_pass::ground_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, resource_manager* resource_manager): - pass(rasterizer, framebuffer), - ground_model(nullptr), - ground_model_vao(nullptr), - ground_material(nullptr), - shader_program(nullptr) -{} - -ground_pass::~ground_pass() -{} - -void ground_pass::render(render::context& ctx) -{ - /* - if (!ground_model) - return; - - rasterizer->use_framebuffer(*framebuffer); - - glDisable(GL_BLEND); - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_ALWAYS); - glDepthMask(GL_TRUE); - glDepthRange(-1.0f, 1.0f); - glEnable(GL_CULL_FACE); - glCullFace(GL_BACK); - glDisable(GL_STENCIL_TEST); - glStencilMask(0); - - auto viewport = framebuffer->get_dimensions(); - rasterizer->set_viewport(0, 0, std::get<0>(viewport), std::get<1>(viewport)); - - math::fvec2 resolution = {static_cast(std::get<0>(viewport)), static_cast(std::get<1>(viewport))}; - - const scene::camera& camera = *ctx.camera; - float clip_near = camera.get_clip_near_tween().interpolate(ctx.alpha); - float clip_far = camera.get_clip_far_tween().interpolate(ctx.alpha); - math::fvec3 model_scale = math::fvec3{1.0f, 1.0f, 1.0f} * (clip_near + clip_far) * 0.5f; - math::fmat4 model = math::scale(math::fmat4::identity(), model_scale); - math::fmat4 view = math::fmat4(math::fmat3(ctx.view)); - math::fmat4 model_view = view * model; - const math::fmat4& projection = ctx.projection; - const math::fmat4& view_projection = ctx.view_projection; - math::fmat4 model_view_projection = projection * model_view; - - math::fvec3 directional_light_color = {0.0f, 0.0f, 0.0f}; - math::fvec3 directional_light_direction = {0.0f, 0.0f, 0.0f}; - - // Collect lights - const std::list* lights = ctx.collection->get_objects(scene::light::object_type_id); - for (const scene::object_base* object: *lights) - { - // Skip inactive lights - if (!object->is_active()) - continue; - - const scene::light* light = static_cast(object); - switch (light->get_light_type()) - { - // Add directional light - case scene::light_type::directional: - { - const scene::directional_light* directional_light = static_cast(light); - - // Pre-expose light - math::fvec3 light_color = light->get_scaled_color_tween().interpolate(ctx.alpha) * ctx.exposure; - if (light_color.x() < directional_light_color.x()) - break; - - directional_light_color = light_color; - - directional_light_direction = static_cast(light)->get_direction_tween().interpolate(ctx.alpha); - break; - } - - default: - break; - } - } - - // Draw ground - rasterizer->use_program(*shader_program); - - if (model_view_projection_var) - model_view_projection_var->update(model_view_projection); - if (view_projection_var) - view_projection_var->update(view_projection); - if (camera_position_var) - camera_position_var->update(ctx.camera_transform.translation); - if (directional_light_colors_var) - directional_light_colors_var->update(0, &directional_light_color, 1); - if (directional_light_directions_var) - directional_light_directions_var->update(0, &directional_light_direction, 1); - - ground_material->update(ctx.alpha); - - rasterizer->draw_arrays(*ground_model_vao, ground_model_drawing_mode, ground_model_start_index, ground_model_index_count); - */ -} - -void ground_pass::set_ground_model(std::shared_ptr model) -{ - /* - ground_model = model; - - if (ground_model) - { - ground_model_vao = model->get_vertex_array().get(); - - for (const auto& group: model->get_groups()) - { - ground_material = group.material; - ground_model_drawing_mode = group.drawing_mode; - ground_model_start_index = group.start_index; - ground_model_index_count = group.index_count; - } - - if (ground_material) - { - shader_program = ground_material->get_shader_program(); - - if (shader_program) - { - model_view_projection_var = shader_program->get_var("model_view_projection"); - view_projection_var = shader_program->get_var("view_projection"); - camera_position_var = shader_program->get_var("camera.position"); - directional_light_colors_var = shader_program->get_var("directional_light_colors"); - directional_light_directions_var = shader_program->get_var("directional_light_directions"); - } - } - } - else - { - ground_model_vao = nullptr; - } - */ -} - -} // namespace render diff --git a/src/engine/render/passes/ground-pass.hpp b/src/engine/render/passes/ground-pass.hpp deleted file mode 100644 index af28831..0000000 --- a/src/engine/render/passes/ground-pass.hpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2023 Christopher J. Howard - * - * This file is part of Antkeeper source code. - * - * Antkeeper source code is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Antkeeper source code is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Antkeeper source code. If not, see . - */ - -#ifndef ANTKEEPER_RENDER_GROUND_PASS_HPP -#define ANTKEEPER_RENDER_GROUND_PASS_HPP - -#include -#include -#include -#include -#include -#include -#include -#include - -class resource_manager; - -namespace render { - -class material; -class model; - -/** - * - */ -class ground_pass: public pass -{ -public: - ground_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, resource_manager* resource_manager); - virtual ~ground_pass(); - void render(render::context& ctx) override; - - void set_ground_model(std::shared_ptr model); - -private: - std::shared_ptr shader_program; - const gl::shader_variable* model_view_projection_var; - const gl::shader_variable* view_projection_var; - const gl::shader_variable* camera_position_var; - const gl::shader_variable* directional_light_colors_var; - const gl::shader_variable* directional_light_directions_var; - - std::shared_ptr ground_model; - const material* ground_material; - const gl::vertex_array* ground_model_vao; - gl::drawing_mode ground_model_drawing_mode; - std::size_t ground_model_start_index; - std::size_t ground_model_index_count; -}; - -} // namespace render - -#endif // ANTKEEPER_RENDER_GROUND_PASS_HPP diff --git a/src/engine/render/passes/material-pass.cpp b/src/engine/render/passes/material-pass.cpp index d2e1e4a..43e36cb 100644 --- a/src/engine/render/passes/material-pass.cpp +++ b/src/engine/render/passes/material-pass.cpp @@ -141,14 +141,11 @@ void material_pass::render(render::context& ctx) glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); - glDepthFunc(GL_GREATER); + glDepthFunc(GL_GEQUAL); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glDisable(GL_STENCIL_TEST); - // For half-z buffer - glDepthRange(-1.0f, 1.0f); - auto viewport = framebuffer->get_dimensions(); rasterizer->set_viewport(0, 0, std::get<0>(viewport), std::get<1>(viewport)); diff --git a/src/engine/render/passes/shadow-map-pass.cpp b/src/engine/render/passes/shadow-map-pass.cpp index c07bddf..cce63be 100644 --- a/src/engine/render/passes/shadow-map-pass.cpp +++ b/src/engine/render/passes/shadow-map-pass.cpp @@ -140,11 +140,6 @@ void shadow_map_pass::render_csm(scene::directional_light& light, render::contex glCullFace(GL_BACK); bool two_sided = false; - // For half-z buffer - glDepthRange(-1.0f, 1.0f); - - - // Get camera const scene::camera& camera = *ctx.camera; @@ -234,7 +229,7 @@ void shadow_map_pass::render_csm(scene::directional_light& light, render::contex // Construct light view matrix const auto light_view = math::look_at_rh(subfrustum_bounds.center, subfrustum_bounds.center + light.get_direction(), light.get_rotation() * math::fvec3{0, 1, 0}); - // Construct light projection matrix (reversed half-z) + // Construct light projection matrix (reversed depth) const auto light_projection = math::ortho_half_z ( -subfrustum_bounds.radius, subfrustum_bounds.radius, @@ -246,7 +241,7 @@ void shadow_map_pass::render_csm(scene::directional_light& light, render::contex const auto light_view_projection = light_projection * light_view; // Update world-space to cascade texture-space transformation matrix - cascade_matrices[i] = light.get_shadow_bias_scale_matrices()[i] * light_view_projection; + cascade_matrices[i] = light.get_shadow_scale_bias_matrices()[i] * light_view_projection; for (const render::operation* operation: ctx.operations) { diff --git a/src/engine/scene/camera.cpp b/src/engine/scene/camera.cpp index 4df6324..a5d051d 100644 --- a/src/engine/scene/camera.cpp +++ b/src/engine/scene/camera.cpp @@ -72,7 +72,7 @@ void camera::set_perspective(float vertical_fov, float aspect_ratio, float clip_ m_clip_near = clip_near; m_clip_far = clip_far; - // Recalculate projection matrix and its inverse + // Recalculate projection matrix (reversed depth) and its inverse std::tie(m_projection, m_inv_projection) = math::perspective_half_z_inv(m_vertical_fov, m_aspect_ratio, m_clip_far, m_clip_near); // Recalculate view-projection matrix @@ -104,7 +104,7 @@ void camera::set_orthographic(float clip_left, float clip_right, float clip_bott m_clip_near = clip_near; m_clip_far = clip_far; - // Recalculate projection matrix and its inverse + // Recalculate projection matrix (reversed depth) and its inverse std::tie(m_projection, m_inv_projection) = math::ortho_half_z_inv(m_clip_left, m_clip_right, m_clip_bottom, m_clip_top, m_clip_far, m_clip_near); // Update view-projection matrix and its inverse diff --git a/src/engine/scene/directional-light.cpp b/src/engine/scene/directional-light.cpp index 5b21563..2849497 100644 --- a/src/engine/scene/directional-light.cpp +++ b/src/engine/scene/directional-light.cpp @@ -24,7 +24,7 @@ namespace scene { directional_light::directional_light(): m_shadow_cascade_distances(m_shadow_cascade_count), m_shadow_cascade_matrices(m_shadow_cascade_count), - m_shadow_bias_scale_matrices(m_shadow_cascade_count) + m_shadow_scale_bias_matrices(m_shadow_cascade_count) { set_shadow_bias(m_shadow_bias); } @@ -47,7 +47,7 @@ void directional_light::set_shadow_framebuffer(std::shared_ptr void directional_light::set_shadow_bias(float bias) noexcept { m_shadow_bias = bias; - update_shadow_bias_scale_matrices(); + update_shadow_scale_bias_matrices(); } void directional_light::set_shadow_cascade_count(unsigned int count) noexcept @@ -55,8 +55,8 @@ void directional_light::set_shadow_cascade_count(unsigned int count) noexcept m_shadow_cascade_count = count; m_shadow_cascade_distances.resize(m_shadow_cascade_count); m_shadow_cascade_matrices.resize(m_shadow_cascade_count); - m_shadow_bias_scale_matrices.resize(m_shadow_cascade_count); - update_shadow_bias_scale_matrices(); + m_shadow_scale_bias_matrices.resize(m_shadow_cascade_count); + update_shadow_scale_bias_matrices(); } void directional_light::set_shadow_cascade_coverage(float factor) noexcept @@ -84,18 +84,21 @@ void directional_light::illuminance_updated() m_colored_illuminance = m_color * m_illuminance; } -void directional_light::update_shadow_bias_scale_matrices() +void directional_light::update_shadow_scale_bias_matrices() { - // Construct shadow bias-scale matrix - auto m = math::translate(math::fvec3{0.5f, 0.5f, 0.5f + m_shadow_bias}) * math::scale(math::fvec3{0.5f, 0.5f, 0.5f}); + // Construct shadow scale-bias matrix (depth range `[-1, 1]`) + // auto m = math::translate(math::fvec3{0.5f, 0.5f, 0.5f + m_shadow_bias}) * math::scale(math::fvec3{0.5f, 0.5f, 0.5f}); + + // Construct shadow scale-bias matrix (depth range `[0, 1]`) + auto m = math::translate(math::fvec3{0.5f, 0.5f, m_shadow_bias}) * math::scale(math::fvec3{0.5f, 0.5f, 1.0f}); // Apply cascade scale m = math::scale(math::fvec3{0.5f, 0.5f, 1.0f}) * m; for (unsigned int i = 0; i < m_shadow_cascade_count; ++i) { - // Apply cascade translation - m_shadow_bias_scale_matrices[i] = math::translate(math::fvec3{static_cast(i % 2) * 0.5f, static_cast(i / 2) * 0.5f, 0.0f}) * m; + // Apply cascade bias + m_shadow_scale_bias_matrices[i] = math::translate(math::fvec3{static_cast(i % 2) * 0.5f, static_cast(i / 2) * 0.5f, 0.0f}) * m; } } diff --git a/src/engine/scene/directional-light.hpp b/src/engine/scene/directional-light.hpp index bf9f59d..922bdbe 100644 --- a/src/engine/scene/directional-light.hpp +++ b/src/engine/scene/directional-light.hpp @@ -195,10 +195,10 @@ public: } /// @} - /// Returns the array of shadow cascade bias-scale matrices. - [[nodiscard]] inline constexpr std::span get_shadow_bias_scale_matrices() const noexcept + /// Returns the array of shadow cascade scale-bias matrices. + [[nodiscard]] inline constexpr std::span get_shadow_scale_bias_matrices() const noexcept { - return m_shadow_bias_scale_matrices; + return m_shadow_scale_bias_matrices; } /// Returns the array of world-space to cascade texture-space transformation matrices. @@ -219,7 +219,7 @@ private: void transformed() override; void color_updated(); void illuminance_updated(); - void update_shadow_bias_scale_matrices(); + void update_shadow_scale_bias_matrices(); math::fvec3 m_direction{0.0f, 0.0f, -1.0f}; math::fvec3 m_color{1.0f, 1.0f, 1.0f}; @@ -234,7 +234,7 @@ private: float m_shadow_cascade_distribution{0.8f}; std::vector m_shadow_cascade_distances; std::vector m_shadow_cascade_matrices; - std::vector m_shadow_bias_scale_matrices; + std::vector m_shadow_scale_bias_matrices; }; } // namespace scene diff --git a/src/game/controls/camera-controls.cpp b/src/game/controls/camera-controls.cpp index 2cad59c..06d5e97 100644 --- a/src/game/controls/camera-controls.cpp +++ b/src/game/controls/camera-controls.cpp @@ -20,6 +20,7 @@ #include "game/controls.hpp" #include "game/components/spring-arm-component.hpp" #include "game/components/rigid-body-component.hpp" +#include "game/components/scene-component.hpp" #include namespace { diff --git a/src/game/game.cpp b/src/game/game.cpp index 4cc2228..d99cc2a 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -82,7 +82,6 @@ #include #include #include -#include #include #include #include @@ -724,7 +723,7 @@ void game::setup_rendering() { ui_clear_pass = std::make_unique(window->get_rasterizer(), &window->get_rasterizer()->get_default_framebuffer()); ui_clear_pass->set_cleared_buffers(false, true, false); - ui_clear_pass->set_clear_depth(-1.0f); + ui_clear_pass->set_clear_depth(0.0f); ui_material_pass = std::make_unique(window->get_rasterizer(), &window->get_rasterizer()->get_default_framebuffer(), resource_manager.get()); ui_material_pass->set_fallback_material(fallback_material); @@ -751,8 +750,6 @@ void game::setup_rendering() sky_pass = std::make_unique(window->get_rasterizer(), hdr_framebuffer.get(), resource_manager.get()); // sky_pass->set_magnification(3.0f); - ground_pass = std::make_unique(window->get_rasterizer(), hdr_framebuffer.get(), resource_manager.get()); - surface_material_pass = std::make_unique(window->get_rasterizer(), hdr_framebuffer.get(), resource_manager.get()); surface_material_pass->set_fallback_material(fallback_material); @@ -765,7 +762,6 @@ void game::setup_rendering() surface_compositor->add_pass(surface_shadow_map_pass.get()); surface_compositor->add_pass(surface_clear_pass.get()); surface_compositor->add_pass(sky_pass.get()); - //surface_compositor->add_pass(ground_pass.get()); surface_compositor->add_pass(surface_material_pass.get()); //surface_compositor->add_pass(surface_outline_pass.get()); surface_compositor->add_pass(bloom_pass.get()); @@ -779,7 +775,7 @@ void game::setup_rendering() underground_clear_pass = std::make_unique(window->get_rasterizer(), hdr_framebuffer.get()); underground_clear_pass->set_cleared_buffers(true, true, false); underground_clear_pass->set_clear_color({0, 0, 0, 1}); - underground_clear_pass->set_clear_depth(-1.0f); + underground_clear_pass->set_clear_depth(0.0f); underground_material_pass = std::make_unique(window->get_rasterizer(), hdr_framebuffer.get(), resource_manager.get()); underground_material_pass->set_fallback_material(fallback_material); diff --git a/src/game/game.hpp b/src/game/game.hpp index 39ebb13..490cbba 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -93,7 +93,6 @@ namespace render class shadow_map_pass; class simple_render_pass; class sky_pass; - class ground_pass; } @@ -341,7 +340,6 @@ public: std::unique_ptr surface_material_pass; std::unique_ptr surface_outline_pass; std::unique_ptr surface_compositor; - std::unique_ptr ground_pass; std::unique_ptr renderer; // UI diff --git a/src/game/states/experiments/treadmill-experiment-state.cpp b/src/game/states/experiments/treadmill-experiment-state.cpp index 8686e9c..edfbe11 100644 --- a/src/game/states/experiments/treadmill-experiment-state.cpp +++ b/src/game/states/experiments/treadmill-experiment-state.cpp @@ -77,7 +77,6 @@ #include #include #include -#include #include #include #include @@ -344,7 +343,6 @@ treadmill_experiment_state::treadmill_experiment_state(::game& ctx): // Setup and enable sky and ground passes ctx.sky_pass->set_enabled(true); - ctx.ground_pass->set_enabled(true); sky_probe = std::make_shared(); sky_probe->set_luminance_texture(std::make_shared(512, 384, gl::pixel_type::float_16, gl::pixel_format::rgb)); diff --git a/src/game/states/main-menu-state.cpp b/src/game/states/main-menu-state.cpp index fe34f2e..09aba70 100644 --- a/src/game/states/main-menu-state.cpp +++ b/src/game/states/main-menu-state.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -275,7 +274,6 @@ main_menu_state::main_menu_state(::game& ctx, bool fade_in): // Setup and enable sky and ground passes ctx.sky_pass->set_enabled(true); - ctx.ground_pass->set_enabled(true); // Enable UI color clear ctx.ui_clear_pass->set_cleared_buffers(true, true, false); diff --git a/src/game/states/nest-selection-state.cpp b/src/game/states/nest-selection-state.cpp index 5b5855e..90bd78c 100644 --- a/src/game/states/nest-selection-state.cpp +++ b/src/game/states/nest-selection-state.cpp @@ -68,7 +68,6 @@ #include #include #include -#include #include #include #include @@ -216,7 +215,6 @@ nest_selection_state::nest_selection_state(::game& ctx): // Setup and enable sky and ground passes ctx.sky_pass->set_enabled(true); - ctx.ground_pass->set_enabled(true); // Set camera exposure const float ev100_sunny16 = physics::light::ev::from_settings(16.0f, 1.0f / 100.0f, 100.0f); diff --git a/src/game/states/nest-view-state.cpp b/src/game/states/nest-view-state.cpp index a43dca7..3597644 100644 --- a/src/game/states/nest-view-state.cpp +++ b/src/game/states/nest-view-state.cpp @@ -69,7 +69,6 @@ #include #include #include -#include #include #include #include diff --git a/src/game/states/nuptial-flight-state.cpp b/src/game/states/nuptial-flight-state.cpp index 163fd64..372ad36 100644 --- a/src/game/states/nuptial-flight-state.cpp +++ b/src/game/states/nuptial-flight-state.cpp @@ -55,7 +55,6 @@ #include "game/world.hpp" #include "game/strings.hpp" #include -#include #include #include #include @@ -98,7 +97,6 @@ nuptial_flight_state::nuptial_flight_state(::game& ctx): // Setup and enable sky and ground passes ctx.sky_pass->set_enabled(true); - ctx.ground_pass->set_enabled(true); // Create mating swarm swarm_eid = create_ant_swarm(ctx); diff --git a/src/game/world.cpp b/src/game/world.cpp index 21b0265..e974d14 100644 --- a/src/game/world.cpp +++ b/src/game/world.cpp @@ -55,7 +55,6 @@ #include #include #include -#include #include #include #include @@ -363,7 +362,7 @@ void create_sun(::game& ctx) ctx.sun_light = std::make_unique(); ctx.sun_light->set_shadow_caster(true); ctx.sun_light->set_shadow_framebuffer(ctx.shadow_map_framebuffer); - ctx.sun_light->set_shadow_bias(0.001f); + ctx.sun_light->set_shadow_bias(0.0025f); ctx.sun_light->set_shadow_cascade_count(4); ctx.sun_light->set_shadow_cascade_coverage(0.05f); ctx.sun_light->set_shadow_cascade_distribution(0.8f); @@ -457,9 +456,6 @@ void enter_ecoregion(::game& ctx, const ecoregion& ecoregion) // Setup sky ctx.sky_pass->set_sky_model(ctx.resource_manager->load("celestial-hemisphere.mdl")); ctx.sky_pass->set_ground_albedo(ecoregion.terrain_albedo); - auto terrestrial_hemisphere_model = ctx.resource_manager->load("terrestrial-hemisphere.mdl"); - terrestrial_hemisphere_model->get_groups().front().material = ecoregion.horizon_material; - ctx.ground_pass->set_ground_model(terrestrial_hemisphere_model); // Setup terrain // ctx.terrain_system->set_patch_material(ecoregion.terrain_material);