CS513 Assignment 5.3: Shading Frank

by Muhammad Karim

General Configurations:
   # Development Platform: Windows 7 x64, Visual Studio IDE, Debug+Release build
   # Used OpenFrameworks library
   # CPU: Intel Core2Duo 2.24 GHz
   # Graphics Hardware: ATI Mobility Radeon HD 3470 (OpenGL 2.1)

  1. Sub-Goal 4: Multiple Spot lights with Percentage-Closer Soft-Shadows


    Implemented a version of Percentage-Closer Soft Shadows, by taking multiple (9 per fragment in this image) samples from the shadow map for each light. And finally calculating the percentage of visibility of each fragment based on what fraction of those samples are visible. This gives really nicer results with a size of the penumbra proportional to the size of the sampling kernel (3 in x:dim, 3 in y:dim, 3 in x=y:dim, instead taking 3x3 block of pixels)


  2. Sub-Goal 3: Multiple Spot lights


    Got multiple shadows for every light (3 here) working! Need to handle the shadow boundaries though.


    A view of Frank with 3 spotlights with 3 different colors (1 white, 1 yellowish, 1 redish). All casting self-shadows.


  3. Sub-Goal 2: Conserving Energy (Blinn-Phong)


    A front view of Frank with a conservative implementation of Blinn-Phong.


    A back view of Frank with a conservative implementation of Blinn-Phong. Notice the self shadows.


    Description:
    I tried to balance between 2 terms: a Diffuse term and a Specular term. The Diffuse term includes the light returned (Lret) from inside translucent Frank from the light that entered through a fragment. I also calculated the light that goes through (Lt assuming all went in) and comes out of the other side (Lout), so for faces that are not seeing the light, they only consider this Lout. I used the cosign term between the fragments normal and lights direction in calculating the available light on a fragment. And for the Specular term I used the Half vector method of Blinn-Phong and Sloan and Hoffman's normalization term to calculated reflected light off the surface.
    (I will include the final details after some more refinements with the final submission.)

  4. Sub-Goal 1: Resolving the artifacts on seams


    Here is the result of the seam correction technique, the highlighted image on the bottom shows the baked positions, and the highlighted image on the top shows the same positions with the seam edges rendered beneath them.


    Seam Rendering
    Seams rendered as lines and points in an FBO Using OpenGL line and point aliasing

    The seam edges were rendered in an FBO, 1 line (width=6) and 2 points for each edge. Using OpenGL's line and poing aliasing makes the seams rendered a bit better.


    Description of the Seam Correction algorithms:
    First while reading the triangles from the obj file a list was populated that contains for each Vertex a list of Vertices that have the same coordinates but different texture coordinates. (There were hardly more than 2 in each list). Then this information was used to find seam edges. So when comparing each Triangle with another I first check if they have at least 2 duplicate vertices, that have different texture coordinates. This simple check increases the speed of finding and comparing edged several order of magnitude faster of this O(N*N) algorithm where N = number of triangles (for each pair of triangles the number of comparisons is constant (9x2 edge compares).

    The seam edges were then rendered as: for each edge => render 1 line with width d and render 2 points in each vertices with size d. Then while rendering them in the Fbo they were anti-aliased using OpenGL's GL_LINE_SMOOTH and GL_POINT_SMOOTH states, which gives a better results. Then following the rendering of the seams, Franks's vertices were rendered over the same Fbo, which replaced some inside fragments of the seams but now have a wider lookup area near there seams.

  5. The rendering equation used:

  6. The Frank lighting Shader is here.
  7. The Phong Shader used in the ground/objects with soft-shadows is here.
  8. The Blur LightMap shader is here.
  9. ** Entire Source code is: here.
    ** OpenFrameworks lib (required): here.
    *** Source code sample of important parts: here.