Graphics Reference
In-Depth Information
Both specular formulas use the normal, light, and view unit vectors shown in the previous
figure (note that the vector directions for Light and View are the vectors towards the light and
view). The Phong model requires the calculation of a reflection vector (using the normal and
the from-light vector, and not to-light vector). The dot product of the reflection vector and view
vector (or the eye vector) are then used to determine the specular amount (along with the
specular power material constant).
float3 Reflection = -Light - 2 * Normal * dot(Light,Normal)
Blinn-Phong uses the vector halfway between the view and the light instead; this is then
used in the dot product between the normal and halfway vectors.
float3 halfway = normalize(Light + View);
Although Blinn-Phong is less efficient than pure Phong (as the normalization contains a
square root calculation) for directional lights, the halfway vector can be calculated outside
of the pixel shader as it does not rely on the normal vector. In most other cases where lights
are not treated to be at infinity (as in directional lights), the Phong model will be faster.
float3 normalizedV = v / sqrt(dot(v, v));
There's moreā€¦
Currently we are saturating the result of the lighting operations to keep the value within the
0.0 to 1.0 range. If instead, we are supporting high-dynamic-range (HDR) rendering, we could
choose a render target format that supports more than 8 bits per component (for example,
Format.R16G16B16A16_Float ) and stores a larger range of values. To display the result,
this technique requires further processing called tone mapping to map colors from HDR to a
lower dynamic range that matches the capabilities of the display device.
Included in the companion source code is an additional project ( Ch03_02WithCubeMapping.
csproj ) that demonstrates how to sample a texture cube (or cube map) using float4
sample = CubeMap.Sample(SamplerClamp, normal); .
The support for sampling the texture cube was added by the following methods:
F Creating a cube map texture (within a DDS) by importing each of the six
512 x 512 textures into the DirectX Texture Tool ( DxTex.exe ) found in the
June 2010 DirectX SDK
F Adding the texture and sampler state in the cube and sphere renderers
 
Search WWH ::




Custom Search