College of Computer and Information Science, Northeastern UniversityJanuary 6, 20161 CS4300 Computer Graphics Prof. Harriet Fell Fall 2011 Lecture 22 –

Slides:



Advertisements
Similar presentations
CSC418 Computer Graphics n Polygon normals n Back Faces n Visibility Algorithms.
Advertisements

Lecture 14 Illumination II – Global Models
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
Visibility in Computer Graphics Toni Sellarès Unversitat de Girona
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
Based on slides created by Edward Angel
Illumination Model & Surface-rendering Method 박 경 와.
Computer Graphics - Class 10
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
IMGD 1001: Illumination by Mark Claypool
Computer Graphics (Fall 2005) COMS 4160, Lecture 16: Illumination and Shading 1
Hidden Surface Elimination Wen-Chieh (Steve) Lin Institute of Multimedia Engineering I-Chen Lin’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals.
College of Computer and Information Science, Northeastern UniversityJune 21, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 21.
Objectives Learn to shade objects so their images appear three- dimensional Learn to shade objects so their images appear three- dimensional Introduce.
6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering.
Vertices and Fragments III Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Part I: Basics of Computer Graphics Rendering Polygonal Objects (Read Chapter 1 of Advanced Animation and Rendering Techniques) Chapter
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
10/11/2001CS 638, Fall 2001 Today Kd-trees BSP Trees.
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.
Hidden Surface Removal
College of Computer and Information Science, Northeastern UniversitySeptember 5, CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.
Lecture 5: 3D Rendering Pipeline (II) Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia Institute of Technology.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) CS 426 Intro to 3D Computer Graphics © 2003, 2004, 2005 Jason Leigh Electronic.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
CS447/ Realistic Rendering -- Radiosity Methods-- Introduction to 2D and 3D Computer Graphics.
College of Computer and Information Science, Northeastern UniversityOctober 16, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2007.
Visible-Surface Detection Jehee Lee Seoul National University.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Taku KomuraComputer Graphics Local Illumination and Shading Computer Graphics – Lecture 10 Taku Komura Institute for Perception, Action.
03/14/02 (c) 2002 University of Wisconsin, CS559 Last Time Some more visibility (Hidden Surface Removal) algorithms –A-buffer –Scanline –Depth sorting.
CS-378: Game Technology Lecture #2.2: Clipping and Hidden Surfaces Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney,
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.
Binary Space Partitioning Trees Ray Casting Depth Buffering
Implementation II.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Basic Ray Tracing CMSC 435/634.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
CS 445 / 645 Introduction to Computer Graphics Lecture 15 Shading Shading.
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
Local Illumination and Shading
Cornell CS465 Spring 2004 Lecture 4© 2004 Steve Marschner 1 Shading CS 465 Lecture 4.
Computer Graphics I, Fall 2010 Implementation II.
Illumination and Shading Prof. Lizhuang Ma Shanghai Jiao Tong University.
1 CSCE 441: Computer Graphics Hidden Surface Removal 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,
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
CS552: Computer Graphics Lecture 33: Illumination and Shading.
Hidden Surface Removal. 2 Goal: Determine which surfaces are visible and which are not. Z-Buffer is just one of many hidden surface removal algorithms.
Illumination and Shading Prof. Lizhuang Ma Shanghai Jiao Tong University.
Shading CS 465 Lecture 4 © 2004 Steve Marschner • 1.
Computer Graphics Implementation II
Prof. Harriet Fell Spring 2007 Lecture 26 – March 19, 2007
Unit-7 Lighting and Shading
CSCE 441: Computer Graphics Hidden Surface Removal
Prof. Harriet Fell Fall 2011 Lecture 24 – November 2, 2011
CS G140 Graduate Computer Graphics
Prof. Harriet Fell Spring 2006 Lecture 21 – February 28,2007
Illumination and Shading
14th Lecture – Final Lecture
CS G140 Graduate Computer Graphics
Computer Graphics (Fall 2003)
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Presentation transcript:

College of Computer and Information Science, Northeastern UniversityJanuary 6, CS4300 Computer Graphics Prof. Harriet Fell Fall 2011 Lecture 22 – October 27,2011

College of Computer and Information Science, Northeastern UniversityJanuary 6, Today’s Topics Poly Mesh Hidden Surface Removal Visible Surface Determination More about the First 3D Project First Lighting model

College of Computer and Information Science, Northeastern UniversityJanuary 6, Rendering a Polymesh Scene is composed of triangles or other polygons. We want to view the scene from different view- points. Hidden Surface Removal Cull out surfaces or parts of surfaces that are not visible. Visible Surface Determination Head right for the surfaces that are visible. Ray-Tracing is one way to do this.

College of Computer and Information Science, Northeastern UniversityJanuary 6, Wireframe Rendering Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Hidden- Line Removal Hidden- Face Removal

College of Computer and Information Science, Northeastern UniversityJanuary 6, Convex Polyhedra We can see a face if and only if its normal has a component toward us. N·V > 0 V points from the face toward the viewer. N point toward the outside of the polyhedra.

College of Computer and Information Science, Northeastern UniversityJanuary 6, Finding N A B C B - A C - A N = (B - A) x (C - A) is a normal to the triangle that points toward you. is a unit normal that points toward you.

College of Computer and Information Science, Northeastern UniversityJanuary 6, Code for N private Vector3d findNormal(){ Vector3d u = new Vector3d(); u.scaleAdd(-1, verts[0], verts[1]); Vector3d v = new Vector3d(); v.scaleAdd(-1, verts[0], verts[2]); Vector3d uxv = new Vector3d(); uxv.cross(u, v); return uxv; }

College of Computer and Information Science, Northeastern UniversityJanuary 6, Finding V Since we are just doing a simple orthographic projection, we can use V = k = (0, 0, 1). Then N  V = the z component of N public boolean faceForward() { return (normal.z > 0); }

College of Computer and Information Science, Northeastern UniversityJanuary 6, Find L L is a unit vector from the point you are about to render toward the light. For the faceted icosahedron use the center point of each face. cpt = (A + B + C)/3

College of Computer and Information Science, Northeastern UniversityJanuary 6, First Lighting Model Ambient light is a global constant ka. Try ka =.2. If a visible object S has color (S R, S G, S B ) then the ambient light contributes (.2* S R,.2* S G,.2* S B ). Diffuse light depends of the angle at which the light hits the surface. We add this to the ambient light. We will also add a spectral highlight.

College of Computer and Information Science, Northeastern UniversityJanuary 6, Visible Surfaces Ambient Light

College of Computer and Information Science, Northeastern UniversityJanuary 6, Diffuse Light

College of Computer and Information Science, Northeastern UniversityJanuary 6, Lambertian Reflection Model Diffuse Shading For matte (non-shiny) objects Examples Matte paper, newsprint Unpolished wood Unpolished stones Color at a point on a matte object does not change with viewpoint.

College of Computer and Information Science, Northeastern UniversityJanuary 6, Physics of Lambertian Reflection Incoming light is partially absorbed and partially transmitted equally in all directions

College of Computer and Information Science, Northeastern UniversityJanuary 6, Geometry of Lambert’s Law N N L dA 90 - θ θ dAcos(θ) θ L Surface 1 Surface 2

College of Computer and Information Science, Northeastern UniversityJanuary 6, cos(θ)=N  L Surface 2 dA 90 - θ θ dAcos(θ) θ L N Cp= ka (SR, SG, SB) + kd N  L (SR, SG, SB)

College of Computer and Information Science, Northeastern UniversityJanuary 6, Hidden Surface Removal Backface culling Never show the back of a polygon. Viewing frustum culling Discard objects outside the camera’s view. Occlusion culling Determining when portions of objects are hidden. Painter’s Algorithm Z-Buffer Contribution culling Discard objects that are too far away to be seen.

College of Computer and Information Science, Northeastern UniversityJanuary 6, Visible Surface Determination If most surfaces are invisible, don’t render them. Ray Tracing We only render the nearest object. Binary Space Partitioning (BSP) Recursively cut up space into convex sets with hyperplanes. The scene is represented by a BSP-tree.

College of Computer and Information Science, Northeastern UniversityJanuary 6, Sorting the Polygons The first step of the Painter’s algorithm is: Sort objects back to front relative to the viewpoint. The relative order may not be well defined. We have to reorder the objects when we change the viewpoint. The BSP algorithm and BSP trees solve these problems.

College of Computer and Information Science, Northeastern UniversityJanuary 6, Binary Space Partition Our scene is made of triangles. Other polygons can work too. Assume no triangle crosses the plane of any other triangle. We relax this condition later. following Shirley et al.

College of Computer and Information Science, Northeastern UniversityJanuary 6, BSP – Basics Let a plane in 3-space (or line in 2-space) be defined implicitly, i.e. f(P) = f(x, y, z) = 0 in 3-space f(P) = f(x, y) = 0 in 2-space All the points P such that f(P) > 0 lie on one side of the plane (line). All the points P such that f(P) < 0 lie on the other side of the plane (line). Since we have assumed that all vertices of a triangle lie on the same side of the plane (line), we can tell which side of a plane a triangle lies on.

College of Computer and Information Science, Northeastern UniversityJanuary 6, BSP on a Simple Scene Suppose scene has 2 triangles T1 on the plane f(P) = 0 T2 on the f(P) < 0 side e is the eye. if f(e) < 0 then draw T1; draw T2 else draw T2; draw T1 f(P)=0 f(P)>0 f(P)<0

College of Computer and Information Science, Northeastern UniversityJanuary 6, The BSP Tree Suppose scene has many triangles, T1, T2, …. We still assume no triangle crosses the plane of any other triangle. Let f i (P) = 0 be the equation of the plane containing Ti. The BSPTREE has a node for each triangle with T1 at the root. At the node for Ti, the minus subtree contains all the triangles whose vertices have f i (P) < 0 the plus subtree contains all the triangles whose vertices have f i (P) > 0.

College of Computer and Information Science, Northeastern UniversityJanuary 6, BSP on a non-Simple Scene function draw(bsptree tree, point e) if (tree.empty) then return if (f t ree.root (e) < 0) then draw(tree.plus, e) render tree.triangle draw(tree.minus, e) else draw(tree.minus, e) render tree.triangle draw(tree.plus, e)

College of Computer and Information Science, Northeastern UniversityJanuary 6, D BSP Trees Demo This is a demo in 2 dimensions. The objects are line segments. The dividing hyperplanes are lines.

Building the BSP Tree We still assume no triangle crosses the plane of another triangle. tree = node(T1) for i in {2, …, N} do tree.add(Ti) function add (triangle T) if (f(a) < 0 and f(b) < 0 and f(c) < 0) then if (tree.minus.empty) then tree.minus = node(T) else tree.minus.add(T) else if (f(a) > 0 and f(b) > 0 and f(c) > 0) then if (tree.plus.empty) then tree.plus = node(T) else tree.plus.add(T)

College of Computer and Information Science, Northeastern UniversityJanuary 6, Triangle Crossing a Plane a c b A B Two vertices, a and b, will be on one side and one, c, on the other side. Find intercepts, A and B, of the plane with the 2 edges that cross it.

College of Computer and Information Science, Northeastern UniversityJanuary 6, Cutting the Triangle a c b A B Cut the triangle into three triangles, none of which cross the cutting plane. Be careful when one or more of a, b, and c is close to or on the cutting plane.

College of Computer and Information Science, Northeastern UniversityJanuary 6, 2016 Flat Shading A single normal vector is used for each polygon. The object appears to have facets.

College of Computer and Information Science, Northeastern UniversityJanuary 6, 2016 Gouraud Shading Average the normals for all the polygons that meet a vertex to calculate its surface normal. Compute the color intensities at vertices base on the Lambertian diffuse lighting model. Average the color intensities across the faces. This image is licensed under the Creative CommonsCreative Commons Attribution License v. 2.5.Attribution License v. 2.5

College of Computer and Information Science, Northeastern UniversityJanuary 6, 2016 Phong Shading Gouraud shading lacks specular highlights except near the vertices. Phong shading eliminates these problems. Compute vertex normals as in Gouraud shading. Interpolate vertex normals to compute normals at each point to be rendered. Use these normals to compute the Lambertian diffuse lighting.