DOC PREVIEW
Columbia COMS 4160 - lecture 12

This preview shows page 1-2-3-26-27-28 out of 28 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Computer Graphics (Fall 2006)To DoMethodology for LectureImportance of LightingOutlineBrief primer on ColorShading ModelsDemo and Color PlatesLightingTypes of Light SourcesMaterial PropertiesSpecifying NormalsSlide 13LightMaterial DemoEmissive TermAmbient TermSlide 17Diffuse TermSlide 19Specular TermSlide 21DemoSlide 23Source Code (in display)Source Code (contd)Slide 26Moving a Light SourceLightposition demoComputer Graphics (Fall 2006)Computer Graphics (Fall 2006)COMS 4160, Lecture 12: OpenGL 3http://www.cs.columbia.edu/~cs4160To DoTo DoHW 3 Milestones due on Thu If stuck, please get help from me or TAsImportant you feel confident you can finish HW 3Programs in class, red book probably most helpMethodology for LectureMethodology for LectureLecture deals with lighting (teapot shaded as in HW1)Some Nate Robbins tutor demos in lectureBriefly explain OpenGL color, lighting, shadingDemo 4160-opengl\opengl3\opengl3-orig.exeLecture corresponds chapter 5 (and some of 4)But of course, better off doing rather than readingImportance of LightingImportance of LightingImportant to bring out 3D appearance (compare teapot now to in previous demo)Important for correct shading under lightsThe way shading is done also importantglShadeModel(GL_FLAT) glShadeModel(GL_SMOOTH)OutlineOutlineBasic ideas and preliminariesTypes of materials and shading Ambient, Diffuse, Emissive, SpecularSource codeMoving light sourcesBrief primer on ColorBrief primer on ColorRed, Green, Blue primary colorsCan be thought of as vertices of a color cubeR+G = Yellow, B+G = Cyan, B+R = Magenta, R+G+B = WhiteEach color channel (R,G,B) treated separatelyRGBA 32 bit mode (8 bits per channel) often usedA is for alpha for transparency if you need itColors normalized to 0 to 1 range in OpenGLOften represented as 0 to 255 in terms of pixel intensitiesAlso, color index mode (not so important)Shading ModelsShading ModelsSo far, lighting disabled: color explicit at each vertexThis lecture, enable lightingCalculate color at each vertex (based on shading model, lights and material properties of objects)Rasterize and interpolate vertex colors at pixelsFlat shading: single color per polygon (one vertex)Smooth shading: interpolate colors at verticesWireframe: glPolygonMode (GL_FRONT, GL_LINE)Also, polygon offsets to superimpose wireframeHidden line elimination? (polygons in black…)Demo and Color PlatesDemo and Color PlatesSee OpenGL color plates 1-8Demo: 4160-opengl\opengl3\opengl3-orig.exeQuestion: Why is blue highlight jerky even with smooth shading, while red highlight is smooth?LightingLightingRest of this lecture considers lighting on verticesIn real world, complex lighting, materials interactWe study this more formally in next unitOpenGL is a hack that efficiently captures some qualitative lighting effects. But not physicalModern programmable shaders allow arbitrary lighting and shading models (not covered in class)Types of Light SourcesTypes of Light SourcesPointPosition, Color [separate diffuse/specular]Attenuation (quadratic model)Directional (w=0, infinitely far away, no attenuation)SpotlightsSpot exponentSpot cutoffAll parameters: page 195 (should have already read HW1)21c l qattenk k d k d=+ +Material PropertiesMaterial PropertiesNeed normals (to calculate how much diffuse, specular, find reflected direction and so on)Four terms: Ambient, Diffuse, Specular, EmissiveSpecifying NormalsSpecifying NormalsNormals are specified through glNormalNormals are associated with verticesSpecifying a normal sets the current normalRemains unchanged until user alters itUsual sequence: glNormal, glVertex, glNormal, glVertex, glNormal, glVertex…Usually, we want unit normals for shadingglEnable( GL_NORMALIZE )This is slow – either normalize them yourself or don’t use glScaleEvaluators will generate normals for curved surfacesSuch as splines. GLUT does it automatically for teapot, cylinder,…OutlineOutlineBasic ideas and preliminariesTypes of materials and shading Ambient, Diffuse, Emissive, SpecularSource codeMoving light sourcesLightMaterial LightMaterial DemoDemoEmissive TermEmissive TermmaterialI Emission=Only relevant for light sources when looking directly at them• Gotcha: must create geometry to actually see light• Emission does not in itself affect other lighting calculationsAmbient TermAmbient TermHack to simulate multiple bounces, scattering of lightAssume light equally from all directionsAmbient TermAmbient TermAssociated with each light and overall lightE.g. skylight, with light from everywhere0* * *nglobal material light i material iiI ambient ambient ambient ambient atten== +�Most effects per light involve linearly combining effects of light sourcesDiffuse TermDiffuse TermRough matte (technically Lambertian) surfacesLight reflects equally in all directionsI N L�:N-LDiffuse TermDiffuse TermRough matte (technically Lambertian) surfacesLight reflects equally in all directionsWhy is diffuse of light diff from ambient, specular?I N L�:N-L0* * *[max ( ,0)]nlight i material iiI diffuse diffuse atten L N==�gSpecular TermSpecular TermGlossy objects, specular reflectionsLight reflects close to mirror directionSpecular TermSpecular TermGlossy objects, specular reflectionsLight reflects close to mirror directionConsider half-angle between light and viewersN0* * *[max ( ,0)]nshininesslight i material iiI specular specular atten N s== ��DemoDemoWhat happens when we make surface less shiny?What happens to jerkiness of highlights?OutlineOutlineBasic ideas and preliminariesTypes of materials and shading Ambient, Diffuse, Emissive, SpecularSource codeMoving light sourcesSource Code (in display)Source Code (in display) /* New for Demo 3; add lighting effects */ /* See hw1 and the red book (chapter 5) for details */ { GLfloat one[] = {1, 1, 1, 1}; // GLfloat small[] = {0.2, 0.2, 0.2, 1}; GLfloat medium[] = {0.5, 0.5, 0.5, 1}; GLfloat small[] = {0.2, 0.2, 0.2, 1}; GLfloat high[] = {100}; GLfloat light_specular[] = {1, 0.5, 0, 1}; GLfloat light_specular1[] = {0, 0.5, 1, 1}; GLfloat light_position[] = {0.5, 0, 0, 1}; GLfloat light_position1[] = {0, -0.5, 0, 1}; /* Set Material properties for the teapot */


View Full Document

Columbia COMS 4160 - lecture 12

Download lecture 12
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view lecture 12 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view lecture 12 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?