|
The crystal/Candy sample demonstrates the use of vertex
and pixel shaders to create the effect of a very shiny
semi-transparent surface such as crystal or a piece
of hard candy.
The vertex and pixel shaders implement a cubic environment
map to provide the reflections, a bump map to provide
some detail, a Fresnel term to control opacity, and
a base map to provide the surface color.
The Crystal/Candy sample renders a model of a head with
predefined texture coordinates, normals and tangents.
The cubic environment map, texture map, and bump map
are applied to this model.
The vertex shader for this effect is centered on computing
the view direction. Additionally it will pass the tangent/texture
space vectors along so that the bump map normal can
be transformed into object space in the pixel shader.
The pixel shader for this effect is accomplished in
two shader phases. The first phase computes the reflection
vector used for the cubic environment map while the
second phase composites the color from the dependent
read with other maps. At the core of the shader is the
environment mapping, which is sampled as a dependent
read at the top of the second phase. The environment
map is combined with a reflection color, the base texture,
and a base color. The final opacity of the model is
set to the computed Fresnel term.
|