Hank Childs, University of Oregon

Slides:



Advertisements
Similar presentations
MAT 594CM S2010Fundamentals of Spatial ComputingAngus Forbes Overview Goals of the course: 1. to introduce real-time 3D graphics programming with openGL.
Advertisements

Using GLU/GLUT Objects GLU/GLUT provides very simple object primitives glutWireCube glutWireCone gluCylinder glutWireTeapot.
Hank Childs, University of Oregon Oct. 22 nd, 2014 CIS 441/541: Introduction to Computer Graphics Lecture 7: Arbitrary Camera Positions.
Graphics Pipeline.
2 COEN Computer Graphics I Evening’s Goals n Discuss the fundamentals of lighting in computer graphics n Analyze OpenGL’s lighting model n Show.
MAT 594CM S2010Fundamentals of Spatial ComputingAngus Forbes Overview Today: - Make sure everyone is set up with an OpenGL environment - OpenGL basics:
Objectives Learn to build arbitrary transformation matrices from simple transformations Learn to build arbitrary transformation matrices from simple transformations.
OpenGL (II). How to Draw a 3-D object on Screen?
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
Hierarchical Transformations Hierarchical Models Scene Graphs
CAP4730: Computational Structures in Computer Graphics Introduction to OpenGL.
COMP 175: Computer Graphics March 10, 2015
1 OpenGL Basics A Graphics Standard ©Mel Slater, Anthony Steed
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Geometric transformations The Pipeline
Hank Childs, University of Oregon
Hank Childs, University of Oregon Nov. 5th, 2014 CIS 441/541: Introduction to Computer Graphics Lecture 11: 2D textures, lighting and materials.
CSE 470: Computer Graphics. 10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Hank Childs, University of Oregon Nov. 14th, 2014 CIS 441/541: Introduction to Computer Graphics Lecture 13: CW/CCW, constructing geometry.
COMPUTER GRAPHICS CSCI 375. What do I need to know?  Familiarity with  Trigonometry  Analytic geometry  Linear algebra  Data structures  OOP.
Computer Graphics Bing-Yu Chen National Taiwan University.
Modeling with OpenGL Practice with OpenGL transformations.
Computer Science Term 1, 2006 Tutorial 2 Assignment 3 – The Virtual World.
MAE152 Computer Graphics for Scientists and Engineers Fall 03 Display Lists.
1/50 CS148: Introduction to Computer Graphics and Imaging Transforms CS148: Introduction to Computer Graphics and Imaging Transforms.
2 COEN Computer Graphics I Evening’s Goals n Discuss viewing and modeling transformations n Describe matrix stacks and their uses n Show basic geometric.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Transformations.
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.
Hank Childs, University of Oregon Volume Rendering, pt 1.
David Luebke1/5/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Hierarchical Modeling.
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.
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
1 Geometric Transformations-II Modelling Transforms By Dr.Ureerat Suksawatchon.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
CSCE 441: Computer Graphics: Hierarchical Models Jinxiang Chai.
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
CIS 441/541: Introduction to Computer Graphics Lecture 17: 2D textures
Hank Childs, University of Oregon
- Introduction - Graphics Pipeline
School of Computer Science
Transformations Introduction to Computer Graphics and Animation
IAT 355 Scene Graphs Feb 23, 2017 IAT 355.
Graphical Objects and Scene Graphs
Hank Childs, University of Oregon
Reference1. [OpenGL course slides by Rasmus Stenholt]
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.
Transformation and Viewing
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
Geometric Transformations
Chapter 4/5 glMatrixMode Modeling Transformations glTranslate glScale
Transformations IV Week 3, Wed Jan 20
Display Lists & Text Glenn G. Chappell
Geometric Transformations
The Modelview Matrix Lecture 8 Mon, Sep 10, 2007.
Transformations in OpenGL
ICG 2018 Fall Homework1 Guidance
Computer Graphics 4Practical Lesson
Transformations IV Week 3, Wed Jan 23
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
Hank Childs, University of Oregon
Geometric Transformations
Hierarchical Modeling
CSCE 441: Computer Graphics: Hierarchical Models
Presentation transcript:

Hank Childs, University of Oregon CIS 441/541: Introduction to Computer Graphics Lecture 19: transforms in GL, Project 2B Hank Childs, University of Oregon Nov. 7th, 2016

Announcements OH today: 230pm-315pm (*not* 3pm-4pm) Class canceled Monday Nov. 14th Also Weds Nov 30th Midterm Friday Nov 18th

Project G Lectures 541 students: when will we do these? Abhishek: Surfaces and Curves Andy: 3D rotation Jacob: Animation and Scene Graph Nicole: Shader programs Chad: GPGPU Garrett: modeling Kyle: particle effects 541 students: when will we do these?

Project G Projects: 541 students: when will these be ready? Manish, Lumin, Vincent: shader programs (x3) Ryan: Unity Sudhanshu: GPGPU Raleigh: WebGL 541 students: when will these be ready?

Review

CPU and GPU Most common configuration has CPU and GPU on separate dies I.e., plug GPU in CPU CPU (typically 4-12 cores, ~10GFLOPs) GPU (typically 100-1000 cores, ~100GFLOPs-~1000GFLOPs) PCIe Peripheral Component Interconnect Express What are the performance ramifications of this architecture?

Display lists Idea: send geometry and settings to GPU once, give it an identifier GPU stores geometry and settings Just pass the identifier for every subsequent render

Display lists Generate an idenfitier: GLUint displayList = glGenLists(1); Tell GPU that all subsequent geometry is part of the list: glNewList(displayList,GL_COMPILE); Specify geometry (i.e., glVertex, etc) Tell GPU we are done specifying geometry: glEndList(); Later on, tell GPU to render all the geometry and settings associated with our list: glCallList(displayList);

Display lists in action What are the performance ramifications between the two?

glNewList GL_COMPILE GL_COMPILE_AND_EXECUTE Make the display list for later use. GL_COMPILE_AND_EXECUTE Make the display list and also execute it as you go.

Geometry Specification: glBegin

Geometry Primitives

Geometry Primitives

Geometry Primitives

What can go inside a glBegin?

Lighting glEnable(GL_LIGHTING); Eight lights Tells OpenGL you want to have lighting. Eight lights Enable and disable individually glEnable(GL_LIGHT0) glDisable(GL_LIGHT7) Set attributes individually glLightfv(GL_LIGHTi, ARGUMENT, VALUES)

glLightfv parameters Ten parameters (ones you will use):

glLightfv in action For each light source, we can set an RGBA for the diffuse, specular, and ambient components: glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); Glfloat diffuse0[4] = { 0.7, 0.7, 0.7, 1 }; glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse0); … // set ambient, specular, position glDisable(GL_LIGHT1); // do we need to do this? … glDisable(GL_LIGHT7); // do we need to do this?

How do we tell OpenGL about the surface normals? Flat shading: glNormal3f(0, 0.707, -0.707); glVertex3f(0, 0, 0); glVertex3f(1, 1, 0); glVertex3f(1, 0, 0); Smooth shading: glNormal3f(0, 0.707, +0.707); glNormal3f(1, 0, 0);

glShadeModel

Transforms in GL

ModelView and Projection Matrices New for us Familiar for us ModelView idea: two purposes … model and view Model: extra matrix, just for rotating, scaling, and translating geometry. How could this be useful? View: Cartesian to Camera transform (We will focus on the model part of the modelview matrix now & come back to others later)

Add additional transforms here…. SLIDE REPEAT: Our goal Add additional transforms here…. Camera space: Camera located at origin, looking down -Z Triangle coordinates relative to camera frame O O World space: Triangles in native Cartesian coordinates Camera located anywhere Image space: All viewable objects within -1 <= x,y,z <= +1 x y z Screen space: All viewable objects within -1 <= x, y <= +1 Device space: All viewable objects within 0<=x<=width, 0 <=y<=height

ModelView and Projection Matrices New for us Familiar for us ModelView idea: two purposes … model and view Model: extra matrix, just for rotating, scaling, and translating geometry. How could this be useful? View: Cartesian to Camera transform (We will focus on the model part of the modelview matrix now & come back to others later)

Common commands for modifying model part of ModelView matrix glTranslate glRotate glScale

glTranslate Note: this matrix transposed from what we did earlier

glRotate

glScale

How do transformations combine? glScale(2, 2, 2) glTranslate(1, 0, 0) glRotate(45, 0, 1, 0) Rotate by 45 degrees around (0,1,0), then translate in X by 1, then scale by 2 in all dimensions. (the last transformation is applied first)

Which of two of these three are the same? Choice A: glScalef(2, 2, 2); glTranslate(1, 0, 0); Choice B: Choice C: glTranslate(2, 0, 0);

Each glTranslatef call updates the state of the ModelView matrix. ModelView usage dl = GenerateTireGeometry(); glCallList(dl); // place tire at (0, 0, 0) glTranslatef(10, 0, 0); glCallList(dl); // place tire at (10, 0, 0) glTranslatef(0, 0, 10); glCallList(dl); // place tire at (10, 0, 10) glTranslatef(-10, 0, 0); glCallList(dl); // place tire at (0, 0, 10) Each glTranslatef call updates the state of the ModelView matrix.

glPushMatrix, glPopMatrix

glPushMatrix and glPopMatrix dl = GenerateTireGeometry(); glCallList(dl); // place tire at (0, 0, 0) glPushMatrix(); glTranslatef(10, 0, 0); glCallList(dl); // place tire at (10, 0, 0) glPopMatrix(); glTranslatef(0, 0, 10); glCallList(dl); // place tire at (10, 0, 10) (0, 0, 10) Why is this useful?

Matrices in OpenGL OpenGL maintains matrices for you and provides functions for setting matrices. There are four different modes you can use: Modelview Projection Texture Color (rarely used, often not supported) You control the mode using glMatrixMode.

Matrices in OpenGL (cont’d) The matrices are the identity matrix by default and you can modify them by: 1) setting the matrix explicitly 2) using OpenGL commands for appending to the matrix You can have >= 32 matrices for modelview, >=2 for others

The Camera Transformation Source: www.opengl.org/archives/resources/faq/technical/viewing.htm

The Camera Transformation Source: www.opengl.org/archives/resources/faq/technical/viewing.htm

How do you put the Camera Transform in the ModelView matrix? No single GL call. Options are: (1) you do it yourself (i.e., calculate matrix and load it into OpenGL) (2) you use somebody’s code, i.e., gluLookAt (3) you use a combination of glRotatef, glScalef, and glTranslatef commands.

glMatrixMode

How do you put the projection transformation in GL_PROJECTION? Two options: glFrustum() (perspective projection) glOrtho() (orthographic projection)

glFrustum

glOrtho

glMatrixMode(GL_TEXTURE)

Project 2B

Project #2F (7%), Due Mon Nov 14th Goal: modify ModelView matrix to create dog out of spheres and cylinders New code skeleton: “project2B.cxx” No geometry file needed. You will be able to do this w/ glPush/PopMatrix, glRotatef, glTranslatef, and glScalef.

Project #2F (7%), Due Mon Nov 14th Goal: modify ModelView matrix to create dog out of spheres and cylinders New code skeleton: “project2B.cxx” No geometry file needed. You will be able to do this w/ glPush/PopMatrix, glRotatef, glTranslatef, and glScalef.

Contents of project2B.cxx Routine for generating spheres Routine for generating cylinders Routine for generating head, eyes, and pupils

What is the correct answer? The correct answer is: Something that looks like a dog No obvious problems with output geometry. Something that uses the sphere and cylinder classes. If you use something else, please clear it with me first. I may fail your project if I think you are using outside resources that make the project too easy. Something that uses rotation for the neck and tail. Aside from that, feel free to be as creative as you want … color, breed, etc.

For your reference: my dog