Skip to content

Commit

Permalink
Normalize throughput and kill the bounced ray stochastically.
Browse files Browse the repository at this point in the history
Allows "infinite" bounces without freezing the GPU.
  • Loading branch information
baskanov committed Nov 13, 2021
1 parent 24ebc1f commit 5ae66bc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ref_vk/shaders/ray.rgen
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,12 @@ void main() {

if (bounce == 0)
first_bounce_brdf_type = brdfType;

float maxThroughput = max(max(throughput.x, throughput.y), throughput.z);
if (rand01() > maxThroughput) {
break;
}
throughput /= maxThroughput;
} // for all bounces

if (first_bounce_brdf_type == DIFFUSE_TYPE) {
Expand Down

0 comments on commit 5ae66bc

Please sign in to comment.