Shader Introduction
Open up the project
FirstShader
Part A
- Modify the shader code to allow the user to set the colour of the object.
(Hint, add an extra parameter to the shader code).
- (when finished step one) Modify the c# code to render 3 torui (in different
positions) (coloured red, green and blue)
Part B
- Modify the shader code so that the brightness of a vertex depends on the
distance away from the light source. (greater distance = reduced brightness).
- Make the attenuation (brightness falloff) be great enough to be noticable
across the surface of a torus. You may need to move the light closer to the
object for this to work.
Part C
- Rework your shader code to have two lights in the scene. Refactor the code,
so that the lighting calculations are placed in one function which can be
called for each light in the scene.
- Render a scene with two lights.
Part D
- Create a colour shift effect. For example, control the amount of blue refelected
from a vertex based on the angle between the view direction and the vertex
normal. Small angle means lots of blue, large angle means little blue. (hint:
use dot product).