Tutorial 5 - Lights and MaterialsBy Pieter Germishuys, January 4 2006 |
Long time no see, How has
everyone been doing? Today we are going to look at a very interesting and exciting
topic. But you are probably thinking hey, why does this screenshot look exactly
like the previous tutorial's shot? It's cause today we are going to enable light
and material and this screenshot has light in it.
Let's get into the theory. We are going to introduce 3 new components today.
They are Normals, Lights and Materials. Let's see what the definition is for
each one of them.
Normal
"A surface normal, or just normal to a flat surface is a three-dimensional
vector which is perpendicular to that surface. A normal to a non-flat surface
at a point p on the surface is a vector which is perpendicular to the tangent
plane to that surface at p."

In this image above I have pointed out what normals are. Normals are unit
vectors, A vector that has the length (or magnitude) of one unit eg: (0.0f,
1.0f, 0.0f). This is the normal point upwards for the object in the figure.
Light
"Form of radiant energy that acts upon the retina of
the eye, optic nerve, etc., making sight possible. This energy is transmitted
at a velocity of about 186,000 miles per second by wavelike or vibrational motion.
2. A form of radiant energy similar to this, but not acting on the normal retina,
such as ultraviolet and infrared radiation. Interplay between light rays and
the atmosphere cause us to see the sky as blue, and can result in such phenomena
as glows, halos, arcs, flashes, and streamers."
There are three types of lights available in Direct3D: point lights, directional
lights, and spotlights. We will be working with a directional light as it's
simple to setup and for tutorial purposes keeps math out of the equation.
Material
"A material defines the color that is reflected off the surface
of a geometric object when a light hits it."
This means that the material is like a costume that the object puts on.
This material defines how the light will interact with it. Look at some examples
in life. Chrome, Wood, Fur... all these materials handles light in a different
way. Some absorb more light than others.
Now that we have some theory covered let's look at some code.
| public
Core() |
We have created all of our resources. The only thing left is to set them and render the quad.
private
void
Render() |
Files for this tutorial
| Filename | Size |
|
|
200.4 KB |
