Some Notes on 3-D Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, October 24, 2003.

Slides:



Advertisements
Similar presentations
Graphics Pipeline.
Advertisements

Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
Projection Matrix Tricks Eric Lengyel Outline  Projection Matrix Internals  Infinite Projection Matrix  Depth Modification  Oblique Near Clipping.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections I.
CS 4731: Computer Graphics Lecture 18: Hidden Surface Removal Emmanuel Agu.
Gopi -ICS186AW03 - Slide1 Graphics Pipeline: First Pass.
OpenGL (II). How to Draw a 3-D object on Screen?
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Jittering, Introduction to Stenciling Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday, February 6, 2004.
Course Overview, Introduction to CG Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 5, 2003.
Objectives Review some advanced topics, including Review some advanced topics, including Chapter 8: Implementation Chapter 8: Implementation Chapter 9:
COMP 175: Computer Graphics March 24, 2015
Polygon Lists & 3-D File Formats Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, February 18, 2002.
Sky Rendering The actual physics is very complicated and costly to calculate. Several cheap approaches for very distant skies: –Constant backdrop –Skybox.
Linear Interpolation, Brief Introduction to OpenGL Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, September.
CS 481 Preview, Some Lighting Details Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 19, 2003.
Week 2 - Wednesday CS361.
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Data Structures for Scenes, The Basics of Scene Graphs Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday,
Clipping Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Luebke)
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,
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Shadows via Projection Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 5, 2003.
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.
OpenGL Conclusions OpenGL Programming and Reference Guides, other sources CSCI 6360/4360.
More on Advanced Interfaces, Image Basics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, November 21, 2003.
More on Drawable Objects, Hierarchical Objects Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, January.
Transformational Geometry CS418 Computer Graphics John C. Hart.
More on Environment Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, December 10, 2003.
Lighting Review & Example Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 17, 2003.
CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE.
Project 5 Lamp Shader Fri, Nov 7, 2003 Due Mon, Nov 17, 2003.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
Intro to OpenGL: Vertices and Drawing
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.
The Camera Analogy ► Set up your tripod and point the camera at the scene (viewing transformation) ► Arrange the scene to be photographed into the desired.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Introduction to Computer Graphics: Viewing Transformations Rama C
Computer Graphics Matrices
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
Details of Texture Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, December 1, 2003.
GL transformations-models. x' = x+t x y' = y+t y z' = z+t z t x t y s x =s y =s z t z uniform nonuniform?!!?? x' = x·s x y' =
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
Coordinate Systems Lecture 20 Wed, Oct 15, Object Coordinates Each object has its own “local” coordinate system, called object coordinates. Normally.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
- Introduction - Graphics Pipeline
Stenciling Effects Glenn G. Chappell
© University of Wisconsin, CS559 Spring 2004
Inside-Outside & Culling
CSCE 441 Computer Graphics 3-D Viewing
CS451Real-time Rendering Pipeline
Class 17 front and back lighting convex sets, convex hull
Advanced Menuing, Introduction to Picking
Projection in 3-D Glenn G. Chappell
Display Lists & Text Glenn G. Chappell
Lecture 13 Clipping & Scan Conversion
Chapter VII Rasterizer
More on Widgets, Misc. Topics
Class 18 front and back lighting convex sets, convex hull
Presentation transcript:

Some Notes on 3-D Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, October 24, 2003

24 Oct 2003CS 3812 Review: Culling Recall that polygons have a front and back. We can cull (turn off rendering of) either or both of these. Do glEnable(GL_CULL_FACE); Then glCullFace( … ); Parameter is GL_FRONT, GL_BACK (default), or GL_FRONT_AND_BACK. Parameter specifies which faces to turn off. Culling back faces can be useful. Objects are often closed: we cannot see the inside. Thus, rendering back faces wastes time.

24 Oct 2003CS 3813 Review: OpenGL Geometry Pipeline [1/2] Here is the OpenGL Geometry Rendering Pipeline as we know it so far. Now we add some details. In particular, the following all go into the “vertex operations” section: Model/view transformation. Lighting. Projection transformation. Clipping. View-frustum clipping, that is. Viewport transformation. Vertices (window coordinates) Vertex Operations Rasterization Fragment Operations Vertices (object coordinates) Fragments Vertex enters here To framebuffer

24 Oct 2003CS 3814 Review: OpenGL Geometry Pipeline [2/2] Model/view Transformation Projection Transformation Viewport Transformation World Coordinates Object Coordinates Eye Coordinates Window Coordinates Vertices (window coord’s) Vertex Operations Rasterization Fragment Operations Vertices (object coord’s) Fragments Vertex enters here To framebuffer Convert vertex data to fragment data Depth test, etc. Lighting Clipping (view-frustum)

24 Oct 2003CS 3815 Some Notes on 3-D: Three Principles for 3-D CG 1. All graphics is 2-D graphics. 2. If it looks good and runs fast, then it’s good enough.* 3. When choosing between two equally likely options, try one; if it doesn’t work, try the other. *Don’t try to claim this when doing scientific visualization (or when told to use a specific method on an assignment).

24 Oct 2003CS 3816 Some Notes on 3-D: Bitmap Text in 3-D Bitmap text does not work well in a 3-D scene. Transformations affect neither its size nor its orientation. But translations move it. Why the seeming inconsistency? You may want text anyway: documentation. Translate to just behind the near plane. This avoids problems with floating-point equality testing. Turn off the depth test. Do “ glDisable(GL_DEPTH_TEST); ”. Re-enable at some other time. Be consistent: What is the state of the depth test when a callback begins & ends? Turn off lighting, if you are using it. As above, turn it back on at some point, and be consistent.

24 Oct 2003CS 3817 Some Notes on 3-D: Transform’s for Multiple Objects To draw many objects of the same general type: Write a function that draws the object in “standard” position. Centered at the origin, unrotated. More generally: The point you put at the origin is the point you want to rotate/scale about. Repeat: Set up a transformation. Call the function. Try it!

24 Oct 2003CS 3818 Some Notes on 3-D: Transformation Order [1/2] Transformations are performed in the reverse order from how they are given in the code. Why? This makes hierarchical objects work right. Think about it. This is why we say (in the code) translate first, then rotate & scale. Because we want scale & rotation to happen about the origin, before translations. What happens if we do glRotate * then glTranslate *? How can we rotate about a line that does not pass through the origin? See next slide.

24 Oct 2003CS 3819 Some Notes on 3-D: Transformation Order [2/2] How can we rotate about a line that does not pass through the origin? Recall: To rotate about the x-axis, do glRotated( angle, 1.,0.,0.); Suppose we want to rotate about the line 1 unit above (+y) this? Solution: Translate down (0, –1, 0). Then rotate (as above). Then translate back up (0, +1, 0). In the code, the transformations need to be given in the reverse order: glTranslated(0., 1., 0.); glRotated( angle, 1.,0.,0.); glTranslated(0., -1., 0.);

24 Oct 2003CS Some Notes on 3-D: Lighting Preview [1/2] When we do lighting, vertices need normal vectors (“normals”). Do “ glNormal3d( … ); ” just before your glVertex * call. Normals need to be unit vectors! The glVertex * command not only specifies a vertex; it also triggers the sending of data through the pipeline. So any data that goes with the vertex needs to be specified before the glVertex * call. The various glutSolid … functions all specify normals properly. Lighting and material definitions are also needed. See sample3d.cpp, on the web page.

24 Oct 2003CS Some Notes on 3-D: Lighting Preview [2/2] Normals go through the model/view transformation, too. Problem, if you use glScale *. Normals get scaled. So they might not be unit vectors, when they get to the lighting section of the pipeline. Solution: If you do lighting and use glScale *, do “ glEnable(GL_NORMALIZE); ” This forces normals to be unit vectors. It will slow things down just a little. This is only necessary if you use both lighting and scaling.