Fix T60320: Cycles OpenCL volume rendering error on some drivers.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 8 Jan 2019 14:50:14 +0000 (15:50 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 8 Jan 2019 14:59:10 +0000 (15:59 +0100)
intern/cycles/kernel/kernel_volume.h

index d6d283c42c5a4ab05d79fda6337d3c34a16c99b0..1df5050443489a8025914c48c5dae2ee80ef3deb 100644 (file)
@@ -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 {