|
49 | 49 | #include "renderer/modeling/edf/edf.h" |
50 | 50 | #include "renderer/modeling/environment/environment.h" |
51 | 51 | #include "renderer/modeling/environmentedf/environmentedf.h" |
| 52 | +#include "renderer/modeling/light/light.h" |
52 | 53 | #include "renderer/modeling/scene/scene.h" |
53 | 54 | #include "renderer/utility/spectrumclamp.h" |
54 | 55 | #include "renderer/utility/stochasticcast.h" |
@@ -442,6 +443,29 @@ namespace |
442 | 443 | { |
443 | 444 | assert(vertex.m_prev_mode != ScatteringMode::None); |
444 | 445 |
|
| 446 | + // Add contributions from all outter space light sources. |
| 447 | + for (auto& light_info : m_light_sampler.get_non_physical_light_vector()) |
| 448 | + { |
| 449 | + Spectrum value; |
| 450 | + light_info.m_light->evaluate( |
| 451 | + m_shading_context, |
| 452 | + normalize(-Vector3d(vertex.m_outgoing.get_value())), |
| 453 | + value); |
| 454 | + |
| 455 | + // Apply path throughput. |
| 456 | + value *= vertex.m_throughput; |
| 457 | + |
| 458 | + // Optionally clamp secondary rays contribution. |
| 459 | + if (m_params.m_has_max_ray_intensity && vertex.m_path_length > 1 && vertex.m_prev_mode != ScatteringMode::Specular) |
| 460 | + clamp_contribution(value, m_params.m_max_ray_intensity); |
| 461 | + |
| 462 | + // Update path radiance. |
| 463 | + m_path_radiance.add_emission( |
| 464 | + vertex.m_path_length, |
| 465 | + vertex.m_aov_mode, |
| 466 | + value); |
| 467 | + } |
| 468 | + |
445 | 469 | // Can't look up the environment if there's no environment EDF. |
446 | 470 | if (m_env_edf == nullptr) |
447 | 471 | return; |
@@ -548,6 +572,35 @@ namespace |
548 | 572 | { |
549 | 573 | assert(vertex.m_prev_mode != ScatteringMode::None); |
550 | 574 |
|
| 575 | + // Add contributions from all Semi-physical light sources. |
| 576 | + for (auto& light_info : m_light_sampler.get_non_physical_light_vector()) |
| 577 | + { |
| 578 | + Spectrum value; |
| 579 | + light_info.m_light->evaluate( |
| 580 | + m_shading_context, |
| 581 | + normalize(-Vector3d(vertex.m_outgoing.get_value())), |
| 582 | + value); |
| 583 | + |
| 584 | + // Multiple importance sampling. |
| 585 | + if (vertex.m_prev_mode != ScatteringMode::Specular) |
| 586 | + { |
| 587 | + value.set(0.0f); |
| 588 | + } |
| 589 | + |
| 590 | + // Apply path throughput. |
| 591 | + value *= vertex.m_throughput; |
| 592 | + |
| 593 | + // Optionally clamp secondary rays contribution. |
| 594 | + if (m_params.m_has_max_ray_intensity && vertex.m_path_length > 1 && vertex.m_prev_mode != ScatteringMode::Specular) |
| 595 | + clamp_contribution(value, m_params.m_max_ray_intensity); |
| 596 | + |
| 597 | + // Update path radiance. |
| 598 | + m_path_radiance.add_emission( |
| 599 | + vertex.m_path_length, |
| 600 | + vertex.m_aov_mode, |
| 601 | + value); |
| 602 | + } |
| 603 | + |
551 | 604 | // Can't look up the environment if there's no environment EDF. |
552 | 605 | if (m_env_edf == nullptr) |
553 | 606 | return; |
|
0 commit comments