Project time frame: Sept - Dec 2018
|
Executable download: LINK
|
Project type: Coursework
|
The vertices for the height map mesh are calculated from a 2D texture. It simply offsets the y-position of the vertex depending on the colour of the pixel in the texture. The default value it multiplies the pixels shade/colour is 16, as grayscale images are typically done in 16bit. Increasing or decreasing the value makes the height map steeper and shallower respectively.
The more difficult part is calculating the normal for the height map. To calculate the normal we normally calculate the perpendicular vector from two vertices creating using the formula of N = normalize(vector1, vector2), but I have realised |
|
Starting off with the billboards, I have created 2 billboarded quads for the scene with the texture off a sun on each side. They are mainly there to show off billboarding but also act in providing a visual representation off the directional lights, or at least where they start. The billboards are of a point class object that gets passed through the pipeline until it hits the geometry shader where it creates the quads based on the inputted size. To top it off and actually make them billboarded we need to rotate them to face the camera.
|
|
The shadows in the scene are created through the technique of shadow mapping. I don't have an example to show here but this is accomplished by calculating the depth of an object and rendering the depth to a separate 2D render texture. During the pixel shader, we check if the depth of the light is smaller than the depth of the object, apply lightning to the pixel and vice versa. The next step was to tackle multiple light sources which went easier than initially expected. You simply repeat the depth code for each light and save it to yet another separate render texture and redo the light vs object depth. Then just before you return the pixel colour, we add and saturate all the colours together to get the final colour.
|