COMP 261 Lecture 14 3D Graphics 2 of 2. Doing better than 3x3? Translation, scaling, rotation are different. Awkward to combine them. Use homogeneous.

Slides:



Advertisements
Similar presentations
1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
Advertisements

3D Graphics Rendering and Terrain Modeling
Computer Graphics (Fall 2008) COMS 4160, Lecture 18: Illumination and Shading 1
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
1. What is Lighting? 2 Example 1. Find the cubic polynomial or that passes through the four points and satisfies 1.As a photon Metal Insulator.
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Shading I.
Computer Graphics - Class 10
IMGD 1001: Illumination by Mark Claypool
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Object-Order vs. Screen-Order Rendering April 24, 2003.
Computer Graphics (Fall 2005) COMS 4160, Lecture 16: Illumination and Shading 1
(conventional Cartesian reference system)
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
BPC: Art and Computation – Summer 2007 Computer Graphics Principles Erik Brisson
Global Illumination May 7, Global Effects translucent surface shadow multiple reflection.
7M836 Animation & Rendering
Objectives Learn to shade objects so their images appear three- dimensional Learn to shade objects so their images appear three- dimensional Introduce.
IAT 3551 Computer Graphics Overview Color Displays Drawing Pipeline.
BPC: Art and Computation – Spring 2007 Computer Graphics – Lighting and Rendering Erik Brisson
Graphics Systems I-Chen Lin’s CG slides, Doug James’s CG slides Angel, Interactive Computer Graphics, Chap 1 Introduction to Graphics Pipeline.
6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering.
Coordinate Systems X Y Z (conventional Cartesian reference system) X Y Z.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
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 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
SET09115 Intro Graphics Programming
CS 445 / 645 Introduction to Computer Graphics Lecture 18 Shading Shading.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Shading (introduction to rendering). Rendering  We know how to specify the geometry but how is the color calculated.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
1 Computer Graphics Week3 –Graphics & Image Processing.
Programmable Pipelines. 2 Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Computer Graphics An Introduction. What’s this course all about? 06/10/2015 Lecture 1 2 We will cover… Graphics programming and algorithms Graphics data.
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.
CS447/ Realistic Rendering -- Radiosity Methods-- Introduction to 2D and 3D Computer Graphics.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
Taku KomuraComputer Graphics Local Illumination and Shading Computer Graphics – Lecture 10 Taku Komura Institute for Perception, Action.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Basic Rendering Pipeline and Shading Spring 2012.
Illumination and Shading How to shade surfaces based on the position,orientation,characteristics of the surfaces and the light sources illuminating them.
CSE 381 – Advanced Game Programming GLSL Lighting.
Programming 3D Applications CE Displaying Computer Graphics Week 3 Lecture 5 Bob Hobbs Faculty of Computing, Engineering and Technology Staffordshire.
Programmable Pipelines Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
Global Illumination. Local Illumination  the GPU pipeline is designed for local illumination  only the surface data at the visible point is needed to.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
Specular Reflection Lecture 27 Mon, Nov 10, 2003.
Local Illumination and Shading
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Render methods. Contents Levels of rendering Wireframe Plain shadow Gouraud Phong Comparison Gouraud-Phong.
Lighting and Reflection Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
David Luebke3/16/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
Illumination Models. Introduction 1 Illumination model: Given a point on a surface, what is the perceived color and intensity? Known as Lighting Model,
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
Computer Graphics (Fall 2006) COMS 4160, Lecture 16: Illumination and Shading 1
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
COMP 261 Lecture 13 3D Graphics 1 of 2.
Shading To determine the correct shades of color on the surface of graphical objects.
Computer Graphics Chapter 9 Rendering.
Intro to 3D Graphics.
Chapter 14 Shading Models.
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
ICG 2018 Fall Homework1 Guidance
Presentation transcript:

COMP 261 Lecture 14 3D Graphics 2 of 2

Doing better than 3x3? Translation, scaling, rotation are different. Awkward to combine them. Use homogeneous coordinates : –Convert 3D vectors to 4D vectors –use 1 for the value in the 4 th dimension –express transformations by a 4 x 4 matrix. Lets us combine a sequence of transformations into a single transformation See more here:

Affine transformations: 4D Translation: Scale: Rotation: x y z ∆x∆x 010∆y∆y 001∆z∆z 0001 ⇒ x ∙ sx y ∙ sy z ∙ sz 1 x+∆ x y+∆y z+∆z 1 ⇒ cos θ -sinθ0 0sinθcosθ x y z 1 ⇒ 1x + 0y + 0z 0x + cosθy – sinθz 0x + sinθy + cosθz 1 sx000 0sy00 00sz x y z 1

Transformations Apply transformation input:point (x, y, z, 1) transform T (4x4 array) initialise newpoint to (0,0,0,1) for row ← 0 to 3 for col ← 0 to 3 newpoint[row] += T[row, col] * point[col] Consistent pattern for all transformations. To transform polygon, apply transform to each vertex.

Combining transformations: Translation followed by Rotation: Matrix multiplication is associative: x y z ∆x∆x 010∆y∆y 001∆z∆z sin θ -cosθ0 0cosθsinθ ∆x∆x 0 -cosθsinθ∆y-cosθ∆z 0cosθsinθcosθ∆y+sinθ∆z 0001 x y z 1

Rendering Viewing perspective: Assume viewer looks along z-axis Rotate and translate object to make this the desired view Remove polygons facing away from viewer

Remove hidden polygons Compute normal to surface: (vector perpendicular to surface, pointing out of the face) facing away from viewer if z-component of normal is +ve normal = edge1  edge2 (cross product of the vectors) n = (n x, n y, n z ) = (a y b z – a z b y, a z b x – a x b z, a x b y – a y b x ) Remove if a x b y > a y b x or (x 2 -x 1 )(y 3 -y 2 ) > (y 2 -y 1 )(x 3 -x 2 ) a = (a x, a y, a z ) = (x 2 -x 1, y 2 -y 1, z 2 -z 1 ) b = (b x, b y, b z ) = (x 3 -x 2, y 3 -y 2, z 3 -z 2 )

input: set of polygons viewing direction direction of light source(s) size of window. output: an image Actions rotate polygons and light source so viewing along z axis translate & scale to fit window / clip polygons out of view remove any polygons facing away from viewer (normal z > 0) for each polygon compute shading work out which image pixels it will affect for each pixel write shading and depth to z-buffer (retains only the shading of the closest surface) convert z-buffer to image Simple Z-buffer Rendering Pipeline z x z y x y

Illumination Light reflected from a surface depends on –light sources –reflectivity –matte vs shiny → diffuse or specular reflection –color, texture, pattern, … (variation in reflectivity) Simple option: assume matte, uniform reflectance for red, green, blue: (R r, R g, R b ) assume some ambient light light ← reflectance  ambient light level diffuse reflection depends on light source direction: light ← reflectance  light source  cos(angle of incidence) cos( θ) = normal ∙ lightdirection (if both unit vectors: length 1) θ light source dot product

Computing Illumination Matte or Diffuse material, “Lambert law”: Amount of light reflected is proportional to the cosine of the angle between the incoming light direction, and the surface normal We’re given the light direction Need to calculate the surface normal

Unit Normal to surface a = (a x, a y, a z ) = (x 2 -x 1, y 2 -y 1, z 2 -z 1 ) b = (b x, b y, b z ) = (x 3 -x 2, y 3 -y 2, z 3 -z 2 ) Cross product

Computing Illumination input:n = (n x, n y, n z )surface normal unit vector d = (d x, d y, d z )light direction unit vector (a r, a g, a b ) ambient light level (R r, R g, R b )reflectance in each colour (I r, I g, I b )intensity/colour of incident light output:(O r, O g, O b ) actions costh ← n ∙ d [ = (n x d x + n y d y + n z d z ) ] for c in red, green, blue: O c ← (a c + I c  costh)  R c

Further reading…for geeks! Shading languages: –Renderman shading language –GLSL –Adobe Pixel Bender –Playstation Shader Language –Etc…

Further reading…for geeks! Shading languages: –Syntax similar to C or Java –Built in variables like N (= normal), I (= eye) –Special operations like. (= dot product)

Shading Light reflected from a polygon: –could be uniform (if assume each polygon is a flat, uniform surface) ⇒ compute once for whole polygon could vary across surface (if polygons approximate a curved surface) –Can interpolate from the vertices: use "vertex normals" (average of surfaces at vertex) either interpolate shading from vertices or interpolate normals from vertices and compute shading What about shadows and reflected light from other sources –ray tracing!! expensive, we will ignore it 