Skip to content
Snippets Groups Projects
Commit bd07a516 authored by Yoel's avatar Yoel
Browse files

Fixing the break, continue issues

parent c40617e9
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment