Graphics Reference
In-Depth Information
outgoing radiance, the emitted radiance depended on direction, we might have
written:
1
2
3
if (includeEmissive) {
L_o += surfel.material.emittedRadianceFunction(-ray.direction);
}
where the emitted radiance function describes the emission pattern. Notice that we
compute the emission in the opposite of the ray direction; the ray goes from the
eye toward the surface, but we want to know the radiance from the surface toward
the eye.
We add to this emitted radiance the reflection of direct light (i.e., light that
goes from a luminaire directly to P , and that scatters back along our ray), and the
reflection of indirect light (i.e., all light leaving the intersection point that's neither
emitted light nor scattered direct light).
To compute the direct lighting from point lights (see Listing 32.5), we deter-
mine a unit vector w_i from the surface to the luminaire, and check visibility; if the
luminaire is visible from the surface, we use w_i in computing the reflected light.
This follows a convention we'll use consistently: The variable w_i corresponds to
the mathematical entity
v i ; the letter “i” indicates “incoming”; the ray
v i points
from the surface toward the source of the light, and
v o points in the direction
along which it's scattered. This means that the variable w_i will be the first argu-
ment to surfel,evaluateBSDF(...) , and often a variable w_o will be the second
argument. This convention matters: While the finite part of the BRDF is typi-
cally symmetric in its two arguments, both the mirror-reflectance and transmissive
portions of scattering are often represented by nonsymmetric functions.
Listing 32.5: Reflecting illumination from point lights.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Radiance3 App::estimateDirectLightFromPointLights(
const SurfaceElement& surfel, const Ray& ray){
Radiance3 L_o(0.0f);
if (m_pointLights) {
for (int L = 0; L < m_world->lightArray.size(); ++L) {
const GLight& light = m_world->lightArray[L];
// Shadow rays
if (m_world->lineOfSight(
surfel.geometric.location + surfel.geometric.normal * 0.0001f,
light.position.xyz())) {
Vector3 w_i = light.position.xyz() - surfel.shading.location;
const float distance2 = w_i.squaredLength();
w_i /= sqrt(distance2);
// Attenuated radiance
const Irradiance3& E_i = light.color / (4.0f * pif() * distance2);
L_o += (surfel.evaluateBSDF(w_i, -ray.direction()) * E_i *
max(0.0f, w_i.dot(surfel.shading.normal)));
debugAssert(radiance.isFinite());
}
}
}
return L_o;
}
 
 
Search WWH ::




Custom Search