Computer Graphics 4Practical Lesson

Slides:



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

Graphics Pipeline.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
Projective Texture Mapping
Texture Mapping. Texturing  process that modifies the appearance of each point on a surface using an image or function  any aspect of appearance can.
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
Computer Graphics - Class 10
Shading in OpenGL CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Shading in OpenGL Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
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);
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
Color in OpenGL (Chapter 4) Presented by: Stacy C. Lovell.
SET09115 Intro Graphics Programming
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
COMPUTER GRAPHICS CS 482 – FALL 2014 AUGUST 27, 2014 FIXED-FUNCTION 3D GRAPHICS MESH SPECIFICATION LIGHTING SPECIFICATION REFLECTION SHADING HIERARCHICAL.
COMP SCI 352 Computer Graphics and Animation. Computer Graphics2 My name is … My name is … How to find me How to find me Course Policies Course Policies.
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.
Shading & Texture. Shading Flat Shading The process of assigning colors to pixels. Smooth Shading Gouraud ShadingPhong Shading Shading.
OpenGL - Lighting, Shading and Material Properties
Computer Graphics I, Fall 2010 Shading in OpenGL.
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.
1 10/24/ :01 UML Graphics II Shadows Session 4.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
Properties of Reflective Waves Flat Mirrors. Light travels in a straight line Some light is absorbed Some light is redirected – “Reflected”
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
RENDERING Introduction to Shading models – Flat and Smooth shading – Adding texture to faces – Adding shadows of objects – Building a camera in a program.
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 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
11/5/2002 (c) University of Wisconsin, CS 559 Last Time Local Shading –Diffuse term –Specular term –All together –OpenGL brief overview.
11/24/ :45 Graphics II Shadow Maps Reflections Session 5.
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
Improving the appearance of 3D OpenGL scenes
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.
Shadows David Luebke University of Virginia. Shadows An important visual cue, traditionally hard to do in real-time rendering Outline: –Notation –Planar.
1 Computer Graphics Week11 : Hidden Surface Removal.
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Chapter 5. Lighting Computer Graphics (spring, 2009) School of Computer Science University of Seoul.
Computer Graphics Overview
- Introduction - Graphics Pipeline
Computer Graphics Lecture 3 Computer Graphics Hardware
Week 7 - Monday CS361.
© University of Wisconsin, CS559 Spring 2004
Shading To determine the correct shades of color on the surface of graphical objects.
Photorealistic Rendering vs. Interactive 3D Graphics
The Graphic PipeLine
How else do you look pretty in the morning?
CS451Real-time Rendering Pipeline
Understanding Theory and application of 3D
Models and Architectures
Vectors, Normals, & Shading
Shading in OpenGL Ed Angel
Lighting.
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
Lighting and Materials
Lighting – Light Sources
Texture and Shadow Mapping
Computer Graphics Practical Lesson 7
Computer Graphics 5Practical Lesson
Last Time Liang-Barsky Details Weiler-Atherton clipping algorithm
Game Programming Algorithms and Techniques
Computer Graphics Material Colours and Lighting
Presentation transcript:

Computer Graphics 4Practical Lesson Let there be light Computer Graphics 4Practical Lesson Lighting

Lighting purpose In openGL we can work without light definition – its how we worked until this session. In this mode object’s color is defined only by its drawing color. Its harder to understand object’s geometry without lighting.

Light Example 1 Keyboard key l turns on and off the lights. Keyboard key d turns on and off depth test. The keys 1,2,3 allow turn on and of 3 light sources. Without lights, it looks like a simple 2d white circle. When we use lights definitions, we can see it’s a sphere.

Depth Test When depth test is on, in the addition to the color buffer, there is depth buffer. This buffer stores for every pixel ( not vertex ) what its distance from the camera. When a new pixel is drawn in color buffer , its distance to the camera is checked.

Depth Test(cont’) If its closer than current drawn point, it will be displayed and frame buffer will be updated. When there is no depth test, every pixel is drawn, so the last drawn polygon will erase previous polygons.

Depth Test In Light Example 1 In this version of OpenGL, the sphere is drawn from the front to the back. So if the depth test is cancelled, what we will see is the back of the sphere. In another version of OpenGL the results can be different.

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 in Lights Example If lights are cancelled, the sphere and the triangle will be shown in their original color white. We can disable or enable each light source separately with the keys 1,2,3

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 source angle In OpenGL we can control the angle of the light source. We can do it with the parameter GL_SPOT_CUTOFF. glLightf(GL_LIGHT2, GL_SPOT_CUTOFF ,90 );

Ambient Light Source Light source can be ambient – the light effects the entire scene. Not just the polygon in front of the light. In example light 1 – we can see that the little triangle on the top is not affected by light 0 and 1. Light 2 also doesn’t reach him. Light 2 only affects him as ambient light.

Color smoothness OpenGL allows giving the scene a more “smooth” appearance. It can calculate the color of each pixel of polygons on the scene and give the object a more “smooth” look. We turn smoothness on and off by: glShadeModel(GL_SMOOTH); glShadeModel(GL_FLAT);

Color smoothness The color is determined by the normal of the surface at the point. The normal is interpolation of normal of polygon points. We can make the object appear as round, although its built from surfaces.

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.