|
24 | 24 | // Final Frame Buffer, shared with OpenGL |
25 | 25 | __device__ __constant__ Surface<float4> accumulator; |
26 | 26 |
|
27 | | -constexpr unsigned FLAG_MIS_ELIGABLE = 1u << 31; // indicates the previous Material has a BRDF that supports MIS |
| 27 | +constexpr unsigned FLAG_ALLOW_NEE = 1u << 31; // Indicates the previous Material has a BRDF that supports NEE |
28 | 28 | constexpr unsigned FLAG_INSIDE_MEDIUM = 1u << 30; |
29 | 29 |
|
30 | | -constexpr unsigned FLAGS_ALL = FLAG_MIS_ELIGABLE | FLAG_INSIDE_MEDIUM; |
| 30 | +constexpr unsigned FLAGS_ALL = FLAG_ALLOW_NEE | FLAG_INSIDE_MEDIUM; |
31 | 31 |
|
32 | 32 | // Input to the Trace and Sort Kernels in SoA layout |
33 | 33 | struct TraceBuffer { |
@@ -235,7 +235,7 @@ extern "C" __global__ void kernel_sort(int bounce, int sample_index) { |
235 | 235 | int x = pixel_index % screen_pitch; |
236 | 236 | int y = pixel_index / screen_pitch; |
237 | 237 |
|
238 | | - bool mis_eligable = pixel_index_and_flags & FLAG_MIS_ELIGABLE; |
| 238 | + bool allow_nee = pixel_index_and_flags & FLAG_ALLOW_NEE; |
239 | 239 | bool inside_medium = pixel_index_and_flags & FLAG_INSIDE_MEDIUM; |
240 | 240 |
|
241 | 241 | float3 throughput; |
@@ -374,7 +374,7 @@ extern "C" __global__ void kernel_sort(int bounce, int sample_index) { |
374 | 374 |
|
375 | 375 | MaterialLight material_light = material_as_light(material_id); |
376 | 376 |
|
377 | | - bool should_count_light_contribution = config.enable_next_event_estimation ? !mis_eligable : true; |
| 377 | + bool should_count_light_contribution = config.enable_next_event_estimation ? !allow_nee : true; |
378 | 378 | if (should_count_light_contribution) { |
379 | 379 | float3 illumination = throughput * material_light.emission; |
380 | 380 |
|
@@ -728,7 +728,7 @@ __device__ void shade_material(int bounce, int sample_index, int buffer_size) { |
728 | 728 | } |
729 | 729 |
|
730 | 730 | // Next Event Estimation |
731 | | - if (config.enable_next_event_estimation && lights_total_weight > 0.0f && bsdf.is_mis_eligable()) { |
| 731 | + if (config.enable_next_event_estimation && lights_total_weight > 0.0f && bsdf.allow_nee()) { |
732 | 732 | next_event_estimation(pixel_index, bounce, sample_index, bsdf, medium_id, hit_point, normal, geometric_normal, throughput); |
733 | 733 | } |
734 | 734 |
|
@@ -757,12 +757,18 @@ __device__ void shade_material(int bounce, int sample_index, int buffer_size) { |
757 | 757 | ray_buffer_trace->cone[index_out] = make_float2(cone_angle, cone_width); |
758 | 758 | } |
759 | 759 |
|
760 | | - unsigned flags = (bsdf.is_mis_eligable() << 31) | ((medium_id != INVALID) << 30); |
| 760 | + bool allow_nee = bsdf.allow_nee(); |
| 761 | + |
| 762 | + unsigned flags = 0; |
| 763 | + if (allow_nee) flags |= FLAG_ALLOW_NEE; |
| 764 | + if (medium_id != INVALID) flags |= FLAG_INSIDE_MEDIUM; |
761 | 765 |
|
762 | 766 | ray_buffer_trace->pixel_index_and_flags[index_out] = pixel_index | flags; |
763 | 767 | ray_buffer_trace->throughput.set(index_out, throughput); |
764 | 768 |
|
765 | | - ray_buffer_trace->last_pdf[index_out] = pdf; |
| 769 | + if (allow_nee) { |
| 770 | + ray_buffer_trace->last_pdf[index_out] = pdf; |
| 771 | + } |
766 | 772 | } |
767 | 773 |
|
768 | 774 | extern "C" __global__ void kernel_material_diffuse(int bounce, int sample_index) { |
|
0 commit comments