Shadows via Projection Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 5, 2003.

Slides:



Advertisements
Similar presentations
Transforming graphs of functions
Advertisements

This terms course Last term we both worked on learning 2 things –Processing –The concepts of graphics etc. This term will focus more on the basic concepts.
Projective Texture Mapping
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
1 Computer Graphics Week6 –Basic Transformations- Translation & Scaling.
Informationsteknologi Monday, November 12, 2007Computer Graphics - Class 71 Today’s class Viewing transformation Menus Mandelbrot set and pixel drawing.
CS 325 Introduction to Computer Graphics 04 / 09 / 2010 Instructor: Michael Eckmann.
1 of 19 New Lecture And Lab Information Lectures: –Thursday 13:00 – 14:00 (A322) Does anyone miss lunch? –Friday 15:00 – 16:00 (A28) Labs: –Wednesday 10:00.
CS 376 Introduction to Computer Graphics 02 / 26 / 2007 Instructor: Michael Eckmann.
CS 376 Introduction to Computer Graphics 04 / 06 / 2007 Instructor: Michael Eckmann.
Stockman MSU/CSE Math models 3D to 2D Affine transformations in 3D; Projections 3D to 2D; Derivation of camera matrix form.
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
Course Overview, Introduction to CG Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 5, 2003.
CS 325 Introduction to Computer Graphics 03 / 03 / 2010 Instructor: Michael Eckmann.
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Mouse-Based Viewing & Navigation Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 3, 2003.
COMP 175: Computer Graphics March 24, 2015
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Camera Geometry and Calibration Thanks to Martial Hebert.
Representing Transformations, The TRANSF Package Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday,
CS 376 Introduction to Computer Graphics 02 / 12 / 2007 Instructor: Michael Eckmann.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Geometric Models & Camera Calibration
Geometric transformations The Pipeline
Data Structures for Scenes, The Basics of Scene Graphs Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday,
University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Introduction to computer vision Chapter 2: Image.
Foundations of Computer Graphics (Fall 2012) CS 184, Lectures 13,14: Reviews Transforms, OpenGL
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
CS 638, Fall 2001 Multi-Pass Rendering The pipeline takes one triangle at a time, so only local information, and pre-computed maps, are available Multi-Pass.
CS-378: Game Technology Lecture #4: Texture and Other Maps Prof. Okan Arikan University of Texas, Austin V Lecture #4: Texture and Other Maps.
More on Advanced Interfaces, Image Basics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, November 21, 2003.
VR UI, Notes on Projects, Intro. to Object Descriptions Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday,
More on Drawable Objects, Hierarchical Objects Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, January.
More on Environment Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, December 10, 2003.
OpenGL Selection. Three Selection Methods Color coding (OpenGL) Selection mode (OpenGL) Selection ray (generic)
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
Lighting Review & Example Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 17, 2003.
CS-498 Computer Vision Week 7, Day 2 Camera Parameters Intrinsic Calibration  Linear  Radial Distortion (Extrinsic Calibration?) 1.
Build-A-Button Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, October 8, 2003.
10/7/04© University of Wisconsin, CS559 Fall 2004 Last Time Transformations Homogeneous coordinates Directions Rotation Geometry 101 – Points, edges, triangles/polygons.
Image Synthesis Rabie A. Ramadan, PhD 4. 2 Review Questions Q1: What are the two principal tasks required to create an image of a three-dimensional scene?
More on GLUT Programming Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, September 15, 2003.
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)
Advanced Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, October 31, 2003.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Lecture 3 Transformations. 2D Object Transformations The functions used for modifying the size, location, and orientation of objects or of the camera.
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
David Luebke1/10/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
1 Perception and VR MONT 104S, Fall 2008 Lecture 20 Computer Graphics and VR.
Computer Graphics Matrices
More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.
Selection Mode, Introduction to Widgets Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 6, 2003.
Some Notes on 3-D Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, October 24, 2003.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Modeling Transformations Mario Costa Sousa University of Calgary CPSC 453, Fall 2001 Mario Costa Sousa University of Calgary CPSC 453, Fall 2001.
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
Stenciling Effects Glenn G. Chappell
© University of Wisconsin, CS559 Spring 2004
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
GAM 325/425: Applied 3D Geometry
Projection in 3-D Glenn G. Chappell
Display Lists & Text Glenn G. Chappell
More on Widgets, Misc. Topics
CS297 Graphics with Java and OpenGL
Presentation transcript:

Shadows via Projection Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 5, 2003

5 Nov 2003CS 3812 Review: Two Kinds of Interfaces Now, about that translation: In our “zoom & pan”, “driving”, the translation was done in the display function, not the saved matrix. But in “flying” the translation was in the saved matrix. Advanced interfaces can be divided into two categories: “View the world” interfaces. We look at the scene. Rotation and scaling are centered on the point we are looking at. So the translation does not go in the saved matrix. Examples Driving from above. Object manipulation. “Move in the world” interfaces. In these, we are explicitly inside the scene. Rotation is centered on the camera. So the translation goes in the saved matrix. Examples Flying. Driving, where we appear to be inside the car.

5 Nov 2003CS 3813 Review: Mouse-Based Viewing [1/2] Last time we will look at two mouse-based viewing interfaces. Click-and-drag rotation. View an object and rotate it in an intuitive way with the mouse (click-and- drag). Flying with the mouse. Fly forward on mouse-button press. Turn in the direction of the mouse position. The first is a “view the world” type of interface. The second is a “move in the world type of interface. These facts have ramifications for how the interfaces are implemented. (See the previous slide.) Both of these involve rotation about a line perpendicular to a vector computed from mouse positions. First: The vector is the difference between the current and previous mouse positions. (So we needed to save the mouse position.) Second: The vector is the difference between the current mouse position and the center of the screen.

5 Nov 2003CS 3814 Review: Mouse-Based Viewing [2/2] The following code was useful in both interfaces, for doing the perpendicular rotation. // perprot // Rotates about an axis in the x,y-plane, perpendicular to the given // vector (vx, vy). Rotation amount is proportional to the length of // the vector and to rotmultiplier. void perprot(double rotmultiplier, double vx, double vy) { double len = sqrt(vx*vx + vy*vy); glPushMatrix(); glRotated(rotmultiplier*len, -vy,vx,0.); glMultMatrixd( your_matrix_variable ); glGetDoublev(GL_MODELVIEW_MATRIX, your_matrix_variable ); glPopMatrix(); glutPostRedisplay(); }

5 Nov 2003CS 3815 Shadows via Projection: Introduction [1/2] Now that we know something about transformation matrices, we can use them to draw shadows. Covering shadows before covering lighting is a bit odd, of course. This topic is covered in section 5.10 of the (blue) text. My presentation differs somewhat from that in the text. What is a “shadow”? Answer 1: A region where light is blocked. That’s a great answer, but to use it, we need to know something about lighting. Maybe next week … Answer 2: The projection of the shape of an object on another object. We say “shape” here, since we do not want to draw the shadow using the same colors as the original object. We know (more or less) how to project onto a plane. We can use this knowledge to draw the shadow of an object on a plane.

5 Nov 2003CS 3816 Shadows via Projection: Introduction [2/2] We wish to find the matrix that projects onto a given plane from a given light position. This is essentially the synthetic-camera model. The light is at the center of projection, and the plane is the image plane. Does this mean that, with this method, objects will still cast shadows when they do not lie between the light and the plane? Yes, it does.

5 Nov 2003CS 3817 Shadows via Projection: The Math [1/2] To compute the proper projection matrix, we need the light position and an equation for the plane. We represent the light position as a 4-D vector L in homogeneous form, as shown below. The equation of a plane in 3-D space can be written as Ax + By + Cz + D = 0. We represent this with another 4-D vector P, as shown below. A point V (expressed in homogeneous form) lies on the plane precisely when V·P = 0. Light Position L = (L x, L y, L z, 1) Plane Equation: Ax + By + Cz + D = 0 P = (A, B, C, D)

5 Nov 2003CS 3818 Shadows via Projection: The Math [2/2] Now, let k = P·L be the dot product of P and L. The matrix that does the projecting is given below. On the left, we use matrix notation (which you may not be familiar with). What do we do with this matrix? It does projection, so we might be tempted to put it in OpenGL’s projection transformation. However, it does not set camera properties; it places objects in the world. (A shadow is an object!) So the matrix goes in model/view, after the viewing transformations, and before moving the object that casts the shadow.

5 Nov 2003CS 3819 Shadows via Projection: Some Code Look at shadowproj.cpp, on the web page, for code that uses this method to draw a shadow. The light position is stored in the global lightpos. The plane is specified by putting the coordinates of points in the global planepts. Function findplane computes and returns the plane “equation” (A, B, C, D). This is called from init, where these values are stored in the global plane_eq. Function makeshadowmatrix computes and returns the shadow projection matrix. This is also called from init, where the matrix is stored in the global shadowmat. The object is drawn by drawobject. The parameter is true if the object is to be drawn in normal color, false if it is to be drawn in gray. This function is called twice: once to draw the object, and once to draw the shadow. The shadow matrix is used in function display.

5 Nov 2003CS Shadows via Projection: Issues If we draw the shadow on a polygon, then the depth test might give us trouble. One solution is to disable the depth test before drawing the shadow. This only works if no part of the shadow is hidden by any previously drawn object. The shadow, being an object, is not confined to the polygon it (supposedly) is cast on. We can solve this using “stenciling”, a method for restricting drawing to certain portions of the frame buffer. Shadows are not gray; they are unlit. To do shadows properly, we draw the unshadowed portion with full lighting, and the shadowed portion using only “ambient” light. More on this when we cover lighting. Suppose we use this method to draw a shadow falling on a more complex object. For each polygon the shadow falls on, we would need to compute a separate matrix and draw the object casting the shadow. So this method is not recommended for casting shadows on complex objects. There are other shadowing methods; more on these later.