Browse Source

Set OpenGL depth range to [0, 1]. Remove obsolete ground pass

master
C. J. Howard 1 year ago
parent
commit
859cdf6916
18 changed files with 47 additions and 305 deletions
  1. +1
    -0
      CMakeLists.txt
  2. +20
    -0
      src/engine/gl/rasterizer.cpp
  3. +0
    -187
      src/engine/render/passes/ground-pass.cpp
  4. +0
    -69
      src/engine/render/passes/ground-pass.hpp
  5. +1
    -4
      src/engine/render/passes/material-pass.cpp
  6. +2
    -7
      src/engine/render/passes/shadow-map-pass.cpp
  7. +2
    -2
      src/engine/scene/camera.cpp
  8. +12
    -9
      src/engine/scene/directional-light.cpp
  9. +5
    -5
      src/engine/scene/directional-light.hpp
  10. +1
    -0
      src/game/controls/camera-controls.cpp
  11. +2
    -6
      src/game/game.cpp
  12. +0
    -2
      src/game/game.hpp
  13. +0
    -2
      src/game/states/experiments/treadmill-experiment-state.cpp
  14. +0
    -2
      src/game/states/main-menu-state.cpp
  15. +0
    -2
      src/game/states/nest-selection-state.cpp
  16. +0
    -1
      src/game/states/nest-view-state.cpp
  17. +0
    -2
      src/game/states/nuptial-flight-state.cpp
  18. +1
    -5
      src/game/world.cpp

+ 1
- 0
CMakeLists.txt View File

@ -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")

+ 20
- 0
src/engine/gl/rasterizer.cpp View File

@ -22,6 +22,8 @@
#include <engine/gl/shader-program.hpp>
#include <engine/gl/vertex-array.hpp>
#include <glad/glad.h>
#include <engine/debug/log.hpp>
#include <stdexcept>
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()

+ 0
- 187
src/engine/render/passes/ground-pass.cpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <engine/render/passes/ground-pass.hpp>
#include <engine/resources/resource-manager.hpp>
#include <engine/gl/rasterizer.hpp>
#include <engine/gl/framebuffer.hpp>
#include <engine/gl/shader-program.hpp>
#include <engine/gl/shader-variable.hpp>
#include <engine/gl/vertex-buffer.hpp>
#include <engine/gl/vertex-array.hpp>
#include <engine/gl/vertex-attribute.hpp>
#include <engine/gl/drawing-mode.hpp>
#include <engine/gl/texture-2d.hpp>
#include <engine/gl/texture-wrapping.hpp>
#include <engine/gl/texture-filter.hpp>
#include <engine/render/vertex-attribute.hpp>
#include <engine/render/context.hpp>
#include <engine/render/model.hpp>
#include <engine/render/material.hpp>
#include <engine/scene/camera.hpp>
#include <engine/scene/collection.hpp>
#include <engine/scene/directional-light.hpp>
#include <engine/math/vector.hpp>
#include <engine/color/color.hpp>
#include <engine/math/interpolation.hpp>
#include <cmath>
#include <stdexcept>
#include <glad/glad.h>
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<float>(std::get<0>(viewport)), static_cast<float>(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<scene::object_base*>* 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<const scene::light*>(object);
switch (light->get_light_type())
{
// Add directional light
case scene::light_type::directional:
{
const scene::directional_light* directional_light = static_cast<const scene::directional_light*>(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<const scene::directional_light*>(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<render::model> 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

+ 0
- 69
src/engine/render/passes/ground-pass.hpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_RENDER_GROUND_PASS_HPP
#define ANTKEEPER_RENDER_GROUND_PASS_HPP
#include <engine/render/pass.hpp>
#include <engine/math/vector.hpp>
#include <engine/animation/tween.hpp>
#include <engine/gl/shader-program.hpp>
#include <engine/gl/shader-variable.hpp>
#include <engine/gl/vertex-buffer.hpp>
#include <engine/gl/vertex-array.hpp>
#include <engine/gl/drawing-mode.hpp>
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<render::model> model);
private:
std::shared_ptr<gl::shader_program> 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<model> 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

+ 1
- 4
src/engine/render/passes/material-pass.cpp View File

@ -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));

+ 2
- 7
src/engine/render/passes/shadow-map-pass.cpp View File

@ -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)
{

+ 2
- 2
src/engine/scene/camera.cpp View File

@ -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

+ 12
- 9
src/engine/scene/directional-light.cpp View File

@ -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<float>(i % 2) * 0.5f, static_cast<float>(i / 2) * 0.5f, 0.0f}) * m;
// Apply cascade bias
m_shadow_scale_bias_matrices[i] = math::translate(math::fvec3{static_cast<float>(i % 2) * 0.5f, static_cast<float>(i / 2) * 0.5f, 0.0f}) * m;
}
}

+ 5
- 5
src/engine/scene/directional-light.hpp View File

@ -195,10 +195,10 @@ public:
}
/// @}
/// Returns the array of shadow cascade bias-scale matrices.
[[nodiscard]] inline constexpr std::span<const math::fmat4> get_shadow_bias_scale_matrices() const noexcept
/// Returns the array of shadow cascade scale-bias matrices.
[[nodiscard]] inline constexpr std::span<const math::fmat4> 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<float> m_shadow_cascade_distances;
std::vector<math::fmat4> m_shadow_cascade_matrices;
std::vector<math::fmat4> m_shadow_bias_scale_matrices;
std::vector<math::fmat4> m_shadow_scale_bias_matrices;
};
} // namespace scene

+ 1
- 0
src/game/controls/camera-controls.cpp View File

@ -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 <engine/debug/log.hpp>
namespace {

+ 2
- 6
src/game/game.cpp View File

@ -82,7 +82,6 @@
#include <engine/render/passes/clear-pass.hpp>
#include <engine/render/passes/final-pass.hpp>
#include <engine/render/passes/fxaa-pass.hpp>
#include <engine/render/passes/ground-pass.hpp>
#include <engine/render/passes/material-pass.hpp>
#include <engine/render/passes/outline-pass.hpp>
#include <engine/render/passes/resample-pass.hpp>
@ -724,7 +723,7 @@ void game::setup_rendering()
{
ui_clear_pass = std::make_unique<render::clear_pass>(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<render::material_pass>(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<render::sky_pass>(window->get_rasterizer(), hdr_framebuffer.get(), resource_manager.get());
// sky_pass->set_magnification(3.0f);
ground_pass = std::make_unique<render::ground_pass>(window->get_rasterizer(), hdr_framebuffer.get(), resource_manager.get());
surface_material_pass = std::make_unique<render::material_pass>(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<render::clear_pass>(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<render::material_pass>(window->get_rasterizer(), hdr_framebuffer.get(), resource_manager.get());
underground_material_pass->set_fallback_material(fallback_material);

+ 0
- 2
src/game/game.hpp View File

@ -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<render::material_pass> surface_material_pass;
std::unique_ptr<render::outline_pass> surface_outline_pass;
std::unique_ptr<render::compositor> surface_compositor;
std::unique_ptr<render::ground_pass> ground_pass;
std::unique_ptr<render::renderer> renderer;
// UI

+ 0
- 2
src/game/states/experiments/treadmill-experiment-state.cpp View File

@ -77,7 +77,6 @@
#include <engine/physics/kinematics/colliders/capsule-collider.hpp>
#include <engine/physics/kinematics/colliders/mesh-collider.hpp>
#include <engine/render/passes/clear-pass.hpp>
#include <engine/render/passes/ground-pass.hpp>
#include <engine/render/passes/material-pass.hpp>
#include <engine/resources/resource-manager.hpp>
#include <engine/utility/state-machine.hpp>
@ -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<scene::light_probe>();
sky_probe->set_luminance_texture(std::make_shared<gl::texture_cube>(512, 384, gl::pixel_type::float_16, gl::pixel_format::rgb));

+ 0
- 2
src/game/states/main-menu-state.cpp View File

@ -42,7 +42,6 @@
#include <engine/physics/light/exposure.hpp>
#include <engine/render/model.hpp>
#include <engine/render/passes/clear-pass.hpp>
#include <engine/render/passes/ground-pass.hpp>
#include <engine/render/passes/sky-pass.hpp>
#include <engine/resources/resource-manager.hpp>
#include <engine/utility/hash/fnv1a.hpp>
@ -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);

+ 0
- 2
src/game/states/nest-selection-state.cpp View File

@ -68,7 +68,6 @@
#include <engine/physics/kinematics/colliders/box-collider.hpp>
#include <engine/physics/kinematics/colliders/capsule-collider.hpp>
#include <engine/render/passes/clear-pass.hpp>
#include <engine/render/passes/ground-pass.hpp>
#include <engine/resources/resource-manager.hpp>
#include <engine/utility/state-machine.hpp>
#include <engine/scene/static-mesh.hpp>
@ -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);

+ 0
- 1
src/game/states/nest-view-state.cpp View File

@ -69,7 +69,6 @@
#include <engine/physics/kinematics/colliders/box-collider.hpp>
#include <engine/physics/kinematics/colliders/capsule-collider.hpp>
#include <engine/render/passes/clear-pass.hpp>
#include <engine/render/passes/ground-pass.hpp>
#include <engine/render/passes/material-pass.hpp>
#include <engine/resources/resource-manager.hpp>
#include <engine/utility/state-machine.hpp>

+ 0
- 2
src/game/states/nuptial-flight-state.cpp View File

@ -55,7 +55,6 @@
#include "game/world.hpp"
#include "game/strings.hpp"
#include <engine/render/passes/clear-pass.hpp>
#include <engine/render/passes/ground-pass.hpp>
#include <engine/utility/state-machine.hpp>
#include <engine/config.hpp>
#include <engine/math/interpolation.hpp>
@ -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);

+ 1
- 5
src/game/world.cpp View File

@ -55,7 +55,6 @@
#include <engine/render/material-flags.hpp>
#include <engine/render/material.hpp>
#include <engine/render/model.hpp>
#include <engine/render/passes/ground-pass.hpp>
#include <engine/render/passes/shadow-map-pass.hpp>
#include <engine/render/passes/sky-pass.hpp>
#include <engine/render/vertex-attribute.hpp>
@ -363,7 +362,7 @@ void create_sun(::game& ctx)
ctx.sun_light = std::make_unique<scene::directional_light>();
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<render::model>("celestial-hemisphere.mdl"));
ctx.sky_pass->set_ground_albedo(ecoregion.terrain_albedo);
auto terrestrial_hemisphere_model = ctx.resource_manager->load<render::model>("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);

Loading…
Cancel
Save