2 3D Viewing Process  3D viewing process MC Model Space Model Transformation Model Transformation WC World Space Viewing Transformation Viewing Transformation.

Slides:



Advertisements
Similar presentations
COMPUTER GRAPHICS SOFTWARE.
Advertisements

Virtual Realism TEXTURE MAPPING. The Quest for Visual Realism.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Graphics Pipeline.
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Interpolation Clipping.
CS 4731: Computer Graphics Lecture 18: Hidden Surface Removal Emmanuel Agu.
Computer Graphics Hardware Acceleration for Embedded Level Systems Brian Murray
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Object-Order vs. Screen-Order Rendering April 24, 2003.
IN4151 Introduction 3D graphics 1 Introduction 3D Computer Graphics part 1 Projective display Viewing pipeline Graphics hardware Image-based rendering.
Gopi -ICS186AW03 - Slide1 Graphics Pipeline: First Pass.
Rasterization May 14, Triangles Only We will discuss the rasterization of triangles only. Why? –Polygon can be decomposed into triangles. –A triangle.
Part I: Basics of Computer Graphics Rendering Polygonal Objects (Read Chapter 1 of Advanced Animation and Rendering Techniques) Chapter
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Hidden Surface Removal
Under the Hood: 3D Pipeline. Motherboard & Chipset PCI Express x16.
Polygon Shading. Assigning color to a shape to make graphical scenes look realistic, or artistic, or whatever effect we’re attempting to achieve But first.
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.
Under the Hood: 3D Pipeline. Motherboard & Chipset PCI Express x16.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
Triangle Scan Conversion. 2 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Rasterization Rasterization (scan conversion) –Determine which.
COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 1 Shading (Shading) & Smooth Shading Graphics.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
1Computer Graphics Implementation III Lecture 17 John Shearer Culture Lab – space 2
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
A Quadrilateral Rendering Primitive Kai Hormann · Marco Tarini A Quadrilateral Rendering Primitive Visual Computing Group · CNR · Pisa.
Shadow Mapping Chun-Fa Chang National Taiwan Normal University.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
CAP4730: Computational Structures in Computer Graphics
Windows, Viewports, and Clipping
CS418 Computer Graphics John C. Hart
Texture Mapping May 4, Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan
Texture Mapping CAP4730: Computational Structures in Computer Graphics.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
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)
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
CS559: Computer Graphics Lecture 27: Texture Mapping Li Zhang Spring 2008 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys, UVA and Rosalee.
Lecture 6 Rasterisation, Antialiasing, Texture Mapping,
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Graphic pipeline  Scan-conversion algorithm (high level)  Pixels.
Chapter III Rasterization
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
Background image by chromosphere.deviantart.com Fella in following slides by devart.deviantart.com DM2336 Programming hardware shaders Dioselin Gonzalez.
CS5500 Computer Graphics April 23, Today’s Topic Details of the front-end of the 3D pipeline: –How to construct the viewing matrix? –How to construct.
Unstructured Volume Rendering. Grid Types uniformrectilinearregularcurvilinear Structured Grids: regularirregularhybridcurved Unstructured Grids:
Lecture 13: Raster Graphics and Scan Conversion
Computer Graphics Lecture 17 Fasih ur Rehman. Last Class 3D Transforms Inverse Rotation.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
- Introduction - Graphics Pipeline
Texture Mapping cgvr.korea.ac.kr.
Gouraud Shading with Bilinear Interpolation
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Day 05 Shader Basics.
Introduction to Computer Graphics with WebGL
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
Lecture 13 Clipping & Scan Conversion
Chapter VII Rasterizer
Visibility (hidden surface removal)
Introduction to Meshes
Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실.
CS5500 Computer Graphics April 24, 2006.
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Introduction to Meshes
Presentation transcript:

2 3D Viewing Process  3D viewing process MC Model Space Model Transformation Model Transformation WC World Space Viewing Transformation Viewing Transformation VC View Space Viewport Transformation Viewport Transformation DC Display Space Normalization & Clipping Normalization & Clipping NC Normalize Space Projection Transformation Projection Transformation PC Projection Space

Simplified View The Data Flow: 3D Polygons (+Colors, Lights, Normals, Texture Coordinates…etc.)  2D Polygons  2D Pixels (I.e., Output Images) Transform (& Lighting) Rasterization

Attributes  Varying Transform (& Lighting) Rasterization vertex attributes: Color, Normal, Tex_coord, …etc. vertex attributes: Color, Normal, Tex_coord, …etc. vertex shader vertex shader fragment shader fragment shader varying variables: interpolated from vertices to internal pixels varying variables: interpolated from vertices to internal pixels

Key Questions Q1: What screen pixels are covered by the triangles? Q2: How to interpolate the attributes?

Rasterization

Triangles Only We will discuss the rasterization of triangles only. Why? –Polygon can be decomposed into triangles. –A triangle is always convex. –Results in algorithms that are more hardware friendly.

Being Hardware Friendly [Angel 5e] Section : –Intersect scan lines with polygon edges. –Sort the intersections, first by scan lines, then by order of x on each scan line. –It works for polygons in general, not just in triangles. –O(n log n) complexity  feasible in software implementation only (i.e., not hardware friendly)

Using Edge Equations Find the edge equations for P1-P2, P2-P3, P1-P3 For each pixel, test which sides of the edges it is at. Q: Do we need to test every pixel on the screen? P1 P2 P3 ege defined by Ax+By+c=0

Example P1 P2 P3 ege defined by Ax+By+C=0

Example Now we have P1-P3 defined by 2x+y-4=0 To test if a point (u,v) is inside the triangle, we calculate 2(u)+(v)-4. For example, (0,0) leads to 2(0)+(0)-4=-4 So the negative side is inside. Use P2 to decide which side is inside. Negate A,B,C if you prefer the positive side P1 P2 P3 Ax+By+C=0

Color and Z Now we know which pixels must be drawn. The next step is to find their colors and Z’s. Gouraud shading: linear interpolation of the vertex colors. Isn’t it straightforward? –Interpolate along the edges. (Y direction) –Then interpolate along the span. (X direction)

13 Attribute Derivation Color Interpolation (255, 0, 0) (0, 255, 0)(0, 0, 255) (255, 0, 0) (0, 0, 0) Red (0, 0, 0) (0, 255, 0) Green (0, 0, 255) (0, 0, 0) Blue

Interpolation in World Space vs Screen Space P1=(x1, y1, z1, c1); P2=(x2, y2, z2, c2); P3=(x3, y3, z3, c3) in world space If (x3, y3) = (1-t)(x1, y1) + t(x2, y2) then z3=(1-t)z1+t z2; c3=(1-t)c1+t c2 P1=(x1,y1,z1) P3=(x3,y3,z3) P2=(x2,y2,z2)

Interpolation in World Space vs Screen Space But, remember that we are interpolating on screen coordinates (x’, y’): P’2 P’1 P2 P1 P3 x’ y’

Let P’ 1 =(x’ 1, y’ 1 ); P’ 2 =(x’ 2, y’ 2 ) and P’ 3 =(x’ 3, y’ 3 )= (1-s)(x’ 1, y’ 1 ) + s(x’ 2, y’ 2 ) Does s=t? If not, should we compute z3 and c3 by s or t? Express s in t (or vice versa), we get something like: So, if we interpolate z on screen space, we get the z of some other point on the line This is OK for Z’s, but may be a problem for texture coordinates (topic of another lecture)

Interpolation OpenGL uses interpolation to find proper texels from specified texture coordinates

Perspectively Correct Interpolation The previous slide is not “perspectively correct” Consider the interpolation along the vertical (Y) direction. Should the checkers spaced equally? Use the s to t conversion shown earlier, then you get the perspectively correct interpolation.

Appendix

Derivation of s and t Two end points P 1 =(x 1, y 1, z 1 ) and P 2 =(x 2, y 2, z 2 ). Let P 3 =(1-t)P 1 +(t)P 2 After projection, P 1, P 2, P 3 are projected to (x’ 1, y’ 1 ), (x’ 2, y’ 2 ), (x’ 3, y’ 3 ) in screen coordinates. Let (x’ 3, y’ 3 )=(1-s)(x’ 1, y’ 1 ) + s(x’ 2, y’ 2 ).

(x’ 1, y’ 1 ), (x’ 2, y’ 2 ), (x’ 3, y’ 3 ) are obtained from P 1, P 2, P 3 by:

Since We have:

When P 3 is projected to the screen, we get (x’ 3, y’ 3 ) by dividing by w, so: But remember that (x’ 3, y’ 3 )=(1-s)(x’ 1, y’ 1 ) + s(x’ 2, y’ 2 ) Looking at x coordinate, we have

We may rewrite s in terms of t, w 1, w 2, x’ 1, and x’ 2. In fact, or conversely Surprisingly, x’ 1 and x’ 2 disappear.