Computer Graphics 5Practical Lesson

Slides:



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

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.
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
Lighting and Illumination Lighting is the major problem in computer graphics, for either realism or real-time compositions- harder than modeling Consider.
SE 313 – Computer Graphics Lecture 13: Lighting and Materials Practice Lecturer: Gazihan Alankuş 1.
Computer Graphics - Class 10
Shading in OpenGL CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
IMGD 1001: Illumination by Mark Claypool
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.
6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering.
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
Computer Graphics (Spring 2008) COMS 4160, Lecture 14: OpenGL 3
Surface Rendering With OpenGL CS460 Project by Rui Yu 11/30/03.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
Illumination and Shading
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.
COMPUTER GRAPHICS CS 482 – FALL 2014 AUGUST 27, 2014 FIXED-FUNCTION 3D GRAPHICS MESH SPECIFICATION LIGHTING SPECIFICATION REFLECTION SHADING HIERARCHICAL.
Shading in OpenGL.
19/17/ :25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.
Computer Graphics I, Fall 2010 Shading in OpenGL.
CS380 LAB IV OpenGL Jonghyeob Lee Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
Lecture 9: Lighting and Shading 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Basic Rendering Pipeline and Shading Spring 2012.
Illumination and Shading How to shade surfaces based on the position,orientation,characteristics of the surfaces and the light sources illuminating them.
Computer Science Term 1, 2006 Tutorial 2 Assignment 3 – The Virtual World.
CG Summary: OpenGL Shading andTextures Angel, Chapters 5, 7; “Red Book” slides from AW, red book, etc. CSCI 6360/4360.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
11/5/2002 (c) University of Wisconsin, CS 559 Last Time Local Shading –Diffuse term –Specular term –All together –OpenGL brief overview.
Local Illumination and Shading
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.
Lighting and Shading Part 2. Global Ambient Light There are at least 8 OpenGL lights and 1 Global Ambient Setting the Global Ambient globalAmbient[] =
In the name of God Computer Graphics. Where We Stand So far we know how to: –Transform between spaces –Draw polygons Next –Deciding a pixel’s intensity.
Lighting Dave Shreiner. 2 Lighting Principles Lighting simulates how objects reflect light Lighting simulates how objects reflect light material composition.
CDS 301 Fall, 2008 From Graphics to Visualization Chap. 2 Sep. 3, 2009 Jie Zhang Copyright ©
Module 05 –Bump mapping Module 05 – Bump mapping Module 05 Advanced mapping techniques: Bump mapping.
CS559: Computer Graphics Lecture 16: Shading and OpenGL Li Zhang Spring 2008.
1© 2009 Autodesk Hardware Shade – Presenting Your Designs Hardware and Software Shading HW Shade Workflow Tessellation Quality Settings Lighting Settings.
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
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.
CSC Graphics Programming
© University of Wisconsin, CS559 Spring 2004
Shading To determine the correct shades of color on the surface of graphical objects.
School of Computer Science
Vectors, Normals, & Shading
Shading in OpenGL Ed Angel
Lighting Phong's Lighting Model normals
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
Lighting and Materials
Lighting – Light Sources
CS5500 Computer Graphics April 10, 2006.
Lighting – Material Properties
Introduction to Meshes
Computer Graphics Practical Lesson 7
Computer Graphics 4Practical Lesson
ייצוג בעולם 3D ייצוג מצולעים (פוליגונים) צלע קודקוד צלעe0 : {v1,v2}
Last Time Liang-Barsky Details Weiler-Atherton clipping algorithm
Computer Graphics Shading in OpenGL
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science
Introduction to Meshes
Presentation transcript:

Computer Graphics 5Practical Lesson Let there be light Computer Graphics 5Practical Lesson Lighting part 2

Defining Light Source To use lighting in OpenGL we first must enable lighting with the command glEnable(GL_LIGHTING) In OpenGL we can define up to 8 light sources. We can enable each light source seperatly by using the command glEnable(GL_LIGHT<0..7>) . We can disable with the command glDisable.

Light Source There are 3 types of effects of light source: Diffuse – this is the color of the light , affects objects the objects that are on direct line from the light source Ambient – light that affects the entire scene, and not only object that have direct line to him. Specular – makes the object “shine” – return light to camera. Also requires object to be set as specular

Light source color We can set the color of light using the parameter diffuse: glLightfv(GL_LIGHT1,GL_DIFFUSE,light_color); Where light color is a vector of 3 floats

Light Example 3 In this example we see 2 robots. Using the mouse, The user can rotate the robots. There 2 light sources, one on each side. The lights are rotating with the robots, creating fixed color.

Light Example 3(cont’) By clicking ‘f’, the lights are set to fixed position, and this changes the color of the robots by their position. Like in light example 2, user can switch between flat and smooth shading by clicking ‘s’.

Coloring Objects To allow coloring of objects: glEnable(GL_COLOR_MATERIAL). If this option is not set, then the light of objects comes only from the light sources. If its enables the color is effected by both the light source and color of object.

Objects Specular To make objects specular, both light source and object must have specular property set. In light example 1 in light sources 1 and 2 are creating specular effect. The commands are: glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glLightfv(GL_LIGHT1,GL_SPECULAR,mat_specular2); The third parameter is vector represent color, the 4th member defines if its single source or “surrounding” light.

Normal's and lighting By Default OpenGL calculates the normal for each triangle. In OpenGL we can set normal for each triangle ourselves by using the command glNormal() before entering the vertices of the triangle. For every polygon, can also set normal for each vertex separately.

Normal's and lighting(cont) Normal’s direction determine the effect of lighting. If the normal is not in the direction of the light source, the light source won’t affect the object. If the normal's of the points are not on the same direction, OpenGL makes interpolation, which can create illusions.

Loading BMP files In the site, I added the class BMPLoader.cpp It will allow you loading BMP files. With this class, you can load bmp images and access the cells directly. BMPClass bmp; BMPLoad(file_name,bmp);

Using BMPLoader.cpp This class properties are initialized with all the needed information to use the image. We will the information for assignment 2 and for textures.