Shader Introduction

Open up the project FirstShader

Part A

  1. Modify the shader code to allow the user to set the colour of the object. (Hint, add an extra parameter to the shader code).
  2. (when finished step one) Modify the c# code to render 3 torui (in different positions) (coloured red, green and blue)

Part B

  1. Modify the shader code so that the brightness of a vertex depends on the distance away from the light source. (greater distance = reduced brightness).
  2. 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

  1. 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.
  2. Render a scene with two lights.

Part D

  1. 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).