Introduction to 3D Graphics Lecture 5: From Realism to Real-Time Anthony Steed University College London.

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

Clipping Covers chapter 10 of Computer Graphics and Virtual Environments (Slater, Steed and Chrysanthou) . See ©Yiorgos Chrysanthou.
Advanced Light and Shadow Culling Methods Eric Lengyel.
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
10/10/02 (c) 2002 University of Wisconsin, CS 559 Last Time Finished viewing: Now you know how to: –Define a region of space that you wish to view – the.
3D Graphics Rendering and Terrain Modeling
03/12/02 (c) 2002 University of Wisconsin, CS559 Last Time Some Visibility (Hidden Surface Removal) algorithms –Painter’s Draw in some order Things drawn.
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
Mark Nelson Rendering algorithms Fall 2013
Part I: Basics of Computer Graphics
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
Implementation Dr. Amy Zhang. Reading 2  Hill, Chapters  Hill, Chapter 10.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Clipping & Scan Conversion
Computer Graphics 14: Surface Detection Methods
Vertices and Fragments III Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
1 Chapter 5 Viewing. 2 Perspective Projection 3 Parallel Projection.
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.
2/26/04© University of Wisconsin, CS559 Spring 2004 Last Time General Orthographic Viewing –Specifying cameras in world coordinates –Building world  view.
Computer Graphics Shadows
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
9/20/2001CS 638, Fall 2001 Today Finishing Up Reflections More Multi-Pass Algorithms Shadows.
Hidden Surface Removal
Introduction to 3D Graphics Lecture 3: General Camera Model Anthony Steed University College London.
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel  dramatic effects  spooky effects Without shadows the.
Introduction to 3D Graphics Lecture 4: Scenes and Scene Graphs Anthony Steed University College London.
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.
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.
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.
Advanced Computer Graphics Three Dimensional Viewing
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
MIT EECS 6.837, Durand and Cutler Graphics Pipeline: Projective Transformations.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
Clipping Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Luebke)
Visible-Surface Detection Jehee Lee Seoul National University.
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 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
CS 325 Introduction to Computer Graphics 03 / 22 / 2010 Instructor: Michael Eckmann.
CS559: Computer Graphics Lecture 9: Rasterization Li Zhang Spring 2008.
Implementation II.
1 Visiblity: Culling and Clipping Computer Graphics COMP 770 (236) Spring 2009 January 21 & 26: 2009.
Computer Graphics Zhen Jiang West Chester University.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
10/19/04© University of Wisconsin, CS559 Fall 2004 Last Time Clipping –Why we care –Sutherland-Hodgman –Cohen-Sutherland –Intuition for Liang-Barsky Homework.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
Computer Graphics I, Fall 2010 Implementation II.
1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
01/28/09Dinesh Manocha, COMP770 Visibility Computations Visible Surface Determination Visibility Culling.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
COMPUTER GRAPHICS CS 482 – FALL 2015 NOVEMBER 10, 2015 VISIBILITY CULLING HIDDEN SURFACES ANTIALIASING HALFTONING.
Visible Surface Detection
Rendering Pipeline Fall, 2015.
Computer Graphics Implementation II
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
CSC461: Lecture 20 Parallel Projections in OpenGL
3D Graphics Rendering PPT By Ricardo Veguilla.
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Implementation II Ed Angel Professor Emeritus of Computer Science
Lecture 13 Clipping & Scan Conversion
Introduction to Computer Graphics with WebGL
Implementation II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Introduction to 3D Graphics Lecture 5: From Realism to Real-Time Anthony Steed University College London

Overview n Projecting –As an optimisation of ray-casting –New issues and problems n Clipping Polygons –2D –3D n Visibility Culling

Reflection on Ray Casting n The process of casting rays is very slow –E.G. for a cow we have 10,000 triangles, but to render a 1000x1000 pixel image we have primary rays to cast (and then reflections, shadow rays, etc…) n Exploit point coherency –If ray through pixel (x,y) hits triangle T, then rays through adjacent pixels will likely hit the same triangle

Think Optimisation n But although point coherency is useful, we can easily enumerate ALL the rays that hit the triangle –Find which rays would hit the vertices of the triangle –These rays are defined by a 2D triangle on the image plane –Scan this 2D triangle out

COP

Why Triangles? n In general for an object representation (bezier, CSG) is it far from easy to find the 2D projection of the shape

Projection Problems (1) n Projecting the vertices –Needs to be done efficiently n Clipping to the view volume –Triangle might lie partially or totally off the screen n Visible surface determination –We now have to iterate through all the objects to see if they are visible.

Projection Problems (2) n Lighting –Now we have to re-construct the lighting across the screen n Depth test determination –Have to cope with overlapping and potential “difficult” coverage relations n Shadows and Inter-Reflections –Much more complicated

Full camera specification n We have already seen: –VRP, VPN, VUV, COP, view plane window n Some more parameters: –Viewplane Distance –Type of projection n Perspective – all rays converge to the COP n Parallel – parallel rays from points in the scene (DOP) n Front and back clip planes

Full Camera V N VRP=O COP VP truncated View Volume view window front clipping plane back clipping plane

Perspective Projection n In order to get a natural looking image we need the perspective n For a simple arrangement it is easy to find the projection COP C Q P A O viewplane Z Y

Canonical Frames n We use these as intermediate stages from which we know how to proceed n Canonical Perspective: –Cop at (0,0,-1) –Viewplane coincident with U-V plane –Viewplane window bounded by –1 to +1 –p’ = (x/z+1, y/z+1, 0) View volume

Canonical Parallel n Orthographic parallel projection n Direction of projection (DOP) is (0,0,-1) n View volume bounded by –1 and +1 on U and V n And by 0 and 1 on the N axis n p’ = (x, y, 0) V + DOP View volume

From General Perspective to Canonical Parallel (Projection Space) +

Perspective to Canonical Perspective n We will apply a set of transformation matrices (4 in total) n Each one ‘corrects’ a particular aspect of the projection n Then we put them all together to get one matrix

Step 1: Move the View Plane to the UV Plane (n = 0) cop View plane d cop V N View plane V N

Step 2: Translate the COP so that it Lies on the N axis View plane V N View plane V N cop

Step 3: Change the View Volume into a Regular Pyramid N View plane V N cop V D D Where D = d – c z dx = x 2 – x 1 dy = y 2 – y 1 px = x 2 + x 1 py = y 2 + y 1

Step 4: Scale by 1/D N V cop 1 1 N V D D

Multiplying Steps 1-4

Canonical Perspective To Canonical Parallel n Projection space –Divide through by Z n Incorporation of front and back clipping planes (canonical parallel) + Dmin Dmax + 0 1

Projection Space n A use for the right hand column! –x maps to x/z+1

Incorporate Front and Back Clipping Planes n (Actually this step occurs before the previous one)

The composite matrix T = MQ

Overview n Projecting –As an optimisation of ray-casting –New issues and problems n Clipping Polygons –2D –3D n Visibility Culling

Clipping Problem n Once we start projecting polygons we have to cope with cases where only some of the vertices project to the view window

Sutherland-Hodgman Algorithm(2D) n Clip the polygon against each boundary of the clip region successively n Result is possibly NUL if polygon is outside n Can be generalised to work for any polygonal clip region, not just rectangular Clip to top Clip to right etc

Clipping to a Region Boundary n To find the new polygon –iterate through each of the polygon edges and construct a new sequence of points –starting with an empty sequence –for each edge there are 4 possible cases to consider clip region right clip boundary P0P0 P1P1 P2P2 P3P3

Clipping the Polygon Edge n Given an edge P 0,P 1 we have 4 case. It can be: –entering the clip region, add P and P 1 –leaving the region, add only P –entirely outside, do nothing –entirely inside, add only P1 n Where P is the point of intersection Visible side of boundary p 0 p 1 p 0 p 0 p 0 p 1 p 1 p 1 p p OUT IN

Wrapping Up n We can determine which of the 4 cases and also the point of intersection with just if statements n To sum it up, an example: P0P0 P1P1 P2P2 P3P3 P0P0 PaPa PbPb P3P3

Weiler-Atherton Algorithm n When we have non-convex polygons then the algorithm above might produce polygons with coincident edges n This is fine for rendering but maybe not for other applications (eg shadows) n The Weiler-Atherton algorithm produces separate polygons for each visible fragment

Weiler-Atherton Algorithm a b c d ab c d A B ij k l clip region polygon loop of polygon vertices loop of region vertices

After Inserting the first Intersection Vertex i a b c d i l k j ab c d A B ij k l clip region polygon

After Insertion of all Intersection Vertices a b c d i l k j ab c d A B ij k l clip region polygon

Collect Your Polygons n Traverse the vertex list from the top n When the intersection point is an exit switch to traversing the clip boundary n When the intersection point is an entry switch to traversing the polygon vertices

Clipping polygons in 3D n The Sutherland-Hodgman can easily be extended to 3D –the clipping boundaries are 6 planes instead of 4 lines –intersection calculation is done by comparing an edge to a plane instead of edge to edge n It can either be done in Projection Space or in Canonical Perspective

Clipping in Projection Space n The view volume is defined by:

Clipping in Canonical Perspective n When we have an edge that extends from the front to behind the COP, then if we perform the clipping after the projection of the points (which in effect is what the PS does) we might get wrong results V N COP O p1 p2 q1 q2 top bottom View plane projected external lines

Clipping in Homogeneous Co-Ordinates n The Sutherland-Hodgman can also be used for clipping in 4D before dividing the points by the w n This can have the advantage that is even more general, it even allows for the front clip plane to be behind the COP

Overview n Projecting –As an optimisation of ray-casting –New issues and problems n Clipping Polygons –2D –3D n Visibility Culling

Visibility Problem n Not all objects are visible –In ray-tracing only rays inside the view frustum could be created n Not all polygons are visible –Visibility “solved” by default by ray-tracing because of object intersection test n Visibility ordering is a problem –Ray-tracing “solved” this problem implicitly because closest ray intersection point was chosen

Object Culling n Any object outside the view frustum can be discarded –Bounding sphere/plane test is common n Remaining objects must be sent to clipping process

Back Face Culling n Polygons facing away from the COP can be discarded –Often over-ridden to model thin walled objects COP

List Priority Algorithms n Must sort the objects (or polygons or pixels) n Commonest approach is to sort the objects on their distance from the COP (z-sort)

Order of Polygons n For a single closed polyhedron ANY order of polygon drawing is correct n With multiple overlapping objects z-sort the individual polygons –Special cases galore! n In general these techniques are not sufficient, and we will buffer individual pixels with a z-buffer

Conclusion n We have moved a considerable way from realism to real-time –Reduced a 3D problems to a 2D problem (via a 4D problem!) n Remaining issues –Filling polygons to cope with local illumination and visibility