diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-01-08 17:50:14 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-01-08 17:59:10 +0300 |
commit | b486088218f66810b97294f38f246e4650d32f2b (patch) | |
tree | 035df030818b2a409f53a2f58971e45eace76118 /intern | |
parent | 8491dba0c6bb96f9785e27429c72315ba9660511 (diff) |
Fix T60320: Cycles OpenCL volume rendering error on some drivers.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/kernel/kernel_volume.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/intern/cycles/kernel/kernel_volume.h b/intern/cycles/kernel/kernel_volume.h index d6d283c42c5..1df50504434 100644 --- a/intern/cycles/kernel/kernel_volume.h +++ b/intern/cycles/kernel/kernel_volume.h @@ -383,18 +383,22 @@ ccl_device int kernel_volume_sample_channel(float3 albedo, float3 throughput, fl * Tracing". Matt Jen-Yuan Chiang, Peter Kutz, Brent Burley. SIGGRAPH 2016. */ float3 weights = fabs(throughput * albedo); float sum_weights = weights.x + weights.y + weights.z; + float3 weights_pdf; if(sum_weights > 0.0f) { - *pdf = weights/sum_weights; + weights_pdf = weights/sum_weights; } else { - *pdf = make_float3(1.0f/3.0f, 1.0f/3.0f, 1.0f/3.0f); + weights_pdf = make_float3(1.0f/3.0f, 1.0f/3.0f, 1.0f/3.0f); } - if(rand < pdf->x) { + *pdf = weights_pdf; + + /* OpenCL does not support -> on float3, so don't use pdf->x. */ + if(rand < weights_pdf.x) { return 0; } - else if(rand < pdf->x + pdf->y) { + else if(rand < weights_pdf.x + weights_pdf.y) { return 1; } else { |