Polygon Scan Conversion & Shading

Similar documents
INTRODUCTION TO RENDERING TECHNIQUES

Scan-Line Fill. Scan-Line Algorithm. Sort by scan line Fill each span vertex order generated by vertex list

Monash University Clayton s School of Information Technology CSE3313 Computer Graphics Sample Exam Questions 2007

Computer Applications in Textile Engineering. Computer Applications in Textile Engineering

Image Processing and Computer Graphics. Rendering Pipeline. Matthias Teschner. Computer Science Department University of Freiburg

The Essentials of CAGD

A Short Introduction to Computer Graphics

Introduction to Computer Graphics

Computer Graphics CS 543 Lecture 12 (Part 1) Curves. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

B2.53-R3: COMPUTER GRAPHICS. NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions.

Lecture Notes, CEng 477

COMP175: Computer Graphics. Lecture 1 Introduction and Display Technologies

Finite Elements for 2 D Problems

Last lecture... Computer Graphics:

We can display an object on a monitor screen in three different computer-model forms: Wireframe model Surface Model Solid model

prepared by Gabe Landes for T. Purdy 2009

VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur

G.H. Raisoni College of Engineering, Nagpur. Department of Information Technology

2.3 WINDOW-TO-VIEWPORT COORDINATE TRANSFORMATION

Cabri Geometry Application User Guide

Lezione 4: Grafica 3D*(II)

Introduction to 2D and 3D Computer Graphics Mastering 2D & 3D Computer Graphics Pipelines

Specular reflection. Dielectrics and Distribution in Ray Tracing. Snell s Law. Ray tracing dielectrics

COMP-557: Fundamentals of Computer Graphics McGill University, Fall 2010

Shader Model 3.0. Ashu Rege. NVIDIA Developer Technology Group

Constrained Tetrahedral Mesh Generation of Human Organs on Segmented Volume *

Algebra Geometry Glossary. 90 angle

Computer Graphics. Geometric Modeling. Page 1. Copyright Gotsman, Elber, Barequet, Karni, Sheffer Computer Science - Technion. An Example.

Efficient Storage, Compression and Transmission

COMPUTER GRAPHICS IMPORTANT QUESTION AND ANSWERS. Computer graphics

EECS 556 Image Processing W 09. Interpolation. Interpolation techniques B splines

Volume visualization I Elvins

Curves and Surfaces. Goals. How do we draw surfaces? How do we specify a surface? How do we approximate a surface?

Model Repair. Leif Kobbelt RWTH Aachen University )NPUT $ATA 2EMOVAL OF TOPOLOGICAL AND GEOMETRICAL ERRORS !NALYSIS OF SURFACE QUALITY

What does the number m in y = mx + b measure? To find out, suppose (x 1, y 1 ) and (x 2, y 2 ) are two points on the graph of y = mx + b.

Computational Geometry. Lecture 1: Introduction and Convex Hulls

Visualization and Feature Extraction, FLOW Spring School 2016 Prof. Dr. Tino Weinkauf. Flow Visualization. Image-Based Methods (integration-based)

also describes the method used to collect the data for the faces. These techniques could be used to animate other flexible surfaces.

Computer Graphics. Anders Hast

Triangulation by Ear Clipping

Computer Graphics. Introduction. Computer graphics. What is computer graphics? Yung-Yu Chuang

Reflection and Refraction

Line and Polygon Clipping. Foley & Van Dam, Chapter 3

Triangle Scan Conversion using 2D Homogeneous Coordinates

Largest Fixed-Aspect, Axis-Aligned Rectangle

Chapter 9. Systems of Linear Equations

Computer Graphics Lecture Notes

Introduction Week 1, Lecture 1

H.Calculating Normal Vectors

Mean Value Coordinates

3D Math Overview and 3D Graphics Foundations

SkillsUSA 2014 Contest Projects 3-D Visualization and Animation

Scan Conversion of Filled Primitives Rectangles Polygons. Many concepts are easy in continuous space - Difficult in discrete space

1. Application of Computer Graphics

Vector storage and access; algorithms in GIS. This is lecture 6

Workstation Applications for Windows. NVIDIA MAXtreme User s Guide

How To Make A Texture Map Work Better On A Computer Graphics Card (Or Mac)

Recent Advances and Future Trends in Graphics Hardware. Michael Doggett Architect November 23, 2005

CUBE-MAP DATA STRUCTURE FOR INTERACTIVE GLOBAL ILLUMINATION COMPUTATION IN DYNAMIC DIFFUSE ENVIRONMENTS

Kankakee Community College

Shortest Path Algorithms

Two Research Schools become ONE

Using Photorealistic RenderMan for High-Quality Direct Volume Rendering

Finite Element Formulation for Plates - Handout 3 -

CSE168 Computer Graphics II, Rendering. Spring 2006 Matthias Zwicker

Geometry Chapter Point (pt) 1.1 Coplanar (1.1) 1.1 Space (1.1) 1.2 Line Segment (seg) 1.2 Measure of a Segment

Vector Notation: AB represents the vector from point A to point B on a graph. The vector can be computed by B A.

3D Analysis and Surface Modeling

Visualization of 2D Domains

Three-Dimensional Data Recovery Using Image-Based Modeling

MA 323 Geometric Modelling Course Notes: Day 02 Model Construction Problem

This satellite photo was taken on October 29th, 2011 and locates the project neighborhood and site for the project.

NURBS Drawing Week 5, Lecture 10

MobiX3D: a player for displaying 3D content on mobile devices

CS 4204 Computer Graphics

Chapter 3.1 Angles. Geometry. Objectives: Define what an angle is. Define the parts of an angle.

Summed-Area Tables for Texture Mapping

CS 534: Computer Vision 3D Model-based recognition

COMPARISON OF TWO DIFFERENT SURFACES FOR 3D MODEL ABSTRACTION IN SUPPORT OF REMOTE SENSING SIMULATIONS BACKGROUND

3D shapes. Level A. 1. Which of the following is a 3-D shape? A) Cylinder B) Octagon C) Kite. 2. What is another name for 3-D shapes?

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. M.Sc. in Advanced Computer Science. Friday 18 th January 2008.

Arrangements And Duality

Intermediate Tutorials Modeling - Trees. 3d studio max. 3d studio max. Tree Modeling Matthew D'Onofrio Page 1 of 12

Course Overview. CSCI 480 Computer Graphics Lecture 1. Administrative Issues Modeling Animation Rendering OpenGL Programming [Angel Ch.

Build Panoramas on Android Phones

NURBS Drawing Week 5, Lecture 10

Abstract. These two vectors define a plane tangent to the surface at that point. Their cross product is Recent work in computer graphics has been

Anamorphic Projection Photographic Techniques for setting up 3D Chalk Paintings

Representing Geography

CASTING CURVED SHADOWS ON CURVED SURFACES. Lance Williams Computer Graphics Lab New York Institute of Technology Old Westbury, New York 11568

2. SPATIAL TRANSFORMATIONS

Max-Min Representation of Piecewise Linear Functions

Introduction to Computer Graphics. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Introduction to Computer Graphics. Reading: Angel ch.1 or Hill Ch1.

REAL-TIME IMAGE BASED LIGHTING FOR OUTDOOR AUGMENTED REALITY UNDER DYNAMICALLY CHANGING ILLUMINATION CONDITIONS

Interactive Computer Graphics

DICOM Correction Item

Geometric Modelling & Curves

Linear Programming. Solving LP Models Using MS Excel, 18

Transcription:

3D Rendering Pipeline (for direct illumination) Polygon Scan Conversion & Shading Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2004 3D Primitives 3D Modeling Coordinates Modeling Transformation Lighting 3D Camera Coordinates Projection Transformation Clipping 2D Screen Coordinates Viewport Transformation 2D Image Coordinates Scan Conversion Image 3D World Coordinates 3D World Coordinates Viewing Transformation 2D Screen Coordinates 2D Image Coordinates Scan Conversion & Shading Overview Scan conversion Figure out which pixels to fill Shading Determine a color for each filled pixel Scan Conversion Render an image of a geometric primitive by setting pixel colors void SetPixel(int x, int y, Color rgba) Example: Filling the inside of a triangle Scan Conversion Render an image of a geometric primitive by setting pixel colors void SetPixel(int x, int y, Color rgba) Example: Filling the inside of a triangle Triangle Scan Conversion Properties of a good algorithm Symmetric Straight edges Antialiased edges No cracks between adjacent primitives MUST BE FAST! P 4 1

Triangle Scan Conversion Properties of a good algorithm Symmetric Straight edges Antialiased edges No cracks between adjacent primitives MUST BE FAST! Simple Algorithm Color all pixels inside triangle void ScanTriangle(Triangle T, Color rgba){ for each pixel P at (x,y){ if (Inside(T, P)) SetPixel(x, y, rgba); P 4 Line defines two halfspaces Implicit equation for a line On line: ax + by + c = 0 On right: ax + by + c < 0 On left: ax + by + c > 0 Inside Triangle Test A point is inside a triangle if it is in the positive halfspace of all three boundary lines Triangle vertices are ordered counter-clockwise Point must be on the left side of every boundary line L L 1 P L 3 L 2 Inside Triangle Test Boolean Inside(Triangle T, Point P) { for each boundary line L of T { Scalar d = L.a*P.x + L.b*P.y + L.c; if (d < 0.0) return FALSE; return TRUE; Simple Algorithm What is bad about this algorithm? void ScanTriangle(Triangle T, Color rgba){ for each pixel P at (x,y){ if (Inside(T, P)) SetPixel(x, y, rgba); L 1 L 3 L 2 2

Triangle Sweep-Line Algorithm Take advantage of spatial coherence Compute which pixels are inside using horizontal spans Process horizontal spans in scan-line order Take advantage of edge linearity Use edge slopes to update coordinates incrementally dx dy Triangle Sweep-Line Algorithm void ScanTriangle(Triangle T, Color rgba){ for each edge pair { initialize x L, x R ; compute dx L /dy L and dx R /dy R ; for each scanline at y for (int x = x L ; x <= x R ; x++) SetPixel(x, y, rgba); x L += dx L /dy L ; x R += dx R /dy R ; dx L dy L Bresenham s algorithm works the same way, but uses only integer operations! x L x R dx R dy R Polygon Scan Conversion Fill pixels inside a polygon Triangle Quadrilateral Convex Star-shaped Concave Self-intersecting Holes What problems do we encounter with arbitrary polygons? Polygon Scan Conversion Need better test for points inside polygon Triangle method works only for convex polygons L 1 L 5 L 2 L 3 Convex Polygon L 4 L 1 L 5 L 2 L 3A L 4 L 3B Concave Polygon Inside Polygon Rule What is a good rule for which pixels are inside? Inside Polygon Rule Odd-parity rule Any ray from P to infinity crosses odd number of edges Concave Self-Intersecting With Holes Concave Self-Intersecting With Holes 3

Polygon Sweep-Line Algorithm Incremental algorithm to find spans, and determine insideness with odd parity rule Takes advantage of scanline coherence Polygon Sweep-Line Algorithm void ScanPolygon(Triangle T, Color rgba){ sort edges by maxy make empty active edge list for each scanline (top-to-bottom) { insert/remove edges from active edge list update x coordinate of every active edge sort active edges by x coordinate for each pair of active edges (left-to-right) SetPixels(x i, x i+1, y, rgba); x L x R Triangle Polygon Hardware Scan Conversion Convert everything into triangles Scan convert the triangles Hardware Antialiasing Supersample pixels Multiple samples per pixel Average subpixel intensities (box filter) Trades intensity resolution for spatial resolution Overview Scan conversion Figure out which pixels to fill Shading Determine a color for each filled pixel Shading How do we choose a color for each filled pixel? Each illumination calculation for a ray from the eyepoint through the view plane provides a radiance sample» How do we choose where to place samples?» How do we filter samples to reconstruct image? Emphasis on methods that can be implemented in hardware Angel Figure 6.34 4

Ray Casting Simplest shading approach is to perform independent lighting calculation for every pixel When is this unnecessary? Polygon Shading Can take advantage of spatial coherence Illumination calculations for pixels covered by same primitive are related to each other I = I E + K I A AL n +! ( K D ( N Li + K S ( V Ri ) i I = I E + K I A AL n +! ( K D ( N Li + K S ( V Ri ) i Flat Shading Phong Shading Flat Shading Phong Shading Flat Shading What if a faceted object is illuminated only by directional light sources and is either diffuse or viewed from infinitely far away Flat Shading One illumination calculation per polygon Assign all pixels inside each polygon the same color N I = I E + K I A AL n +! ( K D ( N Li + K S ( V Ri ) i 5

Flat Shading Objects look like they are composed of polygons Flat Shading OK for polyhedral objects Not so good for smooth surfaces Phong Shading What if smooth surface is represented by polygonal mesh with a normal at each vertex? Method 1: One lighting calculation per vertex Assign pixels inside polygon by interpolating colors computed at vertices Watt Plate 7 I = I E + K A I AL +!i ( K D ( N Li ) I i + K S (V Ri ) n I i ) Bilinearly interpolate colors at vertices down and across scan lines Smooth shading over adjacent polygons Curved surfaces Illumination highlights Soft shadows Mesh with shared normals at vertices Watt Plate 7 6

Produces smoothly shaded polygonal mesh Piecewise linear approximation Need fine mesh to capture subtle lighting effects Flat Shading Phong Shading Flat Shading Phong Shading What if polygonal mesh is too coarse to capture illumination effects in polygon interiors? Phong Shading Method 2: One lighting calculation per pixel Approximate surface normals for points inside polygons by bilinear interpolation of normals from vertices I = I E + K I A AL n +! ( K D ( N Li + K S ( V Ri ) i Phong Shading Bilinearly interpolate surface normals at vertices down and across scan lines Wireframe Flat Gouraud Phong Watt Plate 7 7

Shading Issues Problems with interpolated shading: Polygonal silhouettes Perspective distortion Orientation dependence (due to bilinear interpolation) Problems computing shared vertex normals Problems at T-vertices Summary 2D polygon scan conversion Paint pixels inside primitive Sweep-line algorithm for polygons Flat Gouraud Phong Ray casting Key ideas: Sampling and reconstruction Spatial coherence Less expensive More accurate 8