Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
System of linear equations wikipedia , lookup
Matrix multiplication wikipedia , lookup
Singular-value decomposition wikipedia , lookup
Laplace–Runge–Lenz vector wikipedia , lookup
Matrix calculus wikipedia , lookup
Exterior algebra wikipedia , lookup
Vector space wikipedia , lookup
Cross product wikipedia , lookup
Euclidean vector wikipedia , lookup
Geometric algebra wikipedia , lookup
Today • Course organization • Course overview Computergrafik • Vectors and coordinate systems Matthias Zwicker Universität Bern Herbst 2009 Course organization Course organization Instructor Lecture • Matthias Zwicker ([email protected]) • Fridays, 14:00-16:00, Engehaldenstr. 8, Hörsaal 001 Teaching Assistant • To be announced Exercises • Fridays, 16:00-17:00 , Engehaldenstr. 8, Hörsaal 001 Class web page Web-based forum • Schedule, slides, reading, project descriptions, etc. • On ILIAS http://www.cgg.unibe.ch/teaching/courses/herbstsemester-2009/computergrafik https://ilias.unibe.ch/ilias3/repository.php?cmd=frameset&ref_id=66993 • Use your campus account to log in • Join group “IAM Computergrafik” with password “iamcg09” iamcg09 1 Textbooks Exercises • Fundamentals of Computer Graphics, Peter Shirley, 2nd edition (recommended) • Six programming projects – Available in the student bookstore • OpenGL Programming Guide, Guide Shreiner, Woo, Neider, Davis, 5th edition (recommended) • Two exercise series on paper • Successful completion of exercises is requirement for exam – E Each h assignment i t iis worth th 10 points i t – Total 80 points – Requirement is 75% (60 points) • Opengl Shading Language, Rost, Addison Wesley, 2nd edition (recommended) • Late penalty Programming Projects Programming Projects • Assignments and schedule on class webpage Build your own 3D rendering engine • Java base code and documentation on class webpage • Use ExWi pool or your own computer • Turn-in by demonstration to TA in ExWi pool – Thursdays 12:00-16:00 – More details, sign-up in exercise session – 50% of original score – Exceptions for military service, illness • Project 1: Matrices, Vectors, and Coordinate Transformations • Project 2: Interactive Viewing • Project P j 3: 3 Rasterization R i i • Project 4: Lighting and Texturing • Project 5: Scene Graphs • Project 6: Shader Programming Exercises on paper Prerequisites • Two exercise series on paper Familiarity with • Schedule TBA • Linear algebra • As preparation for exam • Java • Object oriented programming 2 Questions? Today • Course organization • Course overview • Vectors and coordinate systems Computer graphics Computer graphics Core areas • Rendering • Modeling • Animation Rendering Photorealistic rendering • Synthesis of 2D image from 3D scene description • Physically-based simulation of light, camera – Rendering algorithms interpret data structures that represent scenes using geometric primitives, material properties, and lights • 2D image is an array arra of pixels pi els – Red, green, blue values for each pixel • Different objectives – Photorealistic – Interactive – Artistic • Shadows, realistic illumination, multiple light bounces • Slow, minutes to hours per image • Special effects, movies • Not in this class 3 Photorealistic rendering Interactive rendering • Focus of this class • Produce images within milliseconds • Using specialized hardware, graphics processing units (GPUs) • Standardized S d di d AP APIs (O (OpenGL, G Di DirectX)) • Often “as photorealistic as possible” • Hard shadows, fake soft shadows, only single bounce of light • Interactive applications (games, …) See also http://en.wikipedia.org/wiki/Rendering_(computer_graphics) Interactive rendering Artistic rendering • Stylized • Artwork, illustrations, data visualization Modeling Modeling • Creating 3D geometric data • Basic 3D models consist of array of triangles – The “model” or the “scene” • Each triangle stores 3 vertices • By hand – Autodesk (Maya, AutoCAD), LightWave 3D, … • Free software • Each vertex contains – xyz position – Color – Etc. – Blender • Not as easy to use as Notepad… Maya Screenshot 4 Modeling Modeling Procedural tree • Procedurally, i.e. by writing programs Scanned statue • Scanning real-world objects Procedural city See also http://www.procedural.com/ Animation Animation • Deforming or editing the data • Change over time • Faces, articulated characters, fire, water, rigid objects, elastic objects, fracturing objects, … http://www.youtube.com/watch?v=Y1LN97l30-k Physics simulation In this class The Basics… • Rendering 3D models – Camera simulation – Interactive viewing – Lighting, shading • Modeling M d li g – Triangle meshes – Smooth surfaces • Experience with linear algebra, Java, OpenGL • Background for advanced topics http://www.youtube.com/watch?v=_FIKonHQF8Y See also http://www.nvidia.com/object/physx_new.html 5 Schedule 1. 2. 3. 4. Intrdoduction Homogeneous coordinates, transformations Projection Rasterization 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. Color Shading I Shading II Textures Scene management Curves Surfaces Advanced shading Shadows Exam Questions? Today 3D scene representation • Course organization • Goal: describe 3D scenes • Course overview • Vectors and coordinate systems – Position, orientation, motion of objects – Relation of objects to virtual camera – Projection of scene onto image plane • Linear algebra provides mathematical tools – Vectors, coordinate systems, matrices, etc. – As little abstract theory as possible in this class Topics today Vectors Linear algebra & vector geometry review • Direction and length in 3D • Vectors • Linear combination, linear dependency • Coordinate systems • Dot product, cross product – No anchor point • Vectors can describe – Difference between two 3D points – Speed of an object • Vectors are in bold-face • Normal vectors • Representation of planes using vectors 6 Vectors Vectors Multiplication by scalar Addition Vectors Vectors Addition Linear combination Vectors Coordinate systems Linear combination • Describe any vector with respect to three basis vectors Linearly dependent vectors • A set of vectors is linearly dependent if there exist scalars such that • Otherwise, they are linearly independent • The basis vectors form a coordinate system 7 Coordinate systems Coordinate systems • Any three vectors that are linearly independent could be used as a basis • Any three vectors that are linearly independent could be used as a basis – Different lengths – Not perpendicular to each other – Different lengths – Not perpendicular to each other • Why linearly independent? • Why exactly three vectors? • Other coordinate systems? Coordinate systems Coordinate Systems Euclidean coordinate systems Handedness • Basis vectors – Have unit length – Are perpendicular to each other • Orthonormal Right handed Vector arithmetic using coordinates Left handed Vector Magnitude • The magnitude (length) of a vector is: ⎡ ax ⎤ a = ⎢⎢ ay ⎥⎥ ⎢⎣ az ⎥⎦ ⎡bx ⎤ b = ⎢⎢ by ⎥⎥ ⎢⎣ bz ⎥⎦ ⎡ ax + bx ⎤ a + b = ⎢⎢ ay + by ⎥⎥ ⎣⎢ az + bz ⎦⎥ ⎡ ax − bx ⎤ a − b = ⎢⎢ ay − by ⎥⎥ ⎣⎢ az − bz ⎦⎥ ⎡−ax⎤ −a = ⎢⎢−ay⎥⎥ ⎣⎢−az ⎦⎥ ⎡sax⎤ sa = ⎢⎢say⎥⎥ ⎣⎢saz ⎦⎥ v = vx2 + vy2 + vz2 2 v = vx2 + vy2 + vz2 • A vector with length=1 length=1.0 0 is called a unit vector • We can also normalize a vector to make it a unit vector v v • Unit vectors are often used as surface normals 8 Questions? Dot product • Scalar value that tells us something about the relationship between two vectors – Product of lengths of vectors and cosine of angle between vectors • Definition does not refer to a coordinate system – Result is independent of Euclidean coordinate system Dot product Dot Product using coordinates • If a·b > 0 then θ < 90º • Result is independent of coordinate system! – Vectors point in the same general direction a ⋅ b = ∑ ai bi • If a·b < 0 then θ > 90º a ⋅ b = ax bx + ayby + az bz – V Vectors t point i t iin opposite it direction • If a·b = 0 then θ = 90º a ⋅ b = a b cos θ – Vectors are perpendicular – (or one or both of the vectors is degenerate (0,0,0)) Angle between vectors ⎛ a⋅b ⎞ θ = cos−1 ⎜ ⎝ a b ⎟⎠ ? Dot products with unit vector • If |u|=1.0 then a·u is the length of the orthogonal projection of a onto u a ⋅ b = a b cos θ ⎛ a⋅b ⎞ cosθ = ⎜ ⎝ a b ⎟⎠ • What is the meaning of a b a u a·u 9 Dot products with unit vectors Dot products with unit vectors 0 < a·b < 1 a·b = 1 a·b = 1 b a=b a·b a = b = 1.0 a = b = 1.0 a ⋅ b = cos (θ ) a ⋅ b = cos (θ ) Dot products with unit vectors Dot products with unit vectors 0 < a·b < 1 0 < a·b < 1 a·b = 1 a·b = 0 b a a·b = 1 a·b = 0 b a -1 < a·b < 0 a·b a a·b a = b = 1.0 a = b = 1.0 a ⋅ b = cos (θ ) a ⋅ b = cos (θ ) Dot products with unit vectors Surface normals • Vectors are direction and length in 3D 0 < a·b < 1 a·b = 1 a·b = 0 b -1 < a·b < 0 a·b = -1 a a·b • Can describe – Difference between two 3D points – Speed of an object – Surface normals: directions perpendicular to surfaces Normal vector a = b = 1.0 a ⋅ b = cos (θ ) Surface normals Surface 10 Representing planes Cross product • A plane can be defined by • Written as a x b – Its closest distance to the origin – Its normal vector • How can we determine if a point lies on the plane using the dot product? • A vector perpendicular to a and b – In the direction defined by the right hand rule – Length is area of parallelogram spanned by a and db • Definition does not refer to coordinate system! Cross product • If vectors a, b are unit length and perpendicular, then a, b, a x b is a right handed coordinate system • a x b = -(b x a) Cross product a × b is a vector perpendicular to Cross product a × b is a vector perpendicular to both a and b, in the direction defined by the right hand rule Vectors lie in the plane of the projection screen. Does point towards you or away from you? What about ? Cross product • Using coordinates both a and b, in the direction defined by the right hand rule a × b = a b sin i θ a × b = area of parallelogram ab a × b = 0 if a and b are parallel (or one or both degenerate) 11 Questions? Coming up Exercise session • Introduction to the Java base code • Representation of 3D shapes using triangle meshes Next class • Matrices and transformations 12