COMP 261 Lecture 13 3D Graphics 1 of 2.

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

15.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 15 – Visible Surfaces and Shadows.
8.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 8 Polygon Rendering.
3D Graphics Rendering and Terrain Modeling
CS 4363/6353 INTRODUCTION TO COMPUTER GRAPHICS. WHAT YOU’LL SEE Interactive 3D computer graphics Real-time 2D, but mostly 3D OpenGL C/C++ (if you don’t.
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
HCI 530 : Seminar (HCI) Damian Schofield.
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
1 Computer Graphics Week13 –Shading Models. Shading Models Flat Shading Model: In this technique, each surface is assumed to have one normal vector (usually.
COMP 261 Lecture 14 3D Graphics 2 of 2. Doing better than 3x3? Translation, scaling, rotation are different. Awkward to combine them. Use homogeneous.
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Basic Graphics Concepts Day One CSCI 440. Terminology object - the thing being modeled image - view of object(s) on the screen frame buffer - memory that.
COMP 175: Computer Graphics March 24, 2015
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
3D Programming Concepts How objects are described in 3D and Rendering Pipelines – A conceptual way of thinking of the steps involved of converting an abstract.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Computer Graphics An Introduction. What’s this course all about? 06/10/2015 Lecture 1 2 We will cover… Graphics programming and algorithms Graphics data.
COMP 261 Lecture 16 3D Rendering. input: set of polygons viewing direction direction of light source(s) size of window. output: an image Actions rotate.
Shading & Texture. Shading Flat Shading The process of assigning colors to pixels. Smooth Shading Gouraud ShadingPhong Shading Shading.
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
Lecture 6: 3D graphics Concepts 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
Graphics Matrices. Today’s Lecture Brought to you by the integer 6 and letter ‘K’; 2D and 3D points Matrices Rotations Translation Putting it all together.
Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Subject Name: Computer Graphics Subject Code: Textbook: “Computer Graphics”, C Version By Hearn and Baker Credits: 6 1.
Computer Graphics Matrices
Honors Geometry.  We learned how to set up a polygon / vertex matrix  We learned how to add matrices  We learned how to multiply matrices.
Computer Graphics One of the central components of three-dimensional graphics has been a basic system that renders objects represented by a set of polygons.
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
Applications and Rendering pipeline
Computer Graphics (Fall 2006) COMS 4160, Lecture 16: Illumination and Shading 1
Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics.
Introduction to Computer Graphics
Visible Surface Detection
CSE 167 [Win 17], Lecture 2: Review of Basic Math Ravi Ramamoorthi
Rendering Pipeline Fall, 2015.
- Introduction - Graphics Pipeline
Geometric Transformations
Computer Graphics Raster Devices Transformations
Computer Graphics.
© University of Wisconsin, CS559 Spring 2004
Photorealistic Rendering vs. Interactive 3D Graphics
Camera Position (5.6) we specify the position and orientation of the camera to determine what will be seen. use gluLookAt (eye x, y, z, at x, y, z, up.
Computer Graphics CC416 Week 15 3D Graphics.
Intro to 3D Graphics.
BACK FACE DETECTION back-face detection Determination of whether a face of an object is facing backward and therefore invisible. The usual test is whether.
3D Transformations Source & Courtesy: University of Wisconsin,
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
3D Graphics Rendering PPT By Ricardo Veguilla.
CENG 477 Introduction to Computer Graphics
CS451Real-time Rendering Pipeline
Properties of Translations
Properties of Translations
Chapter 14 Shading Models.
Fitting Curve Models to Edges
COMP 175: Computer Graphics February 9, 2016
FP1 Matrices Transformations
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Chapter IV Spaces and Transforms
GAM 325/425: Applied 3D Geometry
Computer Graphics One of the central components of three-dimensional graphics has been a basic system that renders objects represented by a set of polygons.
(c) 2002 University of Wisconsin, CS 559
(c) University of Wisconsin, CS559
with Applications in Computer Graphics
Properties or Rules of Transformations
Chapter 14 Shading Models.
Presentation transcript:

COMP 261 Lecture 13 3D Graphics 1 of 2

Outline Rendering 3D images Polygons Coordinate system Polygon Transformation

3D graphics A lot of applications Movies, Animations, Games, …

3D graphics Different business from 2D images! Model of 3d objects - shape - surface properties - material/mass/.. - movement/animation - light sources … Image to display Rendering

In This Block Representing/Drawing polygons Move them Lighting Hiding Scan conversion (“filling in…”) Assignment 3

Polygon Approximation of a surface a small piece of surface (nearly flat) We only consider triangular polygons

Polygons How to represent a polygon? Ordered list of vertices Representing vertices – 3D coordinate system v1 = (x1,y1,z1), v2 = (x2,y2,z2), … vn = (xn,yn,zn) In order Coordinate system x z y v1 (x1,y1,z1) v2 (x2,y2,z2) v3 (x3,y3,z3)

3D Coordinate System Order x, y and z using right-hand rule Thumb pointing to z axis Curl of other fingers from x to y (anti-clockwise viewing from z axis) Left-handed Right-handed wikipedia

Right-Hand Rule Standard mathematical notation In computer x y y x Where should z-axis face? x y x y Where should z-axis face?

Perspective Projection pda-fx.net

Polygon Rendering What the viewer would see based on Locations of screen, object, light source Angles …

Polygon Rendering Issues Representation of polygons Changing with respect to the viewer's perspective: rotation, translation, scaling Hidden parts and objects obscuring others Illumination and surface effects [shadows and reflections from other objects] Z-buffer: A standard 3D rendering pipeline

Simple Z-buffer Rendering Pipeline input: set of polygons (position, colour), viewing direction, direction of light source(s), window size output: an image rotate polygons and light source(s) so viewing along z axis translate & scale to fit window remove any polygons facing away from viewer for each polygon compute shading work out which image pixels it will affect for each pixel: write shading and depth to z-buffer (retains only the shading of the closest surface) convert z-buffer to image A new topic fwd fwd fwd: from Grandma, on polygons., was created to a board you are watching. Tony Butler-Yeoman wrote Today at 2:07pm the following message: ===================== Hey all, Here's a post I made last year on how to rotate the polygons so that you're looking down the positive Z-axis. Do note that there are lots of ways to think about this, so ignore this if it's nothing like what you've got going. Anyway, here goes. Figuring out how to rotate, translate, and scale the scene is probably the hardest part of the assignment seeing as you're not given much guidance on it. It's much easier to think of this in 2D and then generalise it to 3D, so I'm going to use 2D examples here, where we're working in the XZ plane. When working in 3D you pretty much do this whole process over again except in the YZ plane. So the goal of this part of the renderer is to get us looking down the Z-axis. We want this because it makes working out hidden polygons and doing the edge-list and z-buffer algorithms much simpler. Let's say we have a situation like this: [img]http://i.imgur.com/X5hGxYI.png[/img] Interlude: what's wrong with the above picture? We aren't doing perspective rendering, so things appear the same size no matter how far away they are. So the 'rays' coming out of the eye (that represent what you can see) shouldn't widen outwards, instead we have something like: [img]http://i.imgur.com/TfQa426.png[/img] Great, so now how do we get ourselves looking down the Z-axis? Well we just rotate the eye however much it needs to be rotated, here I've called the angle T: [img]http://i.imgur.com/A3b38Pk.png[/img] But we wouldn't accomplish anything by just rotating the eye, we've got to take the polygons with it of course. But we've already figured out the angle to rotate by, T, and so we just rotate the polygon around the origin by that amount. The result: [img]http://i.imgur.com/Rxs0M1R.png[/img] Notes: [list][*] When I say rotate around the origin, I mean rotate around the Y-axis in 3D space. [*] In your program you'll want your user to be away from the origin, but looking at it. like this: 燵img]http://i.imgur.com/4DJjxrV.png[/img] 營n this case we first need to translate the eye and all polygons so that the eye is at the origin, and then do exactly as above. [*] Be careful not to confuse the two types of movement in your program. Part of the assignment (completion?) is to allow the user to move the eye around in order to get different views of scene. This is very different to what we're doing above, which is the first step of the actual rendering process.[/list] (in response to a question about what the 'eye' is and how to represent it) First keep in mind that all the image files you've got are (more or less) centred around the origin. So what is the 'eye', how do you represent it, and how do you work with it? The key is that, because the scenes are at the origin, we can get away with a 'pretty good' direction of view by just looking at the origin. So let's decide that the eye will always be pointed towards the origin, much like in the last picture above. But where is it pointing at the origin from? The trick is to think of it backwards, not as the eye pointing at the origin, but as something at the origin pointing at the eye. If we're in 2D space, we can describe this as a single angle! In the last picture, if the +ve Z-axis is 0 degrees than the angle the eye is at is about 45 degrees. What about in 3D space? Well much like doing the polygon rotation, you just do this process twice. You can point at any point in 3D space using two angles; you can point anywhere in your room by defining how far to swivel around in your office chair, and how far up or down to tilt your arm. So we use two angles to fully describe everything we need to know about the eye, one in the XZ-plane (like T above), and one in the YZ-plane. You'll notice that there isn't even a vector here, really, just two angles. Furthermore these angles are exactly the angles you'll want to use for rotating the scene (as long as you measure them with your +ve Z-axis as 0). You can also see this message by visiting the following link. http://ecs.victoria.ac.nz/cgi-bin/yabb/YaBB.pl?num=1429927664 Regards, The ECS Forums team

Polygon Transformations Translation Scaling Rotation Do them by linear algebra

Linear Algebra Basics n-dimensional Vector: 𝑥 1 ⋮ 𝑥 𝑛 m-row-n-column Matrix 𝑎 11 ⋯ 𝑎 1𝑛 ⋮ ⋱ ⋮ 𝑎 𝑚1 ⋯ 𝑎 𝑚𝑛 n-dim vector can be seen as n-row-1-column matrix Matrix Addition (same rows and columns) Add corresponding element 𝑎 11 ⋯ 𝑎 1𝑛 ⋮ ⋱ ⋮ 𝑎 𝑚1 ⋯ 𝑎 𝑚𝑛 + 𝑏 11 ⋯ 𝑏 1𝑛 ⋮ ⋱ ⋮ 𝑏 𝑚1 ⋯ 𝑏 𝑚𝑛 = 𝑎 11 + 𝑏 11 ⋯ 𝑎 1𝑛 + 𝑏 1𝑛 ⋮ ⋱ ⋮ 𝑎 𝑚1 + 𝑏 𝑚1 ⋯ 𝑎 𝑚𝑛 + 𝑏 𝑚𝑛

Linear Algebra Basics Matrix Multiplication Condition: #columns of matrix 1 = #rows of matrix 2 To calculate element (i, j), first get row i of matrix 1 and column j of matrix 2 Do the inner product of the two same-dim vectors 𝑎 1 𝑟𝑜𝑤 ⋅ 𝑏 1 𝑐𝑜𝑙 = 𝑎 11 𝑏 11 +…+ 𝑎 1𝑛 𝑏 𝑛1 (m-row-n-col) × (n-row-k-col) → (m-row-k-col) 𝑎 11 ⋯ 𝑎 1𝑛 ⋮ ⋱ ⋮ 𝑎 𝑚1 ⋯ 𝑎 𝑚𝑛 × 𝑏 11 ⋯ 𝑏 1𝑘 ⋮ ⋱ ⋮ 𝑏 𝑛1 ⋯ 𝑏 𝑛𝑘 = 𝑎 1 〈𝑟𝑜𝑤〉 ⋅ 𝑏 1 〈𝑐𝑜𝑙〉 ⋯ 𝑎 1 〈𝑟𝑜𝑤〉 ⋅ 𝑏 𝑘 〈𝑐𝑜𝑙〉 ⋮ ⋱ ⋮ 𝑎 𝑚 〈𝑟𝑜𝑤〉 ⋅ 𝑏 1 〈𝑐𝑜𝑙〉 ⋯ 𝑎 𝑚 〈𝑟𝑜𝑤〉 ⋅ 𝑏 𝑘 〈𝑐𝑜𝑙〉

Linear Transformations Translation 𝑥 𝑦 𝑧 + Δ𝑥 Δ𝑦 Δ𝑧 ⇒ 𝑥+Δ𝑥 𝑦+Δ𝑦 𝑧+Δ𝑧 Scaling 𝑠 𝑥 0 0 0 𝑠 𝑦 0 0 0 𝑠 𝑧 × 𝑥 𝑦 𝑧 ⇒ 𝑥⋅ 𝑠 𝑥 𝑦⋅ 𝑠 𝑦 𝑧⋅ 𝑠 𝑧 Rotation In the y-z plane, rotate 𝜃 angle anti-clockwise 1 0 0 0 cos 𝜃 − sin 𝜃 0 sin 𝜃 cos 𝜃 × 𝑥 𝑦 𝑧 ⇒ 1𝑥+0𝑦+0𝑧 0𝑥+ cos 𝜃⋅𝑦 − sin 𝜃 ⋅𝑧 0𝑥+ sin 𝜃⋅𝑦 + cos 𝜃 ⋅𝑧 z v’ v 𝜃 y

Linear Transformations Rotation In the x-z plane, keeping y fixed cos 𝜃 0 − sin 𝜃 0 1 0 sin 𝜃 0 cos 𝜃 × 𝑥 𝑦 𝑧 ⇒ cos 𝜃 ⋅𝑥− sin 𝜃 ⋅𝑧 𝑦 sin 𝜃 ⋅𝑥+ cos 𝜃 ⋅𝑧 In the x-y plane, keeping z fixed cos 𝜃 − sin 𝜃 0 sin 𝜃 cos 𝜃 0 0 0 1 × 𝑥 𝑦 𝑧 ⇒ cos 𝜃 ⋅𝑥− sin 𝜃 ⋅𝑦 sin 𝜃 ⋅𝑥+ cos 𝜃 ⋅𝑦 𝑧

Unified Transformation Operator Translation 𝑥 𝑦 𝑧 + Δ𝑥 Δ𝑦 Δ𝑧 ⇒ 𝑥+Δ𝑥 𝑦+Δ𝑦 𝑧+Δ𝑧 Scaling 𝑠 𝑥 0 0 0 𝑠 𝑦 0 0 0 𝑠 𝑧 × 𝑥 𝑦 𝑧 ⇒ 𝑥⋅ 𝑠 𝑥 𝑦⋅ 𝑠 𝑦 𝑧⋅ 𝑠 𝑧 Rotation (y-z plane) 1 0 0 0 cos 𝜃 − sin 𝜃 0 sin 𝜃 cos 𝜃 × 𝑥 𝑦 𝑧 ⇒ 𝑥 cos 𝜃⋅𝑦 − sin 𝜃 ⋅𝑧 sin 𝜃⋅𝑦 + cos 𝜃 ⋅𝑧 Can we have a unified transformation operator?

Unified Transformation Operator A unified [matrix * vector] transformation operator Convert 3D vectors to 4D vectors Use 1 for the value in the 4th dimension Translation Scaling Rotation 4x4 matrix Row 4: (0,0,0,1)

Unified Transformation Operator input: point (x, y, z, 1), 4x4 transform matrix T output: new point (x’, y’, z’, 1) initialise newpoint to (0,0,0,1) for row ← 0 to 3 for col ← 0 to 3 newpoint[row] += T[row, col] * point[col] Transform a polygon Apply transformation to each vertex