Browse Source

Allow ground pass to write to depth buffer

master
C. J. Howard 2 years ago
parent
commit
b175a924ef
4 changed files with 29 additions and 12 deletions
  1. +5
    -5
      src/game/state/boot.cpp
  2. +11
    -4
      src/game/state/nuptial-flight.cpp
  3. +12
    -3
      src/render/passes/ground-pass.cpp
  4. +1
    -0
      src/render/passes/ground-pass.hpp

+ 5
- 5
src/game/state/boot.cpp View File

@ -460,7 +460,7 @@ void boot::setup_rendering()
{ {
ctx.ui_clear_pass = new render::clear_pass(ctx.rasterizer, &ctx.rasterizer->get_default_framebuffer()); ctx.ui_clear_pass = new render::clear_pass(ctx.rasterizer, &ctx.rasterizer->get_default_framebuffer());
ctx.ui_clear_pass->set_cleared_buffers(false, true, false); ctx.ui_clear_pass->set_cleared_buffers(false, true, false);
ctx.ui_clear_pass->set_clear_depth(0.0f);
ctx.ui_clear_pass->set_clear_depth(-1.0f);
ctx.ui_material_pass = new render::material_pass(ctx.rasterizer, &ctx.rasterizer->get_default_framebuffer(), ctx.resource_manager); ctx.ui_material_pass = new render::material_pass(ctx.rasterizer, &ctx.rasterizer->get_default_framebuffer(), ctx.resource_manager);
ctx.ui_material_pass->set_fallback_material(ctx.fallback_material); ctx.ui_material_pass->set_fallback_material(ctx.fallback_material);
@ -475,7 +475,7 @@ void boot::setup_rendering()
ctx.underground_clear_pass = new render::clear_pass(ctx.rasterizer, ctx.hdr_framebuffer); ctx.underground_clear_pass = new render::clear_pass(ctx.rasterizer, ctx.hdr_framebuffer);
ctx.underground_clear_pass->set_cleared_buffers(true, true, false); ctx.underground_clear_pass->set_cleared_buffers(true, true, false);
ctx.underground_clear_pass->set_clear_color({1, 0, 1, 0}); ctx.underground_clear_pass->set_clear_color({1, 0, 1, 0});
ctx.underground_clear_pass->set_clear_depth(0.0f);
ctx.underground_clear_pass->set_clear_depth(-1.0f);
ctx.underground_material_pass = new render::material_pass(ctx.rasterizer, ctx.hdr_framebuffer, ctx.resource_manager); ctx.underground_material_pass = new render::material_pass(ctx.rasterizer, ctx.hdr_framebuffer, ctx.resource_manager);
ctx.underground_material_pass->set_fallback_material(ctx.fallback_material); ctx.underground_material_pass->set_fallback_material(ctx.fallback_material);
@ -498,8 +498,8 @@ void boot::setup_rendering()
ctx.surface_shadow_map_pass->set_split_scheme_weight(0.75f); ctx.surface_shadow_map_pass->set_split_scheme_weight(0.75f);
ctx.surface_clear_pass = new render::clear_pass(ctx.rasterizer, ctx.hdr_framebuffer); ctx.surface_clear_pass = new render::clear_pass(ctx.rasterizer, ctx.hdr_framebuffer);
ctx.surface_clear_pass->set_cleared_buffers(true, true, true);
ctx.surface_clear_pass->set_clear_depth(0.0f);
ctx.surface_clear_pass->set_cleared_buffers(false, true, true);
ctx.surface_clear_pass->set_clear_depth(-1.0f);
ctx.sky_pass = new render::sky_pass(ctx.rasterizer, ctx.hdr_framebuffer, ctx.resource_manager); ctx.sky_pass = new render::sky_pass(ctx.rasterizer, ctx.hdr_framebuffer, ctx.resource_manager);
ctx.sky_pass->set_enabled(false); ctx.sky_pass->set_enabled(false);
@ -526,7 +526,7 @@ void boot::setup_rendering()
ctx.surface_compositor->add_pass(ctx.ground_pass); ctx.surface_compositor->add_pass(ctx.ground_pass);
ctx.surface_compositor->add_pass(ctx.surface_material_pass); ctx.surface_compositor->add_pass(ctx.surface_material_pass);
//ctx.surface_compositor->add_pass(ctx.surface_outline_pass); //ctx.surface_compositor->add_pass(ctx.surface_outline_pass);
ctx.surface_compositor->add_pass(ctx.common_bloom_pass);
//ctx.surface_compositor->add_pass(ctx.common_bloom_pass);
ctx.surface_compositor->add_pass(ctx.common_final_pass); ctx.surface_compositor->add_pass(ctx.common_final_pass);
} }

+ 11
- 4
src/game/state/nuptial-flight.cpp View File

@ -126,6 +126,13 @@ nuptial_flight::nuptial_flight(game::context& ctx):
entity::command::warp_to(*ctx.entity_registry, color_checker_eid, {0, 0, 0}); entity::command::warp_to(*ctx.entity_registry, color_checker_eid, {0, 0, 0});
} }
// Create ruler
{
entity::archetype* ruler_10cm_archetype = ctx.resource_manager->load<entity::archetype>("ruler-10cm.ent");
auto ruler_10cm_eid = ruler_10cm_archetype->create(*ctx.entity_registry);
entity::command::warp_to(*ctx.entity_registry, ruler_10cm_eid, {0, 0, 10});
}
// Setup camera // Setup camera
setup_camera(); setup_camera();
@ -294,7 +301,7 @@ void nuptial_flight::enable_controls()
ctx.controls["move_forward"]->set_active_callback ctx.controls["move_forward"]->set_active_callback
( (
[&ctx = this->ctx, target_eid, three_dof_eid, truck_speed, move_slow, move_fast, slow_modifier, fast_modifier](float value)
[&ctx = this->ctx, target_eid, three_dof_eid, dolly_speed, move_slow, move_fast, slow_modifier, fast_modifier](float value)
{ {
if (move_slow->is_active()) if (move_slow->is_active())
value *= slow_modifier; value *= slow_modifier;
@ -304,7 +311,7 @@ void nuptial_flight::enable_controls()
auto& three_dof = ctx.entity_registry->get<entity::component::constraint::three_dof>(three_dof_eid); auto& three_dof = ctx.entity_registry->get<entity::component::constraint::three_dof>(three_dof_eid);
const math::quaternion<float> yaw = math::angle_axis(three_dof.yaw, {0.0f, 1.0f, 0.0f}); const math::quaternion<float> yaw = math::angle_axis(three_dof.yaw, {0.0f, 1.0f, 0.0f});
const float3 movement = {0.0f, 0.0f, -truck_speed * value * (1.0f / 60.0f)};
const float3 movement = {0.0f, 0.0f, -dolly_speed * value * (1.0f / 60.0f)};
entity::command::translate(*ctx.entity_registry, target_eid, yaw * movement); entity::command::translate(*ctx.entity_registry, target_eid, yaw * movement);
} }
); );
@ -312,7 +319,7 @@ void nuptial_flight::enable_controls()
// Dolly backward // Dolly backward
ctx.controls["move_back"]->set_active_callback ctx.controls["move_back"]->set_active_callback
( (
[&ctx = this->ctx, target_eid, three_dof_eid, truck_speed, move_slow, move_fast, slow_modifier, fast_modifier](float value)
[&ctx = this->ctx, target_eid, three_dof_eid, dolly_speed, move_slow, move_fast, slow_modifier, fast_modifier](float value)
{ {
if (move_slow->is_active()) if (move_slow->is_active())
value *= slow_modifier; value *= slow_modifier;
@ -322,7 +329,7 @@ void nuptial_flight::enable_controls()
auto& three_dof = ctx.entity_registry->get<entity::component::constraint::three_dof>(three_dof_eid); auto& three_dof = ctx.entity_registry->get<entity::component::constraint::three_dof>(three_dof_eid);
const math::quaternion<float> yaw = math::angle_axis(three_dof.yaw, {0.0f, 1.0f, 0.0f}); const math::quaternion<float> yaw = math::angle_axis(three_dof.yaw, {0.0f, 1.0f, 0.0f});
const float3 movement = {0.0f, 0.0f, truck_speed * value * (1.0f / 60.0f)};
const float3 movement = {0.0f, 0.0f, dolly_speed * value * (1.0f / 60.0f)};
entity::command::translate(*ctx.entity_registry, target_eid, yaw * movement); entity::command::translate(*ctx.entity_registry, target_eid, yaw * movement);
} }
); );

+ 12
- 3
src/render/passes/ground-pass.cpp View File

@ -67,10 +67,14 @@ void ground_pass::render(const render::context& ctx, render::queue& queue) const
rasterizer->use_framebuffer(*framebuffer); rasterizer->use_framebuffer(*framebuffer);
glDisable(GL_BLEND); glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glDepthFunc(GL_GREATER);
glDepthRange(-1.0f, 1.0f);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glCullFace(GL_BACK); glCullFace(GL_BACK);
glDisable(GL_STENCIL_TEST);
glStencilMask(0);
auto viewport = framebuffer->get_dimensions(); auto viewport = framebuffer->get_dimensions();
rasterizer->set_viewport(0, 0, std::get<0>(viewport), std::get<1>(viewport)); rasterizer->set_viewport(0, 0, std::get<0>(viewport), std::get<1>(viewport));
@ -85,9 +89,11 @@ void ground_pass::render(const render::context& ctx, render::queue& queue) const
float4x4 view = math::resize<4, 4>(math::resize<3, 3>(camera.get_view_tween().interpolate(ctx.alpha))); float4x4 view = math::resize<4, 4>(math::resize<3, 3>(camera.get_view_tween().interpolate(ctx.alpha)));
float4x4 model_view = view * model; float4x4 model_view = view * model;
float4x4 projection = camera.get_projection_tween().interpolate(ctx.alpha); float4x4 projection = camera.get_projection_tween().interpolate(ctx.alpha);
//float4x4 view_projection = projection * view;
float4x4 view_projection = camera.get_view_projection_tween().interpolate(ctx.alpha);
float4x4 model_view_projection = projection * model_view; float4x4 model_view_projection = projection * model_view;
float3 ambient_light_color = {0.0f, 0.0f, 0.0f}; float3 ambient_light_color = {0.0f, 0.0f, 0.0f};
float3 directional_light_color = {0.0f, 0.0f, 0.0f}; float3 directional_light_color = {0.0f, 0.0f, 0.0f};
float3 directional_light_direction = {0.0f, 0.0f, 0.0f}; float3 directional_light_direction = {0.0f, 0.0f, 0.0f};
@ -133,6 +139,8 @@ void ground_pass::render(const render::context& ctx, render::queue& queue) const
if (model_view_projection_input) if (model_view_projection_input)
model_view_projection_input->upload(model_view_projection); model_view_projection_input->upload(model_view_projection);
if (view_projection_input)
view_projection_input->upload(view_projection);
if (camera_position_input) if (camera_position_input)
camera_position_input->upload(ctx.camera_transform.translation); camera_position_input->upload(ctx.camera_transform.translation);
if (directional_light_colors_input) if (directional_light_colors_input)
@ -173,6 +181,7 @@ void ground_pass::set_ground_model(const model* model)
if (shader_program) if (shader_program)
{ {
model_view_projection_input = shader_program->get_input("model_view_projection"); model_view_projection_input = shader_program->get_input("model_view_projection");
view_projection_input = shader_program->get_input("view_projection");
camera_position_input = shader_program->get_input("camera.position"); camera_position_input = shader_program->get_input("camera.position");
directional_light_colors_input = shader_program->get_input("directional_light_colors"); directional_light_colors_input = shader_program->get_input("directional_light_colors");
directional_light_directions_input = shader_program->get_input("directional_light_directions"); directional_light_directions_input = shader_program->get_input("directional_light_directions");

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

@ -51,6 +51,7 @@ public:
private: private:
gl::shader_program* shader_program; gl::shader_program* shader_program;
const gl::shader_input* model_view_projection_input; const gl::shader_input* model_view_projection_input;
const gl::shader_input* view_projection_input;
const gl::shader_input* camera_position_input; const gl::shader_input* camera_position_input;
const gl::shader_input* directional_light_colors_input; const gl::shader_input* directional_light_colors_input;
const gl::shader_input* directional_light_directions_input; const gl::shader_input* directional_light_directions_input;

Loading…
Cancel
Save