SET09115 Intro Graphics Programming

Slides:



Advertisements
Similar presentations
SI23 Introduction to Computer Graphics
Advertisements

16.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 16 – Some Special Rendering Effects.
1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
3D Graphics Rendering and Terrain Modeling
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.
 Engineering Graphics & Introductory Design 3D Graphics and Rendering REU Modeling Course – June 13 th 2014.
Light Issues in Computer Graphics Presented by Saleema Amershi.
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.
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Shading I.
University of New Mexico
Computer Graphics - Class 10
Rendering (彩現 渲染).
IMGD 1001: Illumination by Mark Claypool
Computer Graphics (Fall 2005) COMS 4160, Lecture 16: Illumination and Shading 1
(conventional Cartesian reference system)
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
7M836 Animation & Rendering
Objectives Learn to shade objects so their images appear three- dimensional Learn to shade objects so their images appear three- dimensional Introduce.
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);
6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering.
Computer Graphics (Spring 2008) COMS 4160, Lecture 14: OpenGL 3
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Course Website: Computer Graphics 16: Illumination.
7/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 4: Visual Appearance.
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.
Distinguish between specular and diffuse reflection of light. Apply the law of reflection for flat mirrors. Describe the nature of images formed by flat.
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
CS 445 / 645: Introductory Computer Graphics
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
COMP 261 Lecture 14 3D Graphics 2 of 2. Doing better than 3x3? Translation, scaling, rotation are different. Awkward to combine them. Use homogeneous.
Shading (introduction to rendering). Rendering  We know how to specify the geometry but how is the color calculated.
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) CS 426 Intro to 3D Computer Graphics © 2003, 2004, 2005 Jason Leigh Electronic.
COMPUTER GRAPHICS CS 482 – FALL 2014 AUGUST 27, 2014 FIXED-FUNCTION 3D GRAPHICS MESH SPECIFICATION LIGHTING SPECIFICATION REFLECTION SHADING HIERARCHICAL.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
TERRAIN SET09115 Intro to Graphics Programming. Breakdown  Basics  What do we mean by terrain?  How terrain rendering works  Generating terrain 
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
Steve Sterley. Real World Lighting Physical objects tend to interact with light in three ways: Absorption (black body) Reflection (mirror) Transmission.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Basic Rendering Pipeline and Shading Spring 2012.
CSE 381 – Advanced Game Programming GLSL Lighting.
CS 325 Introduction to Computer Graphics 03 / 24 / 2010 Instructor: Michael Eckmann.
Reflection and Light Flat Mirrors.
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.
BUMP-MAPPING SET09115 Intro to Graphics Programming.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
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.
Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
Specular Reflection Lecture 27 Mon, Nov 10, 2003.
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
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.
Lighting and Shading Part 2. Global Ambient Light There are at least 8 OpenGL lights and 1 Global Ambient Setting the Global Ambient globalAmbient[] =
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
OpenGL Shading. 2 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
David Luebke3/16/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
Computer Graphics: Illumination
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Visual Appearance Chapter 4
3D Graphics Rendering PPT By Ricardo Veguilla.
Computer Graphics Material Colours and Lighting
Lighting Calculations
Presentation transcript:

SET09115 Intro Graphics Programming Lighting SET09115 Intro Graphics Programming

Breakdown Working with Colour Basics of Lighting Surface Lighting Why Lighting? Ambient Light Surface Lighting Diffuse Light Specular Light Other Lighting Types

Recommended Reading Real Time Rendering Course Text Chapter 5 – Visual Appearance Course Text Chapter 6 – Lighting and Shading

Colours

Colour Representation Modern graphics work with 32 bit colour Typically 4 values of 8 bits used Red, green, blue, alpha (transparency) Other formats exist We could work with values 0..255 Better to work with floats 0.0f ..1.0f 0% to 100%

Working with Colour Treat colour as a value you can work with Add colours together Red + Green = Yellow (1.0, 0.0, 0.0) + (0.0, 1.0, 0.0) = (1.0, 1.0, 0.0) Multiply colours together Magenta * Yellow = Red (1.0, 0.0, 1.0) * (1.0, 1.0, 0.0) = (1.0, 0.0, 0.0)

Vertex Colours Attaching colours to vertices is what we have been doing up until this point Blending occurs over surfaces between colour points OpenGL follows the RGBA format Image formats may not be in RGBA DirectX can support other formats These colours can be used in lighting calculations Typically, we use textured objects to provide more detail

Blending The ability to blend colours in this way is useful Multi-texturing Terrain We will revisit blending colours when working with textures and terrain

Questions? Working with colour

Basics of Lighting

Why Lighting? Lighting adds depth to a scene Unlit objects are flat and lack detail Lighting adds realism to objects Specular detail Light reflection

How Lighting Works Light works in rays from a graphics point of view Light comes from a source Light is reflected off of objects Light eventually makes it into the eye

Materials Light rays are just one part of the equation Light itself can have a colour Objects also have a colour The type of light they reflect into the eye rather than absorb The light that an object reflects is commonly described in its material Material may have other properties

Main Lighting Types Generally, an object has three lighting effects affecting it at any time Ambient Diffuse Specular The colour of an object are these three lighting effects combined Plus any other effectx

What is Ambient Light? Ambient light is the light that affects everything equally in a scene Has no direction Has no distance Doesn’t care about which part of the object is being calculated Outside, daylight is an ambient light effect

Ambient Light Equation Ambient light calculation is the simplest The ambient light of a particular vertex is just the ambient material colour of the object multiplied by the ambient light colour of the scene

Example

Questions? Why lighting? Materials Ambient light

Lighting Surfaces

Lighting a Surface Ambient light is something affecting all geometry equally Still gives a flat appearance to a scene Objects reflect light based on how their surfaces are aligned with the light source Occluded objects / surfaces get no light Surfaces perpendicular to light source get full light

Working with Normals We use surface normals to determine how light should be reflected off a surface Andrew will go into the mathematics of lighting next week Normals are very important for lighting

What is Diffuse Light? Diffuse light is concerned with directionality of the light Geometry facing a light source is lit Geometry facing away from the light source unlit Think sunlight outside

How does Diffuse Light Work? Diffuse light is concerned with the light direction against the surface normal of the piece of geometry in question If angle = 90 then full light If angle 0 to 90, or 90 to 180, then shaded If angle < 0 or > 180 then not lit Think about how this would work if you shone a light on a table

Lambert’s Cosine Law A simple way to calculate the diffuse light of an object is using Lambert’s Cosine Law Cos(0) = 0 Cos(90) = 1 Cos(180) = 0 The cosine graph shows how this works

Diffuse Light Algorithm Using Lambert’s Cosine Law, we can generate the diffuse lighting algorithm Remember, dot product of two vectors is equal to the cosine of the angle between them We would normally have to transform the surface normal if the model is transformed Diffuse alpha should always be 1. We will have to set this

Example

What is Specular Light? Specular light refers to the point on the object where the light strikes Specular reflection This provides a shiny look to objects Also indicates where the light is coming from

How does Specular Light Work? Specular light requires three pieces of information Light direction Surface normal Eye position Specular intensity is based on eye position

Specular Light Algorithm Specular light is the most complicated algorithm

Example

Questions? Surface lighting Diffuse lighting Specular lighting

Other Lighting Types

Other Lighting Types Ambient, Diffuse, and Specular are considered the main environmental lighting types Object materials usually deal with these three types There are of course other lighting types which affect a scene Dynamic lighting Point lights Spot lights

Point Lights A point light is a light that emanates from a particular point in the scene Use the same equations, but calculate light vector based on vertex position and light position Distance to light affects the strength of the light

Spot Lights Spot lights also work using light position and distance The direction of the light is also important Objects behind the spot light aren’t lit Light also has an angle associated with it Beam width at distance

Phong Shading Phong Shading is a popular per-pixel approach to performing lighting calculations Normals are interpolated across the surface of a polygon Provides a smoother shading look Vertex lighting as discussed in this lecture is sometimes referred to as Gourand shading

Questions? Point Lights Spot Lights Phong Shading

To do this week… Investigate some of the different forms of light that can affect a scene In particular, try and find their lighting values Consider the type of lighting you may want in your coursework OpenGL has light functionality built in without the use of shaders Shaders provide more controllable lighting

Summary Lighting is an important concept to provide depth and realism to your scene Lighting is about the colour of the light, and how an object reflects this light Three main types of lighting Ambient Diffuse Specular You should make yourself familiar with how to work these out