Slide 1

Slide 1 text

jgs SER 431 Advanced Graphics Lecture 17: Review Javier Gonzalez-Sanchez [email protected] PERALTA 230U Office Hours: By appointment

Slide 2

Slide 2 text

Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 1 jgs Calendar

Slide 3

Slide 3 text

jgs Noise (Procedural Texture/Surfaces Generation)

Slide 4

Slide 4 text

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 å = - =

Slide 5

Slide 5 text

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 å = - =

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 7 jgs Graphics https://www.youtube.com/watch?v=aviL3HX3UEc

Slide 9

Slide 9 text

jgs Collision (Axis-aligned bounding box)

Slide 10

Slide 10 text

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 }

Slide 11

Slide 11 text

Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 10 jgs AABB Calculate AABB Draw AABB with lines

Slide 12

Slide 12 text

jgs Shadows, Reflection, and Fog

Slide 13

Slide 13 text

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?

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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); //

Slide 16

Slide 16 text

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);

Slide 17

Slide 17 text

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(); }

Slide 18

Slide 18 text

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); }

Slide 19

Slide 19 text

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[4] = { 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);

Slide 20

Slide 20 text

jgs Particle Systems

Slide 21

Slide 21 text

Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 20 jgs Particles § Emitter § Behavioral parameter of a particle (lifetime, initial velocity, spawning rate, color) § Equations

Slide 22

Slide 22 text

Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 21 jgs Graphics https://www.youtube.com/watch?v=aviL3HX3UEc

Slide 23

Slide 23 text

jgs Curves

Slide 24

Slide 24 text

Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 23 jgs All about Curves

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 28 jgs Apply Bezier Algorithm

Slide 30

Slide 30 text

Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 29 jgs Apply B-spline Algorithm

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

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.