hevele
hevele

Reputation: 933

Area Lighting In Ray Tracing

I have a quick question about area lighting in ray tracing. I am learning this subject from Ray Tracing from the Ground Up and the result of my area light is like this when no antialising is applied: NO AA

As you can see there are lots of noise in the image. When I apply antialising, it looks fine and looks like this when 256x AA is applied:

AA 256x

[The change in the shadow color is trivial, I changed some properties of shadow]

My question, is this the way area lights behave or am I doing something wrong? Because rendering first one takes only 4 seconds but the latter one takes almost 20 minutes. It feels like there is something wrong.

The only difference between my point light class and area light class is get_direction function.

Point Light's get_direction function:

virtual Vec get_direction(ShadeRec& sr)
{
return Vec(position.x-sr.hit_point.x, position.y-sr.hit_point.y, position.z-sr.hit_point.z).norm();
}

Area Light's get_direction function:

virtual Vec get_direction(ShadeRec& sr)
{
    Vec newLocation;
    newLocation.x = position.x + radius * (2.0 * rand_float() - 1.0);
    newLocation.y = position.y + radius * (2.0 * rand_float() - 1.0);
    newLocation.z = position.z + radius * (2.0 * rand_float() - 1.0);
    return ((newLocation - sr.hit_point).norm());
}

Upvotes: 3

Views: 4144

Answers (1)

Dude
Dude

Reputation: 583

The rendering times you posted make perfect sense to me:

4 seconds * 256 ~= 17 minutes

The overhead introduced by the random number generator sums up to the rest.

Upvotes: 3

Related Questions