CS594 - Project 2
Byungil Jeong
- Programming Environment
- OS - linux
- Using OPENGL-2.0, GLSL, GLEW, GLUT, ImageMagick, MilkShape,
bob's OBJ library
- Application and Shaders
- pond.c - main application code, shader.c - load/access
shaders
- Bump mapping shader - bump.vert, bump.frag : rendering
walls/floor
- Water shader - water.vert, water.frag : rendering water
surface
- Modeling Environment
- Theme - a Pond in a hotel garden
- Using MilkShape for modeling and export models as WAVEFRONT
OBJ files
- OBJ library is used to load models into my OpenGL application with
textures
- Sky using geo-sphere, each building wall is a single
surface, extruding floor surface downward to make the pond
- A rock in the pond with 120 triangles
- Creating textures for sky, front/back walls,
side walls, floor, pond floor, pond sides, and rock.

- Bump Mapping

- Creating normal map from color map using ATI's normal map generator
(TGAtoDOT3).

- Automatic generation of tangential vector from normal vector
for irregular surfaces
vec3 vTangent;
if (gl_Normal.x ==
0.0 && gl_Normal.z == 0.0)
vTangent = vec3(1.0, 0.0, 0.0);
else
vTangent = vec3(gl_Normal.z, 0, -gl_Normal.x);

- Drawing Water
- The basic idea for drawing water came from Christian's
shader demo - Realistic Water using Bump Mapping tutorial
- Three pass rendering
- Pass 0 (Creating Reflection texture) : draw whole scene,
clip below
water surface, flip it upside down, store it as a texture
- Pass 1 (Creating Refraction texture) : draw whole scene as it is, store it as the
refraction texture
- Pass 2 (Drawing real scene and water)
When view point is above water : clip scene below water
When view point is below water : clip scene above water
Draw water surface using the reflection and refraction
texture (multi-texturing)
- gl_FragCoord.xy / window_size is used as the
texture coordinates for the reflection and refraction textures
- By drawing scenes on the water surface using textures, we can easily
give it distortion by adding DuDv map to the texture
coordinates.
- I used an ATI tool(DOT3toDUDV) again to generate the DuDv
map from the normal map. The original DuDv map (bottom left picture) is so
sharp that the water surface distorted by that looks noisy. So I applied
gaussian blur to the normal map (top right picture), generate DuDv map again
from it and applied gaussian blur again to the DuDv map (bottom right
picture). Then it gave smooth refraction to the water surface.


- If we don't clip the scene under water and draw water surface with
the reflection texture using alpha blending, we can get the following
picture. The under water scene is not refracted.

- Fog Effect
- I implemented blue color linear fog in the bump map shader as shown
in the following picture..
- It calculates how long the light passes through water
starting from an object before getting to eyes.

- In the pass 0, the fog effect is turned off because thr flipped scene
for reflection should not have fog.
- The fog effect is turned on for the pass 1 and 2 to render refraction
texture and under water scene.
- The following picture shows the scene from under water view with fog
effect.

- This scene is somewhat dark. I think this makes sense because
part of the light from the objects above is reflected on the water surface.
- Light Reflection
- Add fresnelTerm as described in Realistic Water using Bump
Mapping tutorial for light reflection.
- Add specular lighting on the water surface.
- One point light source is located on top of the front wall.

- Animation of Water Surface
- I implemented simple animation for the water surface by
adding offsets to the texture coordinate of DuDv map and normal map and
keep increasing the offsets.

- Additional notes
- gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;
should be added to a vertex shader if the scene drawn by the shader need to
be clipped using glClipPlane.
- Built-in varying variable gl_TexCoord should be used to
pass texture coordinate from a vertex shader to a fragment shader. I had
used user defined varying variable for this and got so much trouble.
- OBJ library can't read textures from a separate directory.
If I put all things in the same directory, it works fine.
- obj_draw_vertex, obj_draw_surface didn't work for me.
Links to Source codes
proj2.tar.gz
proj2-user.tar.gz (A few user interaction
added - change reflectivity, fog, wave speed ... for the presentation)
Please refer to README.txt in proj2/pond about user interaction
last revision 3/9/06