180

# SER431 Lecture 17

Midterm Review
(201810)

October 18, 2018

## Transcript

1. ### jgs SER 431 Advanced Graphics Lecture 17: Review Javier Gonzalez-Sanchez

javiergs@asu.edu PERALTA 230U Office Hours: By appointment

Calendar

4. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 3 jgs

Multi-scale Function Adding Noise over diverse frequencies and amplitudes )) * , * , * ( * ) , , ( 1 r scale t scale s scale noise amplitude r t s f i i i bands i i å = - =
5. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 4 jgs

Sum of Absolute Values Adding Noise over absolute values is Good for fire )) , , ( ( ) , , ( 1 r scale t scale s scale noise amplitude r t s f i i i bands i i å = - =
6. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 5 jgs

Marble Principle ))) , , ( ( * sin( ) , , ( 4 1 r scale t scale s scale noise amplitude s r t s f i i i i i å = - = Using sin( ) function plus noise
7. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 6 jgs

Marble Example § MarbleMap is from black to white § Scale scales [min, max] to [0,1] § u and v are in range [0,1] § Does not look that great, maybe a more complex color ramp is needed )) ) 5 . 11 , * 2 * 5 , * 2 * 5 ( * 2 * 6 * 20 sin ( ( ) , ( 4 1 ÷ ø ö ç è æ + = å = - v u PNoise u Scale MarbleMap v u Texture i i i i

10. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 9 jgs

§Axis-aligned Bounding Box (AABB) § An AABB is defined by its minimal and maximal positions in space Pmin=(xmin, ymin, zmin), Pmax = (xmax, ymax, zmax) § Calculate Initialize pmin to +infinite or the first vertex Initialize pmax to –infinite or the first vertex foreach vertex p do { if (p.x < pmin.x) then pmin.x = p.x if (p.y < pmin.y) then pmin.y = p.y if (p.z > pmax.z) then pmax.z = p.z }
11. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 10 jgs

AABB Calculate AABB Draw AABB with lines

13. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 12 jgs

Concepts § What is the shadow matrix? § What is the stencil buffer? § What is double blending and how to avoid it?
14. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 13 jgs

Step 2. init() void init() { // ... glClearStencil(0); }
15. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 14 jgs

Step 3. display() void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glEnable(GL_STENCIL_TEST); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // glColorMask controls with Stencil or Color buffer? glStencilFunc(GL_ALWAYS, 1, 1); glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); // <Render stencil box>
16. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 15 jgs

glDisable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-50.0, 50, -50.0, 50.0, 1.0, -1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushMatrix(); glTranslatef(0, 0, 0); glBegin(GL_TRIANGLES); glVertex2f(-20.0, -20.0); glVertex2f( 20.0, -20.0); glVertex2f( 0.0, 20.0); glEnd(); glPopMatrix(); glEnable(GL_DEPTH_TEST);
17. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 16 jgs

// re-enable color and disable stencil glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glStencilFunc(GL_EQUAL, 1, 1); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // draw your colors here glDisable(GL_STENCIL_TEST); glutSwapBuffers(); }
18. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 17 jgs

Culling Face 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); }
19. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 18 jgs

Fog glEnable(GL_FOG); // specifies the equation to be used to compute the fog blend factor. // GL_LINEAR, GL_EXP, and GL_EXP2. // initial fog mode is GL_EXP glFogi(GL_FOG_MODE, GL_LINEAR); // the fog color. Color components are in the range [0,1]. // the initial fog color is (0, 0, 0, 0). GLfloat fogColor = { 0.5, 0.5, 0.5, 1.0 }; glFogfv(GL_FOG_COLOR, fogColor); //Used in exponential fog equations. The initial fog density is 1. // Only nonnegative densities are accepted. glFogf(GL_FOG_DENSITY, 0.25); // the near distance used in the linear fog equation. The initial near distance is 0 glFogf(GL_FOG_START, 10.0); // the far distance used in the linear fog equation. The initial far distance is 1. glFogf(GL_FOG_END, 6000.0);

21. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 20 jgs

Particles § Emitter § Behavioral parameter of a particle (lifetime, initial velocity, spawning rate, color) § Equations

25. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 24 jgs

Curves § What is a Curve? § What is Curvature? § Parametric Representation § Curve equation (general) § Control Graph § Control Point § Tangent
26. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 25 jgs

Curves § Explain C0, C1, C2 continuity § Explain similarities and differences of: Bezier, Hermite, Chaikin and B-spline Curves § What is a Blending Function? § Explain A-frame
27. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 26 jgs

Blending Functions Bezier § B0 (t)=(1-t)3 § B1 (t)=3t(1-t)2 § B2 (t)=3t2(1-t) § B3 (t)=(t)3 Cubic B-Spline § B0 (t)=((1-t)3)/ 6 B1 (t)=(3t3 -6t2 + 4)/ 6 B2 (t)=(-3t3 + 3t2 + 3t + 1) / 6 B3 (t)=(t)3 / 6
28. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 27 jgs

Blending Functions Hermite § B0 (t)= 2*t3 – 3*t2 + 1, § B1 (t)= -2*t3 + 3*t2, § B2 (t)= t3 - 2*t2 + t, § B3 (t)= t3 – t2
29. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 28 jgs

Apply Bezier Algorithm
30. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 29 jgs

Apply B-spline Algorithm
31. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 30 jgs

Apply Chaikin Algorithm Qi=3/4Pi + 1/4Pi+1 Ri=1/4Pi + 3/4Pi+1
32. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 31 jgs

Disclaimer This list of topics is not Comprehensive For a full list of topics review lectures 1 to 16
33. ### jgs SER431 Advanced Graphics Javier Gonzalez-Sanchez javiergs@asu.edu 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.