diff --git a/src/presenter.cpp b/src/presenter.cpp index 2ddd34474c2917b7b68c84fca48169e5d9a7a8a7..9aa16ea4e8baca33512eba45e2e181ff8b9be15d 100644 --- a/src/presenter.cpp +++ b/src/presenter.cpp @@ -115,11 +115,11 @@ static com::Folder *generate_box(vec3 position, vec3 half_sizes_along_axes) { auto container = shader->insert<gfx::ShaderGraph::TextureNode>(com::ContextPath{ "age", "texture", "container2.png" }); // auto specular = shader->insert<gfx::ShaderGraph::TextureNode>( - // "/home/pbabic/Repositories/age_app_template/data/age/texture/container2_specular.png"); + // com::ContextPath{ "age", "texture", "container2_specular.png" }); auto tex_coords = shader->insert<gfx::ShaderGraph::NodeVaryingTexcoord>(); shader->connect(container, gfx::ShaderGraph::TextureNode::inputs::tex_coord, tex_coords, 0); - // shader->connect(container, gfx::ShaderGraph::TextureNode::inputs::tex_coord, tex_coords, 0); + // shader->connect(specular, gfx::ShaderGraph::TextureNode::inputs::tex_coord, tex_coords, 0); shader->connect(shader->root(), gfx::ShaderGraph::MasterNodeLit::inputs::ambient, container, 0); shader->connect(shader->root(), gfx::ShaderGraph::MasterNodeLit::inputs::diffuse, container, 0); @@ -162,9 +162,9 @@ void Presenter::initialize() { auto box = generate_box(vec3{ 0 }, vec3{ 0.5 }); std::vector point_lights{ - generate_point_light("point_light_1", { 1, 1, 1 }, { 0, 1, 1 }, 5), - generate_point_light("point_light_2", { -1, -1.5, -1 }, { 1, 0, 1 }, 7), - generate_point_light("point_light_3", { 0.25, 1.25, -0.25 }, { 1, 1, 0 }, 3), + generate_point_light("point_light_1", { 1, 1, 1 }, { 0, 1, 1 }, 15), + generate_point_light("point_light_2", { -1, -1.5, -1 }, { 1, 0, 1 }, 17), + generate_point_light("point_light_3", { 0.25, 1.25, -0.25 }, { 1, 1, 0 }, 13), }; for (auto &pl : point_lights) gfx::object_system()->insert_light(box, pl); @@ -173,7 +173,7 @@ void Presenter::initialize() { auto light_frame = root()->push_back<com::Folder>("dir_light")->push_back<com::Frame>(); light_frame->set_rotation(quat{ { 1.2, 0.8, 0.3 } }); auto light = gfx::light_system()->insert_light<gfx::DirectionalLight>({ "dir_light" }, light_frame, - vec3{ 0.75, 0.75, 0.75 }); + vec3{ 0.5, 0.5, 0.5 }); gfx::object_system()->insert_light(box, light); // ambient light @@ -192,10 +192,21 @@ void Presenter::release() { void Presenter::next_round() { gfx::renderer()->clear_render_buffers(); - gfx::renderer()->present_collection(gfx::object_system()->objects()->find<com::Folder>("deferred"), gfx::Renderer::DEFERRED); - gfx::renderer()->lighting_pass(*gfx::light_system()->lights()); - gfx::renderer()->copy_depth_buffer(); - gfx::renderer()->present_collection(gfx::object_system()->objects()->find<com::Folder>("forward"), gfx::Renderer::FORWARD); + + auto deferred = gfx::object_system()->objects()->find<com::Folder>("deferred"); + if (deferred != nullptr) { + gfx::renderer()->present_collection(deferred, gfx::Renderer::DEFERRED); + + std::vector<const com::Folder*> lights; + gfx::Renderer::gather_lights(deferred, lights); + gfx::renderer()->lighting_pass(lights); + + gfx::renderer()->copy_depth_buffer(); + } + + auto forward = gfx::object_system()->objects()->find<com::Folder>("forward"); + if (forward != nullptr) + gfx::renderer()->present_collection(forward, gfx::Renderer::FORWARD); } } // namespace mak