CS425 OpenGL Materials. What Color Is It? green & blue absorbed white light Looks red.

Slides:



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

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.
CS 4731: Computer Graphics Lecture 16: Illumination Models Part 2 Emmanuel Agu.
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 11: OpenGL 3
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.
Normals Specifying the normal –void glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ); When using lighting effects, normals must be defined for each.
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
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.
Development of Interactive 3D Virtual World Applications
Color in OpenGL (Chapter 4) Presented by: Stacy C. Lovell.
Computer Graphics Lighting.
Display Issues Week 5 David Breen Department of Computer Science
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.
Shading and Illumination. OpenGL Shading Without ShadingWith Shading.
Illumination and Shading
Computer Graphics I, Fall 2010 Shading in OpenGL.
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,
Chi-Cheng Lin, Winona State University CS430 Computer Graphics Lighting and Shading Part II.
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);
Chap 5 Global Illumination
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.
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Illumination Models and Surface-Rendering Methods CEng 477 Introduction to Computer Graphics.
1 Dr. Scott Schaefer Lighting. 2/49 Lighting/Illumination Color is a function of how light reflects from surfaces to the eye Global illumination accounts.
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
CS418 Computer Graphics John C. Hart
Shading To determine the correct shades of color on the surface of graphical objects.
Lecture 16: Shading and OpenGL Li Zhang Spring 2008
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.
Shading in OpenGL Ed Angel
CSC461: Lecture 24 Lighting and Shading in OpenGL
Lighting Phong's Lighting Model normals
Illumination and Shading
Lighting and Materials
Lighting – Light Sources
CS5500 Computer Graphics April 10, 2006.
Lighting – Material Properties
Last Time Liang-Barsky Details Weiler-Atherton clipping algorithm
Presentation transcript:

CS425 OpenGL Materials

What Color Is It? green & blue absorbed white light Looks red

What Color Is It? red & blue absorbed white light Looks green

What Color Is It? blue absorbed white light Looks yellow

What Color Is It? red absorbed red light ? cyan

What Color Is It? red absorbed red light cyan Looks black

What Color Is It? blue absorbed magenta light ?

What Color Is It? blue absorbed magenta light Looks red

Material Response to Light The material specified in OpenGL can have three different responses to the light hitting it plus one emissive characteristic. You can separately specify the response to: –Ambient –Diffuse –Specular And you can specify that the material “emits light”

glMaterial{if}v(face, pname, param) face –GL_FRONT –GL_BACK –GL_FRONT_AND_BACK

glMaterial{if}v(face, pname, param) pname –GL_AMBIENT (ambient color of material) –GL_DIFFUSE (diffuse color of material) –GL_AMBIENT_AND_DIFFUSE (both) –GL_SPECULAR (specular color of material) –GL_SHININESS (specular exponent) –GL_EMISSION (emissive color of material) –GL_COLOR_INDEXES (ambient, diffuse, and specular color indices)

glMaterial{if}v(face, pname, param ) param The value for the pname’d material property Example GLfloat mat_amb_diff [ ] = {0.1, 0.5, 0.8, 1.0}; glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_amb_diff);

NO Ambient (.7,.7,.7) Ambient (.8,.8,.2) Ambient Diffuse only (.1,.5, ) diffuse & specular (low shininess) diffuse & specular (high shininess) + (.3,.2,.2,.0) emmissive, no specular specular (1,1,1,1) shininess (5.0) specular (1,1,1,1) shininess (100.0)

Nate Robbins Lightmaterial

Color Material Mode I didn’t find this previously. Causes the material property specified to track the value of the current color (glColor*) glColorMaterial(face, mode) “face” and “mode” are same as for glMaterial. Must use glEnable (see example)

glColorMaterial example glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT, GL_DIFFUSE); glColor3f(0.2, 0.5, 0.8); /* draw some objects */ glColorMaterial(GL_FRONT, GL_SPECULAR); /*glColor no longer changes diffuse reflection, it now changes secular reflection */ glColor3f(0.9, 0.0, 0.2); /* draw some other objects */ glDisable(GL_COLOR_MATERIAL);

colormat.c

Two Sided Materials GLfloat outside = {0.2, 1.0, 1.0, 1.0}; GLfloat inside = {1.0, 0.5, 0.5, 1.0}; … glMaterialfv(GL_FRONT, GL_DIFFUSE, outside); glMaterialfv(GL_BACK, GL_DIFFUSE, inside); … glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);

Additional Clipping Plane GLdouble eqn[ ] = {0.0, -1.0, 0.07, 0.5}; … glEnable(GL_CLIP_PLANE0); … glClipPlane(GL_CLIP_PLANE0, eqn); ABCD Plane equation See cutting.c (handout)

Two Sided Materials with Cutting Plane

OpenGL Attenuation Same formula that Denbigh gave. c = constant factor l = linear factor q = quadratic factor d = distance

Function Calls You use the glLightf function to select attenuation factors. Default values are kc=1, kl=0, kq=0. –glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 2.0); –glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.0); –glLlightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.0);

kc=1 kl=0 kq=0 kc=0 kl=1 kq=0 kc=0 kl=0.5 kq=0 kc=0 kl=0.2 kq=0 kc=0 kl=0.1 kq=0 kc=0 kl=0.01 kq=0 kc=0 kl=0 kq=0.1 kc=0 kl=0 kq=0.001 kc=1 kl=0 kq= =