diff options
-rw-r--r-- | c2.cpp | 11 | ||||
-rw-r--r-- | model.cpp | 6 |
2 files changed, 16 insertions, 1 deletions
@@ -189,6 +189,10 @@ extern "C" int entrypoint() { dev->get_ctx().submit(pb.build_rp()); pb.begin_rp(); + pb.rp_depth_target(dev->get_depth_target(), Clear_Mode::restore); + Render_Pass& depth_prepass = pb.build_rp(); + + pb.begin_rp(); pb.rp_target(dev->get_backbuffer(), Clear_Mode::restore); pb.rp_depth_target(dev->get_depth_target(), Clear_Mode::restore); Render_Pass& pass2 = pb.build_rp(); @@ -212,6 +216,13 @@ extern "C" int entrypoint() { monkey->render( dev, &frame_arena, + depth_prepass, + transform, + projection + ); + monkey->render( + dev, + &frame_arena, pass2, transform, projection @@ -165,6 +165,7 @@ void Model::render( cbuffers[i].view_projection = view_projection; cbuffers[i].model = transform * meshes[i].world; } + bool depth_only = !pass.colour_count; dev->unmap_buffer(mvp); for (i = 0; i < c; i++) { Mesh& mesh = meshes[i]; @@ -187,7 +188,10 @@ void Model::render( draw.first_vertex = mesh.offset; draw.vertex_offset = mesh.vbo_offset; pb.begin(); - pb.depth(true, true, Depth_Mode::less); + if (depth_only) + pb.depth(true, true, Depth_Mode::less); + else + pb.depth(true, false, Depth_Mode::equal); pb.shader(mesh.shader); pb.cbuffer( mesh.mvp_binding, |