CPE471 Final Project

For my final project in CPE 471, I chose to focus on creating an interesting scene. I combined multiple techniques learned in the class, including alpha masking, skyboxing, texture blending, and phong shading, as well as other techniques to create the water.

Effects Breakdown


To create the reflection, I rendered the scene upside down by applying a mirror matrix to all of my shapes, and clipped the scene at the y = 0 plane. The image was rendred to a texture to be used in the water shader. I took the texture, and sampled a noisy map plus a time offset to produce offset values. I used those values to offset where I sampled from the prerendered scene texture to create the ripply effect. Finally, I sampled a normal map to help me compute the frensel term, the ratio of reflected light to refracted light.


To create the refracted scene, I had to render the scene right side up, and clip objects above the y=0 plane. The scene was once again rendred to a texture. This new texture was blended with the reflection texture to create a more realistic water image. The color of the was multiplied by the color of the water to produce the illusion of depth. Without refraction, the water loses depth, and becomes a wavy mirror. For more information on implementing this shader yourself, head to https://ericpacelli.wordpress.com/2014/04/21/realistic-water-in-opengl-and-glsl/


To add more depth to my scene, I researched techniques to add fields of grass. I settled on a mix between a technique that was both reasonable to implement, and performed well. The grass is rendered by taking a dynamically built mesh that looks like three rectangle arranged in a star pattern. The shader itself reads off of an alpha map, and discards fragments with a value of zero. The color of the grass was determined by the texture lookup coordinate. The base of the grass is more blue than the top. Were I to implement this again, I would attempt to get true alpha blended grass. I had issues getting the blend order right, and went with the easy, but ineffeciant solution.


The skybox code is based off of class code. However, I modified the code to make it easier to generate and modify the texture. I also had to tweak the shaders to allow for inversions, since I had to render the skybox upside down. Since the texture lookup was based on the normal vector, I mirrored the model matrix while maintaining the original normals.


Reflection and Refraction normal, dudv maps and shader technique: https://ericpacelli.wordpress.com/2014/04/21/realistic-water-in-opengl-and-glsl/
Skybox Image: http://www.redsorceress.com/skybox.html
Grass technique: GPUGems Chapter 7. http://http.developer.nvidia.com/GPUGems/gpugems_ch07.html
Grass texture: http://i.imgur.com/YzzRt.png