Graphics Reference
In-Depth Information
Diffuse Albedo
Diffuse albedo is a simple case, since the source data is typically a color value of the
range [0,1]. This means that we can use an unsigned, normalized, 8-bit integer format such
as DXGI_F0RMAT_R8G8B8A8_UN0RM. It may also be desirable to store the values in sRGB
color space, 8 since this is typically the storage format for diffuse textures. This requires
using a format such as DXGI_F0RMAT_R8G8B8A8_UN0RM_SRGB, which causes the hardware
to perform the sRGB conversion on the value output from the pixel shader. Alternatively, a
10-bit format such as DXGI_FORMAT_R10G10B16A2_UNORM can provide additional precision
if the fourth component isn't needed for other data.
Specujar Albedo and Power
Specular albedo is a similar case to diffuse albedo, in that it doesn't require a great deal of
precision. The 255 discrete values provided by an 8-bit integer are generally adequate for
both the albedo and the power. Additionally, it is common to store only a monochrome specu-
lar value, rather than RGB components. This allows us to store only 2 values for specular
albedo, as opposed to 4.
Position
Position is a value that typically requires high precision, since it can have a potentially
large domain and is used for high-frequency shadow computations. For storing the XYZ
components of a world or view space position, even a 16-bit floating point format is gener-
ally inadequate for avoiding artifacts. Fortunately, there is an alternative to storing the full
XYZ value. When executing a pixel shader, the screen space XY position is implicit and
available to shader through the SV_Position semantic. By using the view and projection
matrices used when rendering the scene geometry, it is possible to reconstruct the view
space or world space position of a pixel from only a single value.
To begin with, we will discuss the basics of a perspective projection. For any pixel
on the screen, there is an associated direction vector that begins at the camera position
and points towards the pixel's position on the far clipping plane. You can calculate this
direction vector by using the screen-space XY position of the pixel to linearly interpolate
between the positions of the corners on the view frustum's far clipping plane, subtracting
the camera position, and then normalizing (you don't have to subtract the camera position
if you're doing this in view space, since the camera position is located at the origin of view
space). If geometry is rasterized at that pixel position, this means that the surface at that
pixel lies somewhere along the vector from the origin to that pixel. The distance along that
8 The sRGB color space is a standard RGB color space often used by image files and display devices. Using
sRGB causes more precision to be used for darker color values, which matches the human eye's natural sensi-
tivity to those color regions.
Search WWH ::




Custom Search