1Computer Graphics Programming with OpenGL Three Dimensions – 2 Lecture 7 John Shearer Culture Lab – space 2

Slides:



Advertisements
Similar presentations
Computer Graphics Programming: Matrices and Transformations CSE 3451 Matt Boggus.
Advertisements

Hidden Surface Removal CSE 581. Visibility Assumption: All polygons are opaque What polygons are visible with respect to your view frustum?  Outside:
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
CECS461 Computer Graphics II University of Missouri at Columbia Hidden Surface Removal.
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Programming with OpenGL Part 3: Three Dimensions.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
1 Dr. Scott Schaefer Hidden Surfaces. 2/62 Hidden Surfaces.
CS 4731: Computer Graphics Lecture 18: Hidden Surface Removal Emmanuel Agu.
CSC 461: Lecture 51 CSC461 Lecture 5: Simple OpenGL Program Objectives: Discuss a simple program Discuss a simple program Introduce the OpenGL program.
Hidden Surface Elimination Wen-Chieh (Steve) Lin Institute of Multimedia Engineering I-Chen Lin’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals.
1 CSC461 Lecture 7: 3D Programming in OpenGL Objectives: Develop 2D and 3D examples -- Sierpinski gasket: a fractal Develop 2D and 3D examples -- Sierpinski.
Vertices and Fragments III Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Sierpinski Gasket Program
1 Lecture 5 Rendering 3D graphical primitives. 2 3D Rendering Example:
1 Chapter 5 Viewing. 2 Perspective Projection 3 Parallel Projection.
Hidden Surface Removal
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
02/26/02 (c) 2002 University of Wisconsin, CS 559 Last Time Canonical view pipeline Orthographic projection –There was an error in the matrix for taking.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
Demetriou/Loizidou – ACSC330 – Chapter 2 Graphics Programming Dr. Giorgos A. Demetriou Dr. Stephania Loizidou Himona Computer Science Frederick Institute.
The BSP-tree from Prof. Seth MIT.. Motivation for BSP Trees: The Visibility Problem We have a set of objects (either 2d or 3d) in space. We have.
Visible-Surface Detection Jehee Lee Seoul National University.
CS 638, Fall 2001 Multi-Pass Rendering The pipeline takes one triangle at a time, so only local information, and pre-computed maps, are available Multi-Pass.
Hidden Surface Removal 1.  Suppose that we have the polyhedron which has 3 totally visible surfaces, 4 totally invisible/hidden surfaces, and 1 partially.
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
Implementation II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
1 Programming with OpenGL Part 3: Three Dimensions Yuanfeng Zhou Shandong University.
1Computer Graphics Programming with OpenGL Three Dimensions Lecture 06 John Shearer Culture Lab – space 2
Computer Graphics I, Fall 2010 Programming with OpenGL Part 3: Three Dimensions.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Programming with OpenGL Review.
1 Chapter 2: Graphics Programming Bryson Payne CSCI 3600 NGCSU.
CS 480/680 Computer Graphics Programming with Open GL Part 6: Three Dimensions Dr. Frederick C Harris, Jr. Fall 2011.
Implementation II.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Computer Graphics I, Fall 2010 Implementation II.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 3: Three Dimensions Ed Angel Professor of Computer Science,
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 6: Three Dimensions Ed Angel Professor.
31/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 2: Introduction.
1 Computer Graphics Week11 : Hidden Surface Removal.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
Data Structures.
Computer Graphics Implementation II
Hidden Surface Removal
CSC461: Lecture 20 Parallel Projections in OpenGL
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 1: Background
Programming with OpenGL Part 3: Three Dimensions
OpenGL API 2D Graphic Primitives
Introduction to Computer Graphics with WebGL
Implementation II Ed Angel Professor Emeritus of Computer Science
Programming with OpenGL Part 3: Three Dimensions
Lecture 13 Clipping & Scan Conversion
Visibility (hidden surface removal)
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 6: Three Dimensions
Programming with OpenGL Part 3: Three Dimensions
Lecture 31: Visible Surface Detection
Implementation II Ed Angel Professor Emeritus of Computer Science
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Programming with OpenGL Part 3: Three Dimensions
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Presentation transcript:

1Computer Graphics Programming with OpenGL Three Dimensions – 2 Lecture 7 John Shearer Culture Lab – space 2

2Computer Graphics Objectives Extend Sierpinski gasket to 3D Other ways of making Sierpinski gasket

3Computer Graphics Moving to 3D We can easily make the program three- dimensional by using –glVertex3f –glOrtho But that would not be very interesting –The gasket is still a 2D object Instead, we can start with a tetrahedron

4Computer Graphics 3D Sierpinski Gasket Tetrahedron / Triangle-based pyramid –Polyhedron composed of four triangular faces –Three of which meet at each vertex Either: –Slice through the tetrahedron with the points through the bisectors of each side –Subdivide each of the four faces

5Computer Graphics 3D Sierpinski Gasket 2 Appears as if we remove a solid tetrahedron from the center leaving four smaller tetrahedra

6Computer Graphics divideTriangle pseudocode divideTriangle(vector2f a, vector2f b, vector2f c, int m) { // triangle subdivision using vertex numbers vector2f v0, v1, v2; if(m>0) { v0.x = (a.x +_b.x) / 2; v0.y = (a.y +_b.y) / 2; v1.x = (b.x +_c.x) / 2; v1.y = (b.y +_c.y) / 2; v2.x = (c.x +_a.x) / 2; v2.y = (c.y +_a.y) / 2; divide_triangle(a, v0, v1, m-1); divide_triangle(c, v1, v2, m-1); divide_triangle(b, v2, v0, m-1); } else(triangle(a,b,c)); // draw triangle at end of recursion }

7Computer Graphics Subdividing triangular faces Use divideTriangle from 2D How to apply to a tetrahedron?

8Computer Graphics Subdividing triangular faces 2 Use divideTriangle from 2D How to apply to a tetrahedron? void tetrahedron( int m) { glColor3f(1.0,0.0,0.0); divide_triangle(v[0], v[1], v[2], m); glColor3f(0.0,1.0,0.0); divide_triangle(v[3], v[2], v[1], m); glColor3f(0.0,0.0,1.0); divide_triangle(v[0], v[3], v[1], m); glColor3f(0.0,0.0,0.0); divide_triangle(v[0], v[2], v[3], m); }

9Computer Graphics Almost Correct 1 The triangles are drawn in the order they are defined in the program, so the front triangles are not always rendered in front of triangles behind them …

10Computer Graphics Almost Correct 2 – what we get

11Computer Graphics Almost Correct 3 – what we want

12Computer Graphics Hidden-Surface Removal We want to see only those surfaces in front of other surfaces OpenGL uses a hidden-surface method called the z-buffer algorithm that saves depth information as objects are rendered so that only the front objects appear in the image

13Computer Graphics Using the z-buffer algorithm The algorithm uses an extra buffer, the z-buffer, to store depth information as geometry travels down the pipeline It must be – Lwjgl have z-buffer enabled by default – Enabled in init glEnable(GL_DEPTH_TEST) – Cleared in the display callback glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

14Computer Graphics Surface vs Volume Subdvision In our example, we divided the surface of each face We could also divide the volume using the same midpoints The midpoints define four smaller tetrahedrons, one for each vertex Keeping only these tetrahedrons removes a volume in the middle

15Computer Graphics Volume Subdvision What functions do we need?

16Computer Graphics Volume Subdvision What functions do we need? – drawTetrahedron – divideTetrahodron

17Computer Graphics Back-face culling Determines whether a polygon of a graphical object is visible, depending on the position of the camera. Tests whether the points in the polygon appear in clockwise or counter-clockwise order when projected onto the screen. User specifies that front-facing polygons have a clockwise winding (or vice-versa), if the polygon projected on the screen has a counter-clockwise winding it has been rotated to face away from the camera and will not be drawn. Makes rendering objects quicker and more efficient by reducing the number of polygons for the program to draw

18Computer Graphics Square-based Sierpinski Gasket A Sierpiński square- based pyramid and its 'inverse'

19Computer Graphics Another way of making Sierpinski gasket 1. Take 3 points in a plane, and form a triangle 2. Randomly select any point inside the triangle and move half the distance from that point to any of the 3 vertex points. Plot the current position. 3. Repeat from step 2. Write some pseudo code to draw the above Would this work well in openGL?