Normals Specifying the normal –void glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ); When using lighting effects, normals must be defined for each.

Slides:



Advertisements
Similar presentations
Polygon Rendering Flat Rendering Goraud Rendering Uses Phong Reflectance Phong Rendering.
Advertisements

Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
1 MAE152 Computer Graphics for Scientists and Engineers Lighting in OpenGL.
Computer Graphics - Class 10
OpenGL Son of the Survival Guide. Last Time on OpenGL Windowing … glut Rendering Primatives Transformations Projections State Management.
Shading in OpenGL CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
What is OpenGL The OpenGL graphics system is a software interface to graphics hardware. (The GL stands for Graphics Library.) It allows you to create interactive.
CS 4731: Computer Graphics Lecture 16: Illumination Models Part 2 Emmanuel Agu.
Shading in OpenGL Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Hidden Surfaces and Shading CS BSP Tree T1T1 T2T2 E if (f 1 (E) < 0) then draw T 1 draw T 2 else draw T 2 draw T 1 f 1 (p) = 0 is the.
1 Lecture 10 Lighting in OpenGL. 2 Sources of light GLfloat myLightPosition[] = {3.0, 6.0, 5.0, 1.0}; GLLightfv(GL_LIGHT0, GL_POSITION, myLightPosition);
Now Playing: Multiply Jamie Lidell from Multiply Released June 13, 2005.
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
Computer Graphics (Spring 2008) COMS 4160, Lecture 14: OpenGL 3
CS425 OpenGL Materials. What Color Is It? green & blue absorbed white light Looks red.
Illumination and Shading
Lighting & Material. Example 1/5 #include ” glut.h ” void display(); void reshape(int, int); void lighting(); int main(int argc, char** argv) { glutInit(&argc,
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Color in OpenGL (Chapter 4) Presented by: Stacy C. Lovell.
Computer Graphics Lighting.
1 Graphics CSCI 343, Fall 2013 Lecture 20 Lighting and Shading III.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Chapter 6: Shading Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Illumination & Reflectance Dr. Amy Zhang. Outline 2  Illumination and Reflectance  The Phong Reflectance Model  Shading in OpenGL.
Shading in OpenGL.
1 Chapter 6 Shading. 2 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build.
19/17/ :25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.
Shading 03/19/2003. Lighting Principles Lighting based on how objects reflect light –Surface characteristics –Light color and direction –Global lighting.
OpenGL - Lighting, Shading and Material Properties
Computer Graphics I, Fall 2010 Shading in OpenGL.
Programming for Virtual Reality Applications Projection in OpenGL Lighting and Shading Lecture 17.
Lecture 9: Lighting and Shading 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271
Lecture 14 Shading models 1.Shading Constant Shading (to be implemented) Gouraud Shading Phong Shading 2.Light and shading with OpenGL 1.
08 |Lighting and Shading Eriq Muhammad Adams J |
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
CG Summary: OpenGL Shading andTextures Angel, Chapters 5, 7; “Red Book” slides from AW, red book, etc. CSCI 6360/4360.
OpenGL Color and Lighting 2003 Spring Keng Shih-Ling.
Lighting Review & Example Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 17, 2003.
OpenGL Lighting Jian-Liang Lin 2002 Hidden-Surface Removal -1 Original Code: while (1) { get_viewing_point_from_mouse_position(); glClear(GL_COLOR_BUFFER_BIT);
COMPUTER GRAPHICS Hochiminh city University of Technology Faculty of Computer Science and Engineering CHAPTER 6: Lighting and Shading.
RENDERING Introduction to Shading models – Flat and Smooth shading – Adding texture to faces – Adding shadows of objects – Building a camera in a program.
Shading in OpenGL Shandong University Software College Instructor: Zhou Yuanfeng
Lighting Dave Shreiner. 2 Lighting Principles Lighting simulates how objects reflect light Lighting simulates how objects reflect light material composition.
Shading NOTE: Some of these slides are from Ed Angel’s presentation at SIGGRAPH February 27, 2008.
Illumination CSE 410. Basic steps of lighting Enable smooth shading Set global ambient light glShadeModel(GL_SMOOTH); glEnable(GL_NORMALIZE); GLfloat.
CS559: Computer Graphics Lecture 16: Shading and OpenGL Li Zhang Spring 2008.
CSC Graphic Programming Lecture 2 OpenGL Lightning.
Lecture 6 Lighting. Introduction What is light? How do we percept colors? Lights in OpenGL.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 55 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 55 Computer Graphics Three-Dimensional Graphics V.
Graphics Graphics Korea University kucg.korea.ac.kr 1 Lights & Material 고려대학교 컴퓨터 그래픽스 연구실.
CSC Graphics Programming
CSC Graphics Programming
Shading To determine the correct shades of color on the surface of graphical objects.
Lecture 16: Shading and OpenGL Li Zhang Spring 2008
Advanced Graphics Algorithms Ying Zhu Georgia State University
Illumination and Shading
@ 2017 by Jim X. Chen George Mason University
Open GL: Colors and Lighting
Lecture 10, 11, and 12 Lighting & Shading
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Vectors, Normals, & Shading
Shading in OpenGL Ed Angel
CSC461: Lecture 24 Lighting and Shading in OpenGL
Lighting Glenn G. Chappell
Lighting Phong's Lighting Model normals
Illumination and Shading
Lighting and Materials
CS5500 Computer Graphics April 10, 2006.
Lighting – Material Properties
ייצוג בעולם 3D ייצוג מצולעים (פוליגונים) צלע קודקוד צלעe0 : {v1,v2}
Last Time Liang-Barsky Details Weiler-Atherton clipping algorithm
Presentation transcript:

Normals Specifying the normal –void glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ); When using lighting effects, normals must be defined for each polygon or for each vertex. OpenGL does not calculate a normal by itself. 垂直於平面的法向量 (perpendicular to a plane) 單位法向量 (normalized normal vector)

Normal Vector What is cross product ( 外積 )

Normalized Normal Vector V=(Vx,Vy,Vz), Length of V = |V| = (Vx 2 +Vy 2 +Vz 2 ) 1/2 Normalized Normal Vector V=(Vx,Vy,Vz)/|V|=(Vx/|V|, Vy/|V|,Vz/|V|)

Shading Models Choose the shading model –void glShadeModel( GLenum mode ); –mode may be GL_FLAT GL_SMOOTH (the same as the Gouraud shading model) OpenGL does not support the Phong shading model.

Material Properties An object has a certain reflective properties When using lighting, each model part has its own material properties, which also define its color. –glMaterialfv(GLenum face, GLenum pname, const GLfloat *params ) –Face must be one of GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK. –pname can be GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_SHININESS etc. –params change accordingly.

Colors In case you want to specify colors per face or per vertex, you must –Enable color tracking. glEnable(GL_COLOR_MATRERIAL); –Set material properties to follow glColor values. glColorMaterial(GLenum face, GLenum mode); –Specify the color before defining it’s corresponding vertex. glColor3d(GLdouble red, GLdouble green, GLdouble blue); glColor3ub(GLubyte red, GLubyte green, GLubyte blue);

Adding Light to a Scene Enabling lighting –glEnable(GL_LIGHT); OpenGL supports up to GL_MAX_LIGHTS lights simultaneously –Query with glGetIntegerv(GL_MAX_LIGHTS) Set the light properties –void glLightfv( GLenum light, GLenum pname, const GLfloat *params ); –pname can be GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_POSITION etc. –params change accordingly. Enable the specific light –glEnable(GL_LIGHTi); –i is between 0 and GL_MAX_LIGHTS-1