Advanced Graphics, Shaders homework
For this homework assignment, we will be writing some shader code.
You will need to download this program: ShadersHomework.zip (updated 1/31).
In it you will find three files called "VertexShade.vfx", "PixelShade.pfx" and "PixelShadeTexture.pfx".
In those functions you'll find a "main" function that is missing some stuff.
- PixelShade.pfx and PixelShadeTexture.pfx are two pixel shaders. As provided, they just output some fixed color.
Your task is to implement them such that they generate the correct output calculated from the input structure.
- VertexShade.vfx is a vertex shader. As provided, it calculates the position, copies the texture coordinates
and calculates the fog value. It is missing all the lighting calculations.
Basic assignment
The basic assignment is to implement the shaders such that the textures show and the ambient and the diffuse component of
the directional light is implemented correctly.
Ambient light needs no calculation.
Diffuse light is calculated using Lambert's formula: color = dotproduct(Normal, LightDir) * LightColor.
This should be multiplied to the texture's color in order to generate the correct output.
Contributions from multiple lights are additive. So are the specular contributions, but they must not be mixed with the texture color.
Program usage:
- On boot, the program will use the stub shaders, so the "ground" will appear green and the cube and the billboard will show as magenta.
- Press the "R" key to toggle between your shaders and the reference shaders.
- Press the "F" key to toggle the fog on and off.
- Press the "L" key to toggle the directional light on and off.
- Press the "P" key to toggle the point light on and off.
- Press the "C" key to toggle the specular light on and off.
- Press the "T" key to substitute the texture with a simple grid texture.
- Press the SPACE bar in order to toggle between several spinning objects and other scenes.
- Press the "G" key to toggle gamma-correct rendering on and off (we'll talk about gamma at a later class).
- The title bar of the application will display the current position of the above toggles.
Submitting
You must send to JCAB your completed shader files according to the instructions.
Extra grade
Extra grade will help you compensate your grade if you don't manage to successfully complete one or more basic assignments.
I will be granting the following:
- Two extra points for correctly handling the point light's diffuse component.
- Two extra points for correctly handling the specular components.
- Two extra points if you successfully add a shader of your own making somewhere in your game project.
[an error occurred while processing this directive]
Solution available
Download the full source code of HWRenderer here.