Download presentation
Presentation is loading. Please wait.
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(GLenum mode); 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
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
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
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) 首先,用眼睛的位置減去物件的位置,算出一個向量。再用這個向量跟 up去做 cross,算出 right 向量。用 right 向量跟 up 向量的單位向量算出位移 (as a circle),最後用 accumulation combine result
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 Depth of Field
At least 4 passes each mirror Depth of Field Render Normally
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.