diff --git a/RayTracer/sampling/Scene.cpp b/RayTracer/sampling/Scene.cpp index 792c57f48ffdb5b6abfad7ccdd18cf281816aa18..02a7b34b602f590f830d6618c7834aa92523fa20 100644 --- a/RayTracer/sampling/Scene.cpp +++ b/RayTracer/sampling/Scene.cpp @@ -70,23 +70,26 @@ util::Vec3 Scene::directLighting(const cam::Hit& h, cam::Ray r) const { cam::Ray(sample_point.point(), h.point() - sample_point.point(), cam::epsilon, 1 - cam::epsilon, false); // When the surface normal and the shadowray dont point in the same - // hemisphere, the ray hits the surface, so we can break - if (util::dot(shadow_ray.d, sample_point.normal()) <= 0) break; + // hemisphere, the ray hits the surface, so we can continue + if (util::dot(shadow_ray.d, sample_point.normal()) <= 0) continue; auto shadow_hit = group.intersect(shadow_ray); - // If the shadowray his something we can break - if (shadow_hit) break; + // If the shadowray his something we can continue + if (shadow_hit) continue; auto light_pdf = light->lightPdf(sample_point, shadow_ray.d); // This happens when the shaodow ray is beyond the surfaces normal. - // This means, that the shadow ray hits the surface and we can break - if (light_pdf <= 0) break; + // This means, that the shadow ray hits the surface and we can + // continue + if (light_pdf <= 0) continue; auto brdf = h.calculateLightMultiplier(shadow_ray.d.normalize(), -r.d, h.normal()); auto L = light->lightEmission(sample_point); - // Dot product could be negative, in that case break + // Dot product could be negative, in that case continue auto cosine_term = std::max<float>( util::dot(-shadow_ray.d.normalize(), h.normal()), 0); - if (cosine_term <= 0) break; + if (cosine_term <= 0) { + continue; + } auto scatterFunction = (brdf * L * cosine_term) / light_pdf; // Add the values from this light to the others