Graphics Reference
In-Depth Information
The representation of the triangle is concealed by making the member vari-
ables private. Although the implementation shown contains methods that simply
return those member variables, you will later use this abstraction boundary to
create a more efficient implementation of the triangle. For example, many trian-
gles may share the same vertices and bidirectional scattering distribution func-
tions (BSDFs), so this representation is not very space-efficient. There are also
properties of the triangle, such as the edge lengths and geometric normal, that
we will find ourselves frequently recomputing and could benefit from storing
explicitly.
Inline Exercise 15.4: Compute the size in bytes of one Triangle .Howbig
is a 1M triangle mesh? Is that reasonable? How does this compare with the
size of a stored mesh file, say, in the binary 3DS format or the ASCII OBJ
format? What are other advantages, beyond space reduction, of sharing vertices
between triangles in a mesh?
Listing 15.8 shows our implementation of an omnidirectional point light
source. We represent the power it emits at three wavelengths (or in three wave-
length bands), and the center of the emitter. Note that emitters are infinitely small
in our representation, so they are not themselves visible. If we wish to see the
source appear in the final rendering we need to either add geometry around it or
explicitly render additional information into the image. We will do neither explic-
itly in this chapter, although you may find that these are necessary when debugging
your illumination code.
Listing 15.8: Interface for a uniform point luminaire—a light source.
1
2
3
4
5
6
7
class Light {
public :
Point3
position;
/ ** Over the entire sphere. * /
Power3
power;
};
Listing 15.9 describes the scene as sets of triangles and lights. Our choice of
arrays for the implementation of these sets imposes an ordering on the scene. This
is convenient for ensuring a reproducible environment for debugging. However,
for now we are going to create that ordering in an arbitrary way, and that choice
may affect performance and even our image in some slight ways, such as resolving
ties between which surface is closest at an intersection. More sophisticated scene
data structures may include additional structure in the scene and impose a specific
ordering.
Listing 15.9: Interface for a scene represented as an unstructured list of
triangles and light sources.
1
2
3
4
5
class Scene {
public :
std::vector< Triangle > triangleArray;
std::vector< Light >
lightArray;
};
 
Search WWH ::




Custom Search