1 / 20

Multiple-pass Reflection & Depth of Field Assignment 2

Implement multiple-pass reflection and depth of field techniques for assignment 2. Deadline: 12/18/23:59. Follow system settings and implement the main function, display function, and mirror reflections. Use stencil buffer and draw scenes accordingly. Apply depth of field using accumulation buffer and jittered positions.

vspence
Download Presentation

Multiple-pass Reflection & Depth of Field Assignment 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Multiple-pass Reflection Depth of Field Assignment 2

  2. Assignment 2 • DeadLine: 12/18 23:59 • Multiple-pass Reflection • Depth of Field

  3. Assignment 2 • It is not necessary to follow TAs implementation rule/steps. • It is free if it comes up the same result. • Do Not Copy • We ‘ll announce Demo after deadline.

  4. Assignment 2

  5. System Setting • Main Function • glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);

  6. System Setting • Display Function • glEnable(GL_STENCIL_TEST); • glClearStencil(initial_value); • glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_ACCUM_BUFFER_BIT);

  7. Multiple-pass Reflection– Mirror Data • Front Mirror Reflection • position is (-40, 20, 0) • parallel to yz-plane. • Back Mirror Reflection • position is (40, 20, 0) • parallel to yz-plane

  8. Multiple-pass Reflection- Step • Set Stencil Buffer value • Use “glColorMask before” / “glClear after” drawing make it non-visible • Not visible • Draw Scene • In each case(value),draw the “Right” Scene

  9. Stencil Buffer - Reflection • glCullFace(GLenummode); • Default = GL_BACK • Doing back-face culling • Drawing Reflection of Scene,we only take the BACK-FACE part. • Doing front-face culling

  10. Set Stencil Buffer value- Initial Value 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

  11. Set Stencil Buffer value- Setting Mirror • glStencilFunc(GL_ALWAYS, 1, 0xFF); • glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); • drawMirror()

  12. Set Stencil Buffer value- Mirror Value 000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000

  13. Set Stencil Buffer value– Setting Scene • glStencilFunc(GL_EQUAL, 1, 0xFF); • glStencilOp(GL_KEEP, GL_KEEP, GL_DECR); • drawScene() • //The part closer to Camera than Mirror

  14. Set Stencil Buffer value- Final Value 000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100001111111111111111111111111111111111111000011111111111111111111111111111111111110000111111111111111111111111111111111111100001111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000

  15. Stencil Buffer– Draw Scene • glStencilFunc(GL_EQUAL, 0, 0xFF); • glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); • drawScene() • //The part closer to Camera than Mirror

  16. Stencil Buffer– Draw Scene • glStencilFunc(GL_EQUAL, 1, 0xFF); • glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); • drawScene() • 1st Reflection in the Mirror

  17. Depth Of Field • gluLookAt( eyes, target, up ) • Combine the result with Accumulation Buffer • gluLookAt( eyes + jitter, object, up )

  18. Depth Of Field (II)

  19. Depth of Field (III) • 算出 新的 座標系 (forward, right, up) • For i = [ 0 : N) • 用 right & up 算出 jitter 的新位置 • ( jitter = right * cosine + up * sine ) • glEnable(GL_MODELVIEW) • glLoadIdentity() • glLookAt() • (draw your scene) • glAccum( i ? GL_ACCUM : GL_LOAD, 1.0 / N); • glAccum(GL_RETURN, 1.0)

  20. Assignment Request • Mobile Camera • Multi-pass Reflection • At least 4 passes each mirror • Depth of Field • Render Normally

More Related