| 318 | } |
| 319 | |
| 320 | void pbr_renderer::run_forward_pass(std::vector<const render_component *> & render_queue, const view_data & view, const render_payload & scene) |
| 321 | { |
| 322 | if (settings.useDepthPrepass) |
| 323 | { |
| 324 | glEnable(GL_DEPTH_TEST); |
| 325 | glDepthFunc(GL_LEQUAL); |
| 326 | glDepthMask(GL_FALSE); // depth already comes from the prepass |
| 327 | } |
| 328 | |
| 329 | // Separate opaque and translucent materials for proper rendering order |
| 330 | std::vector<const render_component *> opaque_queue; |
| 331 | std::vector<const render_component *> translucent_queue; |
| 332 | |
| 333 | for (const render_component * render_comp : render_queue) |
| 334 | { |
| 335 | base_material * the_material = render_comp->material->material.get().get(); |
| 336 | if (dynamic_cast<polymer_pbr_bubble*>(the_material)) |
| 337 | { |
| 338 | translucent_queue.push_back(render_comp); |
| 339 | } |
| 340 | else |
| 341 | { |
| 342 | opaque_queue.push_back(render_comp); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | // Render opaque objects first |
| 347 | for (const render_component * render_comp : opaque_queue) |
| 348 | { |
| 349 | update_per_object_uniform_buffer( |
| 350 | render_comp->world_matrix, |
| 351 | render_comp->material->receive_shadow, |
| 352 | view); |
| 353 | |
| 354 | base_material * the_material = render_comp->material->material.get().get(); |
| 355 | |
| 356 | // update_uniforms must be called FIRST because it resets bindpoint to 0. |
| 357 | // Shadow and IBL textures are then appended to higher texture units. |
| 358 | the_material->update_uniforms(render_comp->material); |
| 359 | |
| 360 | if (auto * mr = dynamic_cast<polymer_pbr_standard*>(the_material)) |
| 361 | { |
| 362 | if (settings.shadowsEnabled) mr->update_uniforms_shadow(shadow->get_output_texture()); |
| 363 | if (scene.ibl_cubemap) |
| 364 | { |
| 365 | mr->update_uniforms_ibl(scene.ibl_cubemap->ibl_irradianceCubemap.get(), |
| 366 | scene.ibl_cubemap->ibl_radianceCubemap.get(), |
| 367 | dfg_lut.id()); |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | if (auto * mr = dynamic_cast<polymer_blinn_phong_standard*>(the_material)) |
| 372 | { |
| 373 | if (settings.shadowsEnabled) mr->update_uniforms_shadow(shadow->get_output_texture()); |
| 374 | } |
| 375 | |
| 376 | the_material->use(); |
| 377 | render_comp->mesh->draw(); |
nothing calls this directly
no test coverage detected