Lighting and Shading Part 2. Global Ambient Light There are at least 8 OpenGL lights and 1 Global Ambient Setting the Global Ambient globalAmbient[] =

Slides:



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

CSPC 352: Computer Graphics
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
1. What is Lighting? 2 Example 1. Find the cubic polynomial or that passes through the four points and satisfies 1.As a photon Metal Insulator.
Shading in OpenGL CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
IMGD 1001: Illumination by Mark Claypool
Lighting and Shading Wen-Chieh (Steve) Lin
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.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
LIGHTING Part One - Theory based on Chapter 6. Lights in the real world Lights bounce off surfaces and reflect colors, scattering light in many directions.
SET09115 Intro Graphics Programming
Fundamentals of Computer Graphics Part 6 Shading prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared with Angel,E.:
Computer Graphics Lighting.
1 Graphics CSCI 343, Fall 2013 Lecture 20 Lighting and Shading III.
Polygon Shading. Assigning color to a shape to make graphical scenes look realistic, or artistic, or whatever effect we’re attempting to achieve But first.
1 Shading I Shandong University Software College Instructor: Zhou Yuanfeng
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Chapter 6: Shading Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Shading (introduction to rendering). Rendering  We know how to specify the geometry but how is the color calculated.
COMPUTER GRAPHICS CS 482 – FALL 2014 AUGUST 27, 2014 FIXED-FUNCTION 3D GRAPHICS MESH SPECIFICATION LIGHTING SPECIFICATION REFLECTION SHADING HIERARCHICAL.
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.
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.
Steve Sterley. Real World Lighting Physical objects tend to interact with light in three ways: Absorption (black body) Reflection (mirror) Transmission.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Illumination and Shading
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.
Specular Reflection Lecture 27 Mon, Nov 10, 2003.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Local Illumination and Shading
Chris Mayer & Nic Shulver Shading Definitions Light emanating from small surfaces is called a Point light sourcee.g. the sun (not really small though!)
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
Render methods. Contents Levels of rendering Wireframe Plain shadow Gouraud Phong Comparison Gouraud-Phong.
Illumination and Shading Sang Il Park Sejong University.
Lighting and Reflection Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Shading NOTE: Some of these slides are from Ed Angel’s presentation at SIGGRAPH February 27, 2008.
Illumination Models. Introduction 1 Illumination model: Given a point on a surface, what is the perceived color and intensity? Known as Lighting Model,
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
Illumination Models and Surface-Rendering Methods CEng 477 Introduction to Computer Graphics.
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness 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.
Illumination : Hearn & Baker Ch. 10
Shading To determine the correct shades of color on the surface of graphical objects.
Unit-7 Lighting and Shading
Chapter 14 Shading Models.
CSC461: Lecture 23 Shading Computation
Vectors, Normals, & Shading
Shading in OpenGL Ed Angel
Lighting and Shading Lab 8:.
Introduction to Computer Graphics with WebGL
Fundamentals of Computer Graphics Part 6 Shading
Lighting and Materials
Lighting – Light Sources
CS5500 Computer Graphics April 10, 2006.
Illumination and Shading
ייצוג בעולם 3D ייצוג מצולעים (פוליגונים) צלע קודקוד צלעe0 : {v1,v2}
Chapter 14 Shading Models.
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics Shading in OpenGL
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science
Lighting Calculations
Presentation transcript:

Lighting and Shading Part 2

Global Ambient Light There are at least 8 OpenGL lights and 1 Global Ambient Setting the Global Ambient globalAmbient[] = { 0.2f, 0.2f, 0.2f, 1.0f }; glLightModelfv(GL_LIGHT_MODEL_AMBIENT, globalAmbient); This is the default level of ambient light, you can alter this but shouldn’t really need to

Materials For OpenGL to calculate the lighting correctly your surfaces (Polygons) need to have their material properties set. There are five Variables you will need to consider: – Shininess Exponent – Emission (4x Floats rgba) – Specular (4x Floats rgba) – Diffuse (4x Floats rgba) // Diffuse sets the alpha trans! – Ambient (4x Floats rgba)

A nice way to store your Material Properties typedef struct{ float shinyness; // float emission[4]; float specular[4]; float diffuse[4]; float ambient[4]; } surfaceProperties;

Material Properties act as Multipliers Except for the Emissive Component If World has 0.2f Ambient – Your surface has an Ambient of 0.5f – You will end up with 0.1f of light on your surface

Light Property Storage typedef struct{ float ambient[4];// 0.0f - 1.0f float diffuse[4];// 0.0f - 1.0f float specular[4];// 0.0f - 1.0f float position[4]; // [4] == 0.0f Light = Directional and Att is off float spotDirection[3]; // Not used when spotCutoff == 180.0f float spotExponent;// 0.0f f float spotCutoff;// 0.0f f f float constantAtt;// <=0.0f float linearAtt;// <=0.0f float quadraticAtt;// <=0.0f } lightProperties;

Smooth vs Flat Shading Smooth Shading is the Default applied by OpenGL You can Enable Flat Shading by changing the shading model glShadeModel(GL_FLAT); glShadeModel(GL_SMOOTH);

Flat Shading Unexciting – This is the simplest form of shading – One vertex from each polygon is selected for shading. – The Pixel shader is then given a flat shade colour for each polygon.

Flat Shading In Action…

Mach Bands

Perceived and Actual Intensities

When Flat Shading is ok… Typically at best it’s average looking if – Both I and R are distant This way variances between adjacent polygons will be low – If I or R are close variances in adjacent Polygons will be ugly

Gouraud Shading (Smooth Shading) Each vertex in a Polygon mesh is assigned an ‘average’ normal calculated from the adjacent Polygons to the Vertex The Shading Is then Calculated for each Vertex and then Interpolated across the Polygon uraud_shading.gif

Phong Shading The Normal Is calculated at each Vertex as per Gouraud Shading Then Instead of Interpolating the Shade over the Polygon, we Interpolate the Normal across the Polygon Edges and use this to Render each pixel with its own Normal, and associated Shade In effect Phong Shading represents each Polygon as a Curved Surface to the Light Source

From Smooth to Phong

Ambient Surfaces Each Pixel is simply coloured based on the Ambient Absorbtion, The Ambient light sources, and the pixels current colour

Diffuse Surfaces Each Pixel is simply coloured based on the Diffuse Absorbtion, The Diffuse light sources, and the pixels current colour Diffuse Light Sources have can have distance and attenuation, and only light the sides of the object which have a direct LOS to the Light

Specular Light Specular Lighting takes into account Specular Light Sources, The Viewer Location and the Angle between these and the Normal of the Vertex

Shading Specular Reflective Surfaces For Reflective Lighting we need 3 things – The angle of incidence – The angle of reflection – The normal of the surface

We can always calculate the normal of the surface, and we know where the light is (Given we place it!) elaw.jpg

That’s the end of Basic Lighting We’ll Continue Lighting After we learn to program Vertex and Pixel Shaders This will allow us to do almost any lighting we want