Fix T57963: Cycles crash using AO for displacement.
[blender.git] / intern / cycles / kernel / svm / svm_ao.h
index 0337c88a5434556b55c85c119fac645e0299c81e..15d074780c4353dd504671037a3ac6d7dce13d4f 100644 (file)
@@ -33,6 +33,11 @@ ccl_device_noinline float svm_ao(KernelGlobals *kg,
                return 1.0f;
        }
 
+       /* Can't raytrace from shaders like displacement, before BVH exists. */
+       if (kernel_data.bvh.bvh_layout == BVH_LAYOUT_NONE) {
+               return 1.0f;
+       }
+
        if(flags & NODE_AO_INSIDE) {
                N = -N;
        }