Skip to content

Commit d658b48

Browse files
Rename 'is_mis_eligable' to 'allow_nee'
1 parent 123e2f4 commit d658b48

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

Src/CUDA/BSDF.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct BSDFDiffuse {
5858
return material.texture_id != INVALID;
5959
}
6060

61-
__device__ bool is_mis_eligable() const {
61+
__device__ bool allow_nee() const {
6262
return true;
6363
}
6464
};
@@ -202,7 +202,7 @@ struct BSDFPlastic {
202202
return material.texture_id != INVALID;
203203
}
204204

205-
__device__ bool is_mis_eligable() const {
205+
__device__ bool allow_nee() const {
206206
return true;
207207
}
208208
};
@@ -329,7 +329,7 @@ struct BSDFDielectric {
329329
return false;
330330
}
331331

332-
__device__ bool is_mis_eligable() const {
332+
__device__ bool allow_nee() const {
333333
return material.roughness >= ROUGHNESS_CUTOFF;
334334
}
335335
};
@@ -410,7 +410,7 @@ struct BSDFConductor {
410410
return false;
411411
}
412412

413-
__device__ bool is_mis_eligable() const {
413+
__device__ bool allow_nee() const {
414414
return material.roughness >= ROUGHNESS_CUTOFF;
415415
}
416416
};

Src/CUDA/Pathtracer.cu

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
// Final Frame Buffer, shared with OpenGL
2525
__device__ __constant__ Surface<float4> accumulator;
2626

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
2828
constexpr unsigned FLAG_INSIDE_MEDIUM = 1u << 30;
2929

30-
constexpr unsigned FLAGS_ALL = FLAG_MIS_ELIGABLE | FLAG_INSIDE_MEDIUM;
30+
constexpr unsigned FLAGS_ALL = FLAG_ALLOW_NEE | FLAG_INSIDE_MEDIUM;
3131

3232
// Input to the Trace and Sort Kernels in SoA layout
3333
struct TraceBuffer {
@@ -235,7 +235,7 @@ extern "C" __global__ void kernel_sort(int bounce, int sample_index) {
235235
int x = pixel_index % screen_pitch;
236236
int y = pixel_index / screen_pitch;
237237

238-
bool mis_eligable = pixel_index_and_flags & FLAG_MIS_ELIGABLE;
238+
bool allow_nee = pixel_index_and_flags & FLAG_ALLOW_NEE;
239239
bool inside_medium = pixel_index_and_flags & FLAG_INSIDE_MEDIUM;
240240

241241
float3 throughput;
@@ -374,7 +374,7 @@ extern "C" __global__ void kernel_sort(int bounce, int sample_index) {
374374

375375
MaterialLight material_light = material_as_light(material_id);
376376

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;
378378
if (should_count_light_contribution) {
379379
float3 illumination = throughput * material_light.emission;
380380

@@ -728,7 +728,7 @@ __device__ void shade_material(int bounce, int sample_index, int buffer_size) {
728728
}
729729

730730
// 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()) {
732732
next_event_estimation(pixel_index, bounce, sample_index, bsdf, medium_id, hit_point, normal, geometric_normal, throughput);
733733
}
734734

@@ -757,12 +757,18 @@ __device__ void shade_material(int bounce, int sample_index, int buffer_size) {
757757
ray_buffer_trace->cone[index_out] = make_float2(cone_angle, cone_width);
758758
}
759759

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;
761765

762766
ray_buffer_trace->pixel_index_and_flags[index_out] = pixel_index | flags;
763767
ray_buffer_trace->throughput.set(index_out, throughput);
764768

765-
ray_buffer_trace->last_pdf[index_out] = pdf;
769+
if (allow_nee) {
770+
ray_buffer_trace->last_pdf[index_out] = pdf;
771+
}
766772
}
767773

768774
extern "C" __global__ void kernel_material_diffuse(int bounce, int sample_index) {

0 commit comments

Comments
 (0)