This project attempts to recreate Navi from a video game series called The Legend of Zelda. This project includes the use of FBO, blur, and screen blending to create a bloom affect on the fairy. Other techniques include tiled texturing, object loading, and implementation of a skybox.
The resources used in this program was found in the websites listed in the "Other Resources" index
The first step was to render a sphere with a texture mapped to it. The method chosen in this program was to create a sphere in the 3D modeling software Blender, and export the model as an .obj file. The .obj will contain information such as indices, vertices, normals, and uv mapping.
See Opengl-Tutorial.org for a guide.
To create a gradient from white to blue, the texture was rendered using rim lighting. Rim lighting uses a smooth step function and the dot product of the camera position and the normal to a point on the object to determine the brightness.
A good explanation can be found Fundza.com
Field buffer objects is a process in which you can render a scene that is normally drawn to a screen into a texture. This is useful with post-processing effects such as blur or blending. Essentially, the image above is just a texture of a previously drawn object being drawn onto a quad.
Songho has better description/theory behind the FBO.
A purpose of bluring an object is to create a blurry/foggy effect for a bloom. One of the most popular blur methods and the one used in the picture above is the gaussian blur. The gaussian blur is convolving an image with the Gaussian function. Normally, this effect is done in two passes, a horizontal blur, and a vertical blur.
Cameron Nouri Page Link. Cameron Nouri a fellow colleague suggested using a "Faster Gaussian Blur" mentioned in Faster Gaussian Blur in GLSL by xissburg. This algorithm precomputes 16 texture coordinates in the vertex shader that gets interpolated to the fragment shader. Improving overall performance of this process.
By combining a blurred image with an original object rendering, it creates a glow effect also known as bloom. FBO's can be blended together in multiple ways such as additive blend, screen blend, or softlight blend. Each process has a unique effect to them and serves their own purpose. The process used in the picture above used screen blending due to the mild results.
Nathaniel Meyer's tutorial on glow and bloom is a great resource to get the concept down. Be wary, the gaussian method used in Nathaniel Meyer's guide did not end up working for me. Probably at my fault.
The skybox is a box that surrounds the scene giving it a sense of environment. This is normally used to map out the sky, mountains, and other scenerary that is being viewed off in the distance. A simple way to create such a box is to create a cube with textures mapped to the sides. Blender can be used to easily create UV mappings to Each face of a cube making a convenient overlay image. An advantage to this method is it only requires one texture file for an entire cube.
The problems with large floors are they require a large texture file if the texture spanned the entirety of the floor. Otherwise, the texture would be stretched resulting in a low quality, pixelated image. An easy way to have a quality floor texture with a relatively small texture file is tiling the texture. Textures can be bound with a GL_REPEAT setting which causes the tile to repeat itself if the texture coordinates are bound outside the texture region. The farther out of bounds the texture coordinates are, the more the texture will repeat itself.
Other few minor details added to this program is movement for Navi, Phong shading with textures, and additional objects. Navi was programmed to go around a circle traveling in a random rate on the y axis. Other objects such as a Redead, Gossip Stone, and rocks are added to the scene to give character. Additionally, rocks were used to hide the contact point between the ground and the skybox. Lastly, the Phong shader was alterted to take account for textures. This was done by replacing the diffused color with the texture if it existed. Specular was excluded because it gave the objects a glossy look to it.
Working with FBO's, multiple objects, and textures led to interesting bugs. Listed below are a few tips to help debug errors that are hard to identify.
Verify your object have the correct index, vertices, normals, and texture coordinates. Error within this data can cause very unpredictable results.
Never bind two textures to the same target. Unexpected/blank images can be a result of this action
Be careful of depth and blend settings when drawing objects