Intro to 3D Graphics.

Slides:



Advertisements
Similar presentations
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Advertisements

3D Graphics Rendering and Terrain Modeling
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
Mark Nelson Rendering algorithms Fall 2013
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.
CGDD 4003 THE MASSIVE FIELD OF COMPUTER GRAPHICS.
1 Chapter 5 Viewing. 2 Perspective Projection 3 Parallel Projection.
Part I: Basics of Computer Graphics Rendering Polygonal Objects (Read Chapter 1 of Advanced Animation and Rendering Techniques) Chapter
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A.
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) CS 426 Intro to 3D Computer Graphics © 2003, 2004, 2005 Jason Leigh Electronic.
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.
CSE 381 – Advanced Game Programming Basic 3D Graphics
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.
Buffers Textures and more Rendering Paul Taylor & Barry La Trobe University 2009.
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
MIT EECS 6.837, Durand and Cutler Graphics Pipeline: Projective Transformations.
Week 2 - Friday.  What did we talk about last time?  Graphics rendering pipeline  Geometry Stage.
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
Programming 3D Applications CE Displaying Computer Graphics Week 3 Lecture 5 Bob Hobbs Faculty of Computing, Engineering and Technology Staffordshire.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
CS559: Computer Graphics Lecture 9: Rasterization Li Zhang Spring 2008.
CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE.
Mark Nelson 3d projections Fall 2013
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.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
Honours Graphics 2008 Session 2. Today’s focus Vectors, matrices and associated math Transformations and concatenation 3D space.
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
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.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
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.
Introduction to Computer Graphics
Visible Surface Detection
Rendering Pipeline Fall, 2015.
- Introduction - Graphics Pipeline
Computer Graphics Implementation II
Week 2 - Friday CS361.
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
Graphics Fundamentals
CSCE 441 Computer Graphics 3-D Viewing
CSC461: Lecture 20 Parallel Projections in OpenGL
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
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
CSCE 441: Computer Graphics Hidden Surface Removal
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Three Dimensional Viewing
Computer Graphics Lecture 20
Implementation II Ed Angel Professor Emeritus of Computer Science
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.
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
Chapter V Vertex Processing
Lecture 13 Clipping & Scan Conversion
Last Time Canonical view pipeline Projection Local Coordinate Space
Visibility (hidden surface removal)
Viewing (Projections)
Introduction to Computer Graphics with WebGL
Game Programming Algorithms and Techniques
Implementation II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Intro to 3D Graphics

Revisiting the Display Pipeline Object space World space Camera space Image space Screen space

Homogeneous Coordinates 3D Vectors use a 4th, homogeneous coordinate Usually 1, if not, divide through (4,3,2,1) = (8,6,4,2) All transformations kept in the form of 4x4 matrices. This keeps the matrices invertible, and all transforms are matrix multiplications.

Building Polygon Matrices New problem in 3D: Which side of the polygon is the front? Relative order of vertices in matrix matters Vertices should appear in counter-clockwise order for right handed systems and clockwise order for left handed systems Now normal vector will denote the “front”

Analogous Transformation Matrices The do-everything transform matrix: a b c p Top 9- rotations d e f q p,q,r – perspective g I j r h,k,l - translation h k l s s – overall scaling

Scaling a 0 0 0 0 e 0 0 0 0 j 0 0 0 0 1 a in x-dir e in y-dir 0 0 0 1 a in x-dir e in y-dir j in z-dir Negative values reflect

Translation 1 0 0 0 0 1 0 0 0 0 1 0 h k l 1 shift h in x-dir 1 0 0 0 0 1 0 0 0 0 1 0 h k l 1 shift h in x-dir k in y-dir l in z-dir

Rotations 1 0 0 0 0 cosӨ sinӨ 0 0 -sinӨ cosӨ 0 0 0 0 1 cosӨ sinӨ 0 0 1 0 0 0 0 cosӨ sinӨ 0 0 -sinӨ cosӨ 0 0 0 0 1 cosӨ sinӨ 0 0 -sinӨ cosӨ 0 0 0 0 1 0 0 0 0 1 About x About z

Rotations cosӨ 0 -sinӨ 0 0 1 0 0 sin Ө 0 cos Ө 0 0 0 0 1 About y-axis 0 1 0 0 sin Ө 0 cos Ө 0 0 0 0 1 About y-axis Note changes in sines! Necessary for preserving handed-ness

Overall Scaling Scale factor is last coordinate in last row s < 1 expands, s >1 contracts Must “divide through” by s to get last coordinate 1.

Camera/Observer/Eye Camera position (3D point) Need perspective of viewer View direction Up vector View direction: COI: Center of interest View direction is COI – Eye position

Field of View Camera position View Direction & Orientation Near clipping distance Far clipping distance Define: View Frustum: 6-sided volume of world space displayable (truncated pyramid)

View Frustum

Remember Your Trig SOH CAH TOA Sin = Opposite / Hypotenuse Cos = Adjacent / Hypotenuse Tan = Opposite / Adjacent Hyp Opp Ө Adj

Image Transformation Right-handed system Our camera at (-10,0,0) looking down z-axis. Need to calculate view frustum and project it onto the view window Change (x,y,z) camera coordinates to (x’,y’) image coordinates

Calculating view distance Pick an angle for viewing (90 degrees) d = (w/2) / tan(Ө/2) w/2 tangent of 45 degrees = 1 d = w/2, or camera size in unity! d Ө

Calculating x’ Use similar triangle ratios: d is to x’ as t is to x: x’ = dx/t y’ = dy/t t x d x’

Calculating x’ Use similar triangle ratios: d is to x’ as z is to x: x’ = dx/z y’ = dy/z z x d x’ Can approximate by dividing everything by z value.

Perspective Transforms are not Affine! Vanishing points

Types of Rendering Rendering = Drawing & filling in polygons Ray Tracing: Models rays of light Reverse: Eyes to World Expensive Movies (Ice Age) Polygon Modeling All Shapes are modeled as polygons Rounded shapes require more polygons

Polygon Rendering Triangles (sometimes deal with strips) Vertices – often exist on multiple triangles Each triangle needs a normal Unit vector Points “out” perpendicular to triangle

Solid Shapes Is it just adding more polygons? Must be careful the order in which the polygons are drawn – or the back will cover the front Most efficient: don’t draw polygons that aren’t visible, then… Order the visible polygons correctly.

Back-face Culling Reduce the number of polygons drawn by about half Need the normal to the polygon Normal: vector perpendicular to the polygon, facing the same direction as the polygon Polygon is “facing the camera” if the angle between the camera and the normal is less than 90 degrees

Computing Normals Cross Product U x V = (UyVz – UzVy, UzVx – UxVz, UxVy – UyVx) The vector perpendicular to U and V

Calculating normals Right-handed: define “front” as counter-clockwise ordering of vertices. U = v2-v1 V = v0-v1 Normal = UxV 1 2

Angle between two vectors Dot product: U·V = UxVx + UyVy + UzVz U·V =|U||V|cosӨ All we care about is whether or not Ө<90: if U·V<0, then Ө > 90 if U·V=0, Ө = 90 if U·V>0, Ө < 90

Does it face camera? U = camera - v0 V = Normal Polygon faces camera if U·V >= 0 1 2

Tackling Roundoff More accurate polygon drawing: Scan Converter Draw horizontal lines to draw a polygon Problem: don’t want polygons to overlap, so round down on the right side of the polygon

Horizontal Scanner Scan object: tells me the left and right x values to draw for all y values in range for the polygon. For each edge Find the highest and lowest y values For each intermediate y, Find the x point of the intersection Keep up with the leftmost and rightmost x for this y value over all edges At the end, you have the leftmost and rightmost x values for each y – then draw horizontal lines

Finding that intersection You have 2 vertices (x1,y1) and (x2,y2) The equation of the edge is: y-y1 = m(x-x1) (y-y1)/m+x1 = x So, x = x1 + (y-y1)/m where m is (y2-y1)/(x2-x1)

Finally,… For each y, draw a line from left to right Gives you the filled in polygon with little round-off error

3D Clipping What about polygons partially in the frustum? First, clip to a plane: Polygon is behind plane, ignore it. Problem: Compute the line segment where the polygon intersects the clipping plane. This becomes a new edge and only vertices in front of the pane are kept.

Hidden-surface Removal So far: Back-face culling Clipping Doesn’t work for overlapping polygons

More Hidden-Surface Removal How do you know which objects are in front of others? Simple ordering Inefficient Doesn’t always work Use Z-Buffer Collection of depth values with pixel color

Hidden surface removal Painter’s Algorithm: Draw things back to front Reverse Painter’s Algorithm: Draw things front to back, but don’t draw over a pixel already drawn Problem: Which point on polygon determines its depth?

Z-Buffering Or depth-buffering Store depth of each pixel Start with all pixels = inf. Only overwrite if depth is less than current

Z-Buffering

Final Pipeline To Draw a polygon: Check to see if it’s facing the camera Apply transforms Project onto the view window Scan-convert it Draw the horizontal lines Use Z-Buffering to determine final pixel-by-pixel coloring

Polygon Rendering Texture: Picture to paste on the triangles Shader: Program that determines coloring of triangles Material: Rendering description including shaders, textures, and lots more Mesh: Collection of triangles, vertices, and material to render it with Render Object: Set of meshes defining an object, sometimes uses a skeleton

Types of Shaders Wireframe – Edges only Flat – Triangle is single color Gouraud – Interpolate color between vertices Phong – takes more lighting models into account (interpolates normals between vertices) Texture Map – paste picture on triangle Environment mapping – cube map of environment is put on object to fake shininess