Program Description


 

Implement effects that are similar to windows, inlcuding planar reflection and refraction.
You also need to implement keyboard functions to control camera and adjust some parameters.

 

Due Day


 

2016/12/7 23:59
Please upload your entire files as a zip file to e3.

Please upload entire solution, project, source code, and objects!
And please use your school id as your file name.
For example: 9655862V1.zip

 

Requirement


 

Use stencil buffer to render scene only in window's area.
Use blending to render the transparent window.
Use accumulation buffer to accumulate effects of reflection and refraction.
Use back-face culling: glEnable(GL_CULL_FACE).

UI control:

    • Keyboard : Move the camera and adjust parameters.
      • 'w' : zoom in
      • 'a' : move left (circle the center)
      • 's' : zoom out
      • 'd' : move right (circle the center)
      • 'r' : increase reflectance 0.1f
      • 'f' : decrease reflectance 0.1f
      • 't' : increase transmittance 0.1f
      • 'g' : decrease transmittance 0.1f

Reflectance and transmittance is range 0 to 1.
Remeber to check your loaded light is point light.

Remeber to clear your buffers according your usage.

 

Implementation Steps


 

Step 1: Set stencil buffer

Set your window's area with stencil buffer.

Step 2: Refraction

You may need to use glFrontFace(GL_CCW).
Draw your scene to render the effect of refraction.
Use glAccum(GL_ACCUM, transmittance).

Step 3: Reflection

Filp your scene or camera along the window to form a reflected scene or camera.
If you flip camera, remenber your rendering image is left and right reversed.
You may need to use glFrontFace(GL_CW).

Draw your scene to render the effect of reflection.
Use glAccum(GL_ACCUM, reflectance).
PS: window's center position is (-20, 20, 0) and is parallel to yz-plane.

Step 4: Combination

You may need to use glFrontFace(GL_CCW).
Return the accumuation buffer to color buffer.

Draw your scene expect the window's area.

You may use these functions in OpenGL:

    • glColorMask
    • glDepthMask
    • glFrontFace
    • glCullFace

Test Scene


Cornell box (Click to download!) 

CombinedResult.png

Picture 1: combined result (reflectance: 0.5f, transmittance: 0.5f)

 

CameraLeft.png

Picture 2: camera move left (reflectance: 0.5f, transmittance: 0.5f)

 

CameraRight.png

 Picture 3: camera move right (reflectance: 0.5f, transmittance: 0.5f)

 

FullReflection.png

Picture 4: full reflection (reflectance: 1.0f, transmittance: 0.0f)

 

FullRefraction.png

Picture 5: full refraction (reflectance: 0.0f, transmittance: 1.0f)

Go to top