Graphics Reference
In-Depth Information
In this chapter, we choose to represent a sample of a surface rather than a
BSDF. This means that a surface element encodes a position, reference frame,
and any spatially varying parameters of the BSDF, as well as the BSDF itself. We
favor this representation because it allows separating the ray-surface sampling and
scattering portions of a renderer. That separation has pedagogical benefits because
it allows us to consider the pieces of a renderer separately. It also has design
benefits because the pieces become modular and we can mix different surface and
scattering sampling methods. We do not consider the efficiency implications of
this decision here, but note that it is used in several rendering libraries, such as
PBRT ( http://pbrt.org) and The G3D Innovation Engine ( http://g3d.sf.net) .
In practice, there are two different operations that f s must support. The first is
direct evaluation: Given two directions, we wish to evaluate the function. This is
used for direct illumination, where we have already chosen a light-transport path
and wish to know the magnitude of the transport along it. The second is sam-
pling. In this case, we are given either the incoming or the outgoing light direction
and wish to choose the other direction with probability density proportional to f s ,
possibly weighted by projected area along one of the vectors.
For both direct evaluation and sampling, scattering such as by a mirror or
lens that does not diffuse light and reflects or transmits a perfect image must be
handled separately. The function f s “takes on infinite values” at the directions cor-
responding to reflection or transmission, which we call impulses. So we divide
most operations into separate methods for the finite and impulse aspects.
T HE API PRINCIPLE : Design APIs from the perspective of the programmer
who will use them, not of the programmer who will implement them or the math-
ematical notation used in their derivation. For example, a single BSDF f ( v i ,
v o )
mapped to a function API Color3 bsdf(Vector3 wi, Vector3 wo) is easy to
implement but hard to use in a real renderer.
Listing 14.6 gives an interface for evaluating the finite part of f . This method
abstracts the algorithm typically employed for direct illumination in a pixel shader
or ray tracer. It is relatively straightforward to implement.
Listing 14.6: An interface for a scattering function's direct evaluation
(similar to G3D::Surfel ).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class BSDF {
protected :
CFrame cframe; // coordinate frame in which BSDF is expressed
...
public :
class Impulse {
public :
Vector3
direction;
Color3
magnitude;
};
 
 
Search WWH ::




Custom Search