diff --git a/shader/cloudshader.cpp b/shader/cloudshader.cpp index 2f0e120..11a8160 100644 --- a/shader/cloudshader.cpp +++ b/shader/cloudshader.cpp @@ -122,7 +122,7 @@ Color CloudShader::transparency(const Scene &scene, const Ray &ray, float maxLen cloudRay.primitive = nullptr; // Get out of cloud primitive first - if (!ray.primitive->intersect(cloudRay) || cloudRay.length == INFINITY || cloudRay.length <= 0) + if (ray.primitive != nullptr && !ray.primitive->intersect(cloudRay) || cloudRay.length == INFINITY || cloudRay.length <= 0) { // Something went wrong return Color(1, 1, 1);