Scan Conversion & Shading

Similar documents
Scan Conversion & Shading

Computer Graphics. Jeng-Sheng Yeh 葉正聖 Ming Chuan University (modified from Bing-Yu Chen s slides)

Color in OpenGL Polygonal Shading Light Source in OpenGL Material Properties Normal Vectors Phong model

Some Tutorial about the Project. Computer Graphics

3D Polygon Rendering Pipeline

Barycentric Coordinates. From: Mean Value Coordinates for Closed Triangular Meshes by Ju et al.

Interactive Rendering of Translucent Objects

3D Rasterization II COS 426

2D Raster Graphics. Integer grid Sequential (left-right, top-down) scan. Computer Graphics

Surface Mapping One. CS7GV3 Real-time Rendering

Reading. 14. Subdivision curves. Recommended:

Real-time. Shading of Folded Surfaces

Global Illumination: Radiosity

Improvement of Spatial Resolution Using BlockMatching Based Motion Estimation and Frame. Integration

Discussion. History and Outline. Smoothness of Indirect Lighting. Irradiance Caching. Irradiance Calculation. Advanced Computer Graphics (Fall 2009)

Discussion. History and Outline. Smoothness of Indirect Lighting. Irradiance Calculation. Irradiance Caching. Advanced Computer Graphics (Fall 2009)

Interpolation of the Irregular Curve Network of Ship Hull Form Using Subdivision Surfaces

Computer Animation and Visualisation. Lecture 4. Rigging / Skinning

Global Illumination and Radiosity

Monte Carlo 1: Integration

Fast, Arbitrary BRDF Shading for Low-Frequency Lighting Using Spherical Harmonics

Global Illumination and Radiosity

Monte Carlo 1: Integration

A Range Image Refinement Technique for Multi-view 3D Model Reconstruction

An efficient method to build panoramic image mosaics

Image Alignment CSC 767

Shape Representation Robust to the Sketching Order Using Distance Map and Direction Histogram

Global Illumination and Radiosity

Plane Sampling for Light Paths from the Environment Map

What are the camera parameters? Where are the light sources? What is the mapping from radiance to pixel color? Want to solve for 3D geometry

X-Ray Rendering. Other Rendering Techniques: Points, Splats, Shear-Warp. X-Ray Point Splatting. X-Ray Rendering. CSE 564: Visualization

R s s f. m y s. SPH3UW Unit 7.3 Spherical Concave Mirrors Page 1 of 12. Notes

Lighting. Dr. Scott Schaefer

Any Pair of 2D Curves Is Consistent with a 3D Symmetric Interpretation

Implementation of a Dynamic Image-Based Rendering System

PROJECTIVE RECONSTRUCTION OF BUILDING SHAPE FROM SILHOUETTE IMAGES ACQUIRED FROM UNCALIBRATED CAMERAS

Range images. Range image registration. Examples of sampling patterns. Range images and range surfaces

DESIGN OF VERTICAL ALIGNMET

Short Papers. Toward Accurate Recovery of Shape from Shading Under Diffuse Lighting 1 INTRODUCTION 2 PROBLEM FORMULATION

Model Clipping Triangle Strips and Quad Meshes.

Structure from Motion

Computer Graphics. - Spline and Subdivision Surfaces - Hendrik Lensch. Computer Graphics WS07/08 Spline & Subdivision Surfaces

Harmonic Coordinates for Character Articulation PIXAR

An Approach in Coloring Semi-Regular Tilings on the Hyperbolic Plane

Model-Based Bundle Adjustment to Face Modeling

Computer Graphics 7 - Rasterisation

Slide 1 SPH3UW: OPTICS I. Slide 2. Slide 3. Introduction to Mirrors. Light incident on an object

Real-Time Volumetric Shadows using 1D Min-Max Mipmaps

MATHEMATICS FORM ONE SCHEME OF WORK 2004

Monte Carlo Integration

A Fast, Practical Algorithm for the Trapezoidation of Simple Polygons submitted to CISST 05 by:

Smooth Approximation to Surface Meshes of Arbitrary Topology with Locally Blended Radial Basis Functions

Motivation. TensorTextures: Multilinear Image-Based Rendering. Image-Based Rendering. Our Contribution. BTF Texture Mapping [Dana et al.

GPU-based Parallel Construction of Compact Visual Hull Meshes

Outline. Discriminative classifiers for image recognition. Where in the World? A nearest neighbor recognition example 4/14/2011. CS 376 Lecture 22 1

REFRACTION. a. To study the refraction of light from plane surfaces. b. To determine the index of refraction for Acrylic and Water.

3D vector computer graphics

An Accurate Evaluation of Integrals in Convex and Non convex Polygonal Domain by Twelve Node Quadrilateral Finite Element Method

Consistent Illumination within Optical See-Through Augmented Environments

Pipeline Operations. CS 4620 Lecture 10

Chapter 4. Non-Uniform Offsetting and Hollowing by Using Biarcs Fitting for Rapid Prototyping Processes

Monte Carlo Rendering

Complex Filtering and Integration via Sampling

Repetition of TDA361. Misc. GEOMETRY Summary. Lecture 2: Transforms. Homogeneous notation. Ulf Assarsson

Computer Graphics 1. Chapter 7 (June 17th, 2010, 2-4pm): Shading and rendering. LMU München Medieninformatik Andreas Butz Computergraphik 1 SS2010

Image warping and stitching May 5 th, 2015

Mesh Composition on Models with Arbitrary Boundary Topology

Finding Intrinsic and Extrinsic Viewing Parameters from a Single Realist Painting

APPLICATION OF AN AUGMENTED REALITY SYSTEM FOR DISASTER RELIEF

UNIT 2 : INEQUALITIES AND CONVEX SETS

Calibrating a single camera. Odilon Redon, Cyclops, 1914

3D Face Reconstruction With Local Feature Refinement

3D Face Reconstruction With Local Feature Refinement. Abstract

New dynamic zoom calibration technique for a stereo-vision based multi-view 3D modeling system

Object Recognition Based on Photometric Alignment Using Random Sample Consensus

Recognizing Faces. Outline

TEST-05 TOPIC: OPTICS COMPLETE


Parallel Computation of the Functions Constructed with

A Binarization Algorithm specialized on Document Images and Photos

RESOLUTION ENHANCEMENT OF SATELLITE IMAGES USING DUAL-TREE COMPLEX WAVELET AND CURVELET TRANSFORM

Radial Basis Functions

BITPLANE AG IMARISCOLOC. Operating Instructions. Manual Version 1.0 January the image revolution starts here.

GSLM Operations Research II Fall 13/14

Robust Soft Shadow Mapping with Depth Peeling

CS 231A Computer Vision Midterm

Shading. Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller/Fuhrmann

Efficient Reconstruction of Indoor Scenes with Color

Face Recognition University at Buffalo CSE666 Lecture Slides Resources:

Fitting a Morphable Model to 3D Scans of Faces

Differential wavefront curvature sensor

3D Virtual Eyeglass Frames Modeling from Multiple Camera Image Data Based on the GFFD Deformation Method

Indirect Volume Rendering

Point-Based Computer Graphics

News. Recap: While Loop Example. Reading. Recap: Do Loop Example. Recap: For Loop Example

TN348: Openlab Module - Colocalization

Robust Face Alignment for Illumination and Pose Invariant Face Recognition

Injective Shape Deformations Using Cube-Like Cages

Ecient Computation of the Most Probable Motion from Fuzzy. Moshe Ben-Ezra Shmuel Peleg Michael Werman. The Hebrew University of Jerusalem

Snakes-based approach for extraction of building roof contours from digital aerial images

Transcription:

Scan Converson & Shadng Thomas Funkhouser Prnceton Unversty C0S 426, Fall 1999 3D Renderng Ppelne (for drect llumnaton) 3D Prmtves 3D Modelng Coordnates Modelng Transformaton 3D World Coordnates Lghtng 3D World Coordnates Vewng Transformaton 3D Camera Coordnates Projecton Transformaton 2D Screen Coordnates Clppng 2D Screen Coordnates Vewport Transformaton 2D Image Coordnates Scan Converson 2D Image Coordnates Image P 2 P 1 Scan Converson & Shadng P 3 1

Overvew Scan converson Fgure out whch pxels to fll Shadng Determne a color for each flled pxel Scan Converson Render an mage of a geometrc prmtve by settng pxel colors vod SetPxel(nt x, nt y, Color rgba) Example: Fllng the nsde of a trangle P 1 P 2 P 3 2

Scan Converson Render an mage of a geometrc prmtve by settng pxel colors vod SetPxel(nt x, nt y, Color rgba) Example: Fllng the nsde of a trangle P 1 P 2 P 3 Trangle Scan Converson Propertes of a good algorthm Symmetrc Straght edges Antalased edges No cracks between adjacent prmtves MUST BE FAST! P 1 P 2 P 3 P 4 3

Trangle Scan Converson Propertes of a good algorthm Symmetrc Straght edges Antalased edges No cracks between adjacent prmtves MUST BE FAST! P 1 P 2 P 3 P 4 Smple Algorthm Color all pxels nsde trangle vod ScanTrangle(Trangle T, Color rgba){ for each pxel P at (x,y){ f (Insde(T, P)) SetPxel(x, y, rgba); } } P 1 P 2 P 3 4

Insde Trangle Test A pont s nsde a trangle f t s n the postve halfspace of all three boundary lnes Trangle vertces are ordered counter-clockwse Pont must be on the left sde of every boundary lne L 1 P L 3 L 2 Insde Trangle Test Boolean Insde(Trangle T, Pont P) { for each boundary lne L of T { Scalar d = L.a*P.x + L.b*P.y + L.c; f (d < 0.0) return FALSE; } return TRUE; } L 1 L 3 L 2 5

Smple Algorthm What s bad about ths algorthm? vod ScanTrangle(Trangle T, Color rgba){ for each pxel P at (x,y){ f (Insde(T, P)) SetPxel(x, y, rgba); } } P 1 P 2 P 3 Trangle Sweep-Lne Algorthm Take advantage of spatal coherence Compute whch pxels are nsde usng horzontal spans Process horzontal spans n scan-lne order Take advantage of edge lnearty Use edge slopes to update coordnates ncrementally dy dx 6

Trangle Sweep-Lne Algorthm vod ScanTrangle(Trangle T, Color rgba){ for each edge par { ntalze x L, x R ; compute dx L /dy L and dx R /dy R ; for each scanlne at y for (nt x = x L ; x <= x R ; x++) SetPxel(x, y, rgba); x L += dx L /dy L ; x R += dx R /dy R ; } } dx L dy L dx R dy R x L x R Polygon Scan Converson Fll pxels nsde a polygon Trangle Quadrlateral Convex Star-shaped Concave Self-ntersectng Holes What problems do we encounter wth arbtrary polygons? 7

Polygon Scan Converson Need better test for ponts nsde polygon Trangle method works only for convex polygons L 5 L 4 L 5 L 4 L 1 L 1 L 3B L 2 L 3 L 2 L 3A Convex Polygon Concave Polygon Insde Polygon Rule What s a good rule for whch pxels are nsde? Concave Self-Intersectng Wth Holes 8

Insde Polygon Rule Odd-party rule Any ray from P to nfnty crosses odd number of edges Concave Self-Intersectng Wth Holes Polygon Sweep-Lne Algorthm Incremental algorthm to fnd spans, and determne nsdeness wth odd party rule Takes advantage of scanlne coherence x L x R Trangle Polygon 9

Polygon Sweep-Lne Algorthm vod ScanPolygon(Trangle T, Color rgba){ sort edges by maxy make empty actve edge lst for each scanlne (top-to-bottom) { nsert/remove edges from actve edge lst update x coordnate of every actve edge sort actve edges by x coordnate for each par of actve edges (left-to-rght) SetPxels(x, x +1, y, rgba); } } Hardware Scan Converson Convert everythng nto trangles Scan convert the trangles 10

Hardware Antalasng Supersample pxels Multple samples per pxel Average subpxel ntenstes (box flter) Trades ntensty resoluton for spatal resoluton P 1 P 2 P 3 Overvew Scan converson Fgure out whch pxels to fll Shadng Determne a color for each flled pxel 11

! " Shadng How do we choose a color for each flled pxel? Each llumnaton calculaton for a ray from the eyepont through the vew plane provdes a radance sample» How do we choose where to place samples?» How do we flter samples to reconstruct mage? Emphass on methods that can be mplemented n hardware Angel Fgure 6.34 Ray Castng Smplest shadng approach s to perform ndependent lghtng calculaton for every pxel When s ths unnecessary? I = I E + K A I AL + ( K D ( N L ) I + K S ( V R ) n I ) 12

# Polygon Shadng Can take advantage of spatal coherence Illumnaton calculatons for pxels covered by same prmtve are related to each other I = I E + K A I AL + ( K D ( N L ) I + K S ( V R ) n I ) Polygon Shadng Algorthms Flat Shadng Gouraud Shadng Phong Shadng 13

Polygon Shadng Algorthms Flat Shadng Gouraud Shadng Phong Shadng Flat Shadng What f a faceted object s llumnated only by drectonal lght sources and s ether dffuse or vewed from nfntely far away I = I E + K A I AL + ( K D ( N L ) I + K S ( V R ) n I ) 14

$ % & Flat Shadng One llumnaton calculaton per polygon Assgn all pxels nsde each polygon the same color N Flat Shadng Objects look lke they are composed of polygons OK for polyhedral objects Not so good for ones wth smooth surfaces 15

Polygon Shadng Algorthms Flat Shadng Gouraud Shadng Phong Shadng Gouraud Shadng What f smooth surface s represented by polygonal mesh wth a normal at each vertex? Watt Plate 7 I = I E + K A I AL + ( K D ( N L ) I + K S (V R ) n I ) 16

' Gouraud Shadng Method 1: One lghtng calculaton per vertex Assgn pxels nsde polygon by nterpolatng colors computed at vertces Gouraud Shadng Blnearly nterpolate colors at vertces down and across scan lnes 17

Gouraud Shadng Smooth shadng over adjacent polygons Curved surfaces Illumnaton hghlghts Soft shadows ( ) * Mesh wth shared normals at vertces Watt Plate 7 Gouraud Shadng Produces smoothly shaded polygonal mesh, + Pecewse lnear approxmaton Need fne mesh to capture subtle lghtng effects Flat Shadng Gouraud Shadng 18

Polygon Shadng Algorthms Flat Shadng Gouraud Shadng Phong Shadng Phong Shadng What f polygonal mesh s too coarse to capture llumnaton effects n polygon nterors? I = I E + K A I AL + ( K D ( N L ) I + K S ( V R ) n I ) 19

- Phong Shadng Method 2: One lghtng calculaton per pxel Approxmate surface normals for ponts nsde polygons by blnear nterpolaton of normals from vertces Phong Shadng Blnearly nterpolate surface normals at vertces down and across scan lnes 20

Polygon Shadng Algorthms Wreframe Gouraud Flat Phong Watt Plate 7 Shadng Issues Problems wth nterpolated shadng: 2 1 0 /. Polygonal slhouettes Perspectve dstorton Orentaton dependence (due to blnear nterpolaton) Problems at T-vertces Problems computng shared vertex normals 21

3 4 5 6 7 8 9 : Summary 2D polygon scan converson Pant pxels nsde prmtve Sweep-lne algorthm for polygons Polygon Shadng Algorthms Flat Less expensve Gouraud Phong Ray castng More accurate Key deas: Samplng and reconstructon Spatal coherence 22