Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 6 jgs Step 2. init() // init void init() { // init as usual here... //define the value to use as clean. glClearStencil(0); }
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 13 jgs Planar Reflections § Easy hack, draw the object twice, § One time has glScalef(1,-1,1) to reflect through the floor
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 17 jgs Planar Reflections § Stencil can help to maintain the floor § Clear stencil to zero. § Draw floor polygon with stencil set to one. § Then, only draw reflection where stencil is one. § Finally, deactivate stencil and draw the rest of the scene.
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 21 jgs One Last Thing void display(void) { glEnable(GL_CULL_FACE); // checks all the faces that are front facing towards // the viewer and renders those while discarding all // the faces that are back facing // Improve performance also! glDisable(GL_CULL_FACE); }
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 22 jgs Test Yourselves § Test 1. Add reflections to your game. For instance, add a mirror or a table with a reflective surface § Test 2. Add a menu that allows enable/disable reflections
jgs SER431 Advanced Graphics Javier Gonzalez-Sanchez [email protected] Fall 2018 Disclaimer. These slides can only be used as study material for the class SER431 at ASU. They cannot be distributed or used for another purpose.