Graphics Reference
In-Depth Information
target, as well as the depth stencil resource, after performing the depth test (the stencil test
and blending functionality are not used).
float4 PSMAIN( in VS_OUTPUT input ) : SV_Target
{
// Normalize the world space normal and light vectors
float3 n = normalize( input.normal );
float3 1 = normalize( input.light );
// Calculate the amount of light reaching this fragment
float4 Illumination = max(dot(n,l),0) + 0.2f;
// Determine the color properties of the surface from a texture
float4 SurfaceColor = ColorTexture.Sample( LinearSampler, input.tex );
// Return the surface color modulated by the illumination
return( SurfaceColor * Illumination );
}
Listing 8.2. The pixel shader for static mesh rendering.
Figure 8.8 shows the results of our rendering as we have configured it for several
orientations of the model and camera.
8.1.3 Conclusion
Rendering a static mesh is somewhat of a first point of entry into developing real-time
rendering algorithms. This technique allows for an object to become animated by changing
some of its properties over time. For example, if the object were spinning in a circle, this
could easily be accomplished by animating the rotation about the y -axis. The operation de-
scribed above would be executed once for each object that needs to be rendered in a given
scene. Since we are using a transformation matrix and a texture map that will be unique
for each object, each object must be rendered with its own draw calls after the associated
resources have been updated and bound to the pipeline.
8.2 Vertex Skinning
In the previous section, we saw how to perform the transformation of an object to control
its spatial properties within a scene. This provides a surprisingly large amount of func-
tionality. For instance, it could be used to implement a chess game where each piece is
Search WWH ::




Custom Search