260 likes | 678 Views
SEM023/CD3018 Advanced Computer Graphics Lecture 1 Friday Lecture 12:00 – 1300, Room 3.01 Lab/Tutorials 13:00 – 15:00, Lab 6.16/6.20 Lecturer : Dr Paul Strickland Room 737, p.m.strickland@ljmu.ac.uk Module Aims To explain the principles and techniques underlying 3D computer graphics.
E N D
SEM023/CD3018 Advanced Computer Graphics Lecture 1 Friday Lecture 12:00 – 1300, Room 3.01 Lab/Tutorials 13:00 – 15:00, Lab 6.16/6.20 Lecturer: Dr Paul Strickland Room 737, p.m.strickland@ljmu.ac.uk CMPSEM023/CMPCD3018: Module Introduction
Module Aims • To explain the principles and techniques underlying 3D computer graphics. • To introduce a current 3D graphics API. • To develop programming skills in 3D computer graphics. • To introduce advanced techniques for 3D rendering and modelling. • To demonstrate current advanced techniques and research in computer graphics. (MSc)
Learning Outcomes • Demonstrate competence in a current 3D graphics API. • Solve problems in 3D graphics and develop graphical applications. • Explain the principles of 3D graphics rendering and modelling. • Critically Evaluate algorithms for 3D graphics problems (MSc)
Assessment • Exam: Coursework ratio: 60:40 • Coursework worth 40% • Near End semester submission • Exam covers outcomes 2, 3 and 4 • Coursework outcomes 1, 2, 3 and 4
Outline Syllabus • Introduction to 3D Modelling and Rendering. • Basic Algorithms from 2D graphics • 3D Input devices • Principles of Geometrical Transformations (Matrix Algebra) • Viewing in 3D
Outline Syllabus … • Visual Realism • Visible and Hidden Surfaces • Illumination and Shading • Advanced Modelling Techniques • 3D animation* • Colour Models* • *Depending on time available
Recommended Prior Study • CD1003/CD1004 or equivalent C/C++ programming knowledge • Basic Computer Graphics Programming • Which means ….
Basic Computer Graphics • Introduction to 2D graphics - Raster-based output, graphics primitives and 2D graphics libraries. • 2D programming using OpenGL • Handling event-driven user input in OpenGL • Introduction to programming 3D graphics - Primitives, transformation, translation and rotation, materials and simple lighting models
Course materials • Angel E, (2003) “Interactive Computer Graphics: A top-down approach with OpenGL”, Addison-Wesley, ISBN 0321190440 • Woo Mason, Neider Jackie, David Tom, Shriner Dave. (1999) 'OpenGL 1.2 Programming Guide' 3rd Addison Wesley ISBN 0201604582 (online) • Lengyel, (2002) “Mathematics for 3D game programming and Computer Graphics”, Charles River Media, ISBN 1584502770 • Foley, et al. “Computer Graphics Principles and Practice”, Addison-Wesley, ISBN 0201121107
Course materials … • Will be on Blackboard • See also CD2012 OpenGL links from • http://java.cms.livjm.ac.uk/homepage/staff/cmsdengl/Teaching/cd3018revision.html (Dr. Dave England web site) • And L:\CD2012 especially for old examples and GLUT resources • GLUT works with Visual C++ and Borland.
Revision and Examples • Most of Computer Graphics involves finding the most correct and efficient algorithms to represent the real, continuous 3D world on a 2D space in discrete, pixel coordinates • This is achieved by mathematically and physically modelling aspects of the real world
Scan conversion • Scan conversion is the process of translating a geometric or mathematical representation of an object into a set of discrete points on the screen • Ideally we would like efficient algorithms which avoid too great a reliance on floating point operations
Example 1: Lines • Geometric lines are represented by the equation y = mx +c • Where all values are floating point • And m is the slope of the line • Also the mathematical line has no endpoints • How do we draw a continuous, line in pixels?
y (x2,y2) y (x1,y1) x x Drawing Straight Lines • If the equation of the line is y = mx + c, then the slope, m, is given bym = (y2 - y1) / (x2 - x1) • y = m x
The basic incremental algorithm • We can simply use rounding to Write the pixel with the least deviation from our desired mathematical line. • x = 1 and yi = mxi+ c and the point is: • (xi, round (yi)) • However • This requires floating point arithmetic • The rounding errors grow with longer lines
Bressenham’s algorithm NE M E
Bressenham’s algorithm • Bressenham’s algorithm • uses integer calculations and • Incrementally works out the shift in pixel values from the true line • This technique can also be applied to Circles • It uses a decision variable to decide to draw the pixel above or below the true line
Bressenham’s algorithm • The decision variable, d is initialised • If d < 0, increment x, and set the decision variable to draw below the line • Else , increment x and y, set the decision variable to draw below the line • Draw Pixel at X,Y
Bressenham’s algorithm dx = x2 – x1; dy = y2-y1; X = x1; Y = y1; set_pixel (X,Y); d = 2 *dy – dx; incrE = 2 *dy; incNE = 2*(dy –dx); while (x < x1) { if (d<=0) {d += incrE;X++;} else {d += incrNE; X++; Y++} set_pixel (X,Y); }
Example 2: Circles • We can apply the same technique to circle drawing • The true circle can be calculated as • Y= +/- (R2 – X2) • Again this requires floating point calculations and will not produce a realistic curve
E M SE Bressenham’s Circles • At each point we have to decide which of the candidate pixels is closest to the true line
Bressenham’s Circles • With Bressenham’s algorithm for circles we again initialise the decision variable d • Then for each step in x • If d < 0 select the top most pixel • Else select the lowest pixel and decrement y • Increment x • Draw Pixel at X,Y • See Foley and van Dam, Fig. 3.15
Bressenham’s Circles • We can further refine the technique to • Remove floating point arithmetic (See Foley and van Dam, Fig.3.16) • Use 2nd order differences, i.e. the rate of change of the slope of the curve at any point • Only addition and subtraction is used in the decision making process (See Foley and van Dam, Fig. 3.18)
Practical • To compile an OpenGL program with Visual C++, see tutorial 1 in L:SEM023 • Study the program complete.cpp. Work out the following • How are the coordinates of the objects specified? • How are the objects located in 3D? • How are object materials specified?
Practical… 4. How is scene lighting controlled? 5. How is keyboard input handled and 6. How does the scene respond to keyboard input? 7. How are textures applied to some of the objects and not others? 8. How is graphical state managed so that objects, materials and textures are used at the right time? (hint: what do push and pop matrix do?) 3. Compile the program complete.cpp
Summary • We have introduced the module and the topics in 3D graphics • For next week: study the complete.cpp code and come up with a list of answers and further questions about the program • Next Week: Answering the questions about complete.cpp