SlideShare a Scribd company logo
Mohammad Shaker
mohammadshaker.com
@ZGTRShaker
2015
OpenGL Graphics
L04-Lighting
What we’ve learnt so far..
RULE
TOSEEA3DSCENEYOUSHOULDSETUP:
CAMERA(Singleton,forallobjects)
PROJECTION(Singleton,forallobjects)
WORLDMATRIX(Foreachobjectseparately)
Lighting
How We See Things?
How We See Things?
Light and Color Systems
Additive Colors Subtractive Colors
Colors in OpenGL
• glColor3f(red, green, blue) [0,1]
• glColor4f(red, green, blue, alpha) [0,1]
Colors in OpenGL
• glColor3f(red, green, blue) [0,1]
• glColor4f(red, green, blue, alpha) [0,1]
– alpha for transparency [0; full,1: no]
Color Filling Mode
• Filling Mode
– glShadeModel(GL_FLAT);
• Fill the polygon with solid color (the same as last vertex color)
– glShadeModel(GL_SMOOTH);
• Interpolate colors between polygon edges
Light’s Type
• DIFFUSE color's alpha value actually determines the transparency of the polygon
Only ambient light only specular lightonly diffuse light
The Modified Phong Model
• Computes a color or shade for each vertex using a lighting model (the modified
Phong model) that takes into account
– Diffuse reflections
– Specular reflections
– Ambient light
– Emission
• Vertex shades are interpolated across polygons by the rasterizer
Lighting - Types
• Ambient Light: doesn’t come from any particular direction. It has an original
source somewhere, but the rays of light have bounced around the room or scene
and become directionless.
Lighting - Types
• Diffuse Light: The diffuse part of an OpenGL light is the directional component
that appears to come from a particular direction and is reflected off a surface with
an intensity proportional to the angle at which the light rays strike the surface.
Thus, the object surface is brighter if the light is pointed directly at the surface
than if the light grazes the surface from a greater angle.
Lighting - Types
• Specular light: Like diffuse light, specular light is a highly directional property, but
it interacts more sharply with the surface and in a particular direction.
The Modified Phong Model
• The model is a balance between simple computation and physical realism
• The model uses
– Light positions and intensities
– Surface orientation (normals)
– Material properties (reflectivity)
– Viewer location
• Computed for each source and each color component
Material Properties
• Define the surface properties of a primitive
• you can have separate materials for front and back
Property Description
Diffuse Base object color
Specular Highlight color
Ambient Low-light color
Emission Glow color
Shininess Surface smoothness
Material Properties
• Define the surface properties of a primitive
• you can have separate materials for front and back
Property Description
GL_DIFFUSE Base color
GL_SPECULAR Highlight Color
GL_AMBIENT Low-light Color
GL_EMISSION Glow Color
GL_SHININESS Surface Smoothness
Color Theory
Color Theory
Lighting in OpenGL
Lighting in OpenGL
Light Source and Object Material
Lighting in OpenGL
Light Source and Object Material
Turning on the Lights
• For any type of light, you should first
– Flip each light’s switch
glEnable(GL_LIGHT0);
– Turn on the power
glEnable(GL_LIGHTING);
Lighting in OpenGL – Light Source
• For the light source:
– Set light properties:
float Light_Ambient [ ] = {0.2,0.2,0.2,1};
float Light_Diffuse [ ] = {1,1,1,1};
float Light_Specular [ ] = {1,1,1,1};
float Light_Position [ ] = {0,0,20,0};
– Enable a specific light (GL_LIGHT0):
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
– Bind the light properties with the specific light (GL_LIGHT0):
glLightfv(GL_LIGHT0 , GL_AMBIENT , Light_Ambient);
glLightfv(GL_LIGHT0 , GL_DIFFUSE , Light_Diffuse);
glLightfv(GL_LIGHT0 , GL_SPECULAR , Light_Specular);
glLightfv(GL_LIGHT0 , GL_POSITION , Light_Position);
Lighting in OpenGL – Object Material
• For the object material:
– Set material properties:
float Cone_Ambient [ ] = {0.1,0.1,0.1,1};
float Cone_Diffuse [ ] = {0.2,0.1,0.9,1};
float Cone_Specular [ ] = {1,1,1,1};
float Cone_Shininess = 100;
– Bind the material properties with a specific object:
glMaterialfv(GL_FRONT_AND_BACK , GL_AMBIENT , Cone_Ambient);
glMaterialfv(GL_FRONT_AND_BACK , GL_DIFFUSE , Cone_Diffuse);
glMaterialfv(GL_FRONT_AND_BACK , GL_SPECULAR , Cone_Specular);
glMaterialf (GL_FRONT_AND_BACK , GL_SHININESS , Cone_Shininess);
• Now draw whatever you want.
GLUquadric *quadric = gluNewQudric();
gluCylinder(quadric, 4, 1, 7, 32, 32);
Lighting Example
Complete Code
Lighting Example
SpotLight Lighting Example
Complete Code
Lighting Example
Normals for Lighting
Why Normals are essential for lighting?
Why Normals are essential for lighting?
Normals for Lighting
• Vertex Normals
– Prefixed w/ “vn” (Wavefront)
– Contains x,y,z of normal
– Not necessarily unit length
– Not necessarily in vertex order
– Indexed as with vertices
(x0,y0,z0)
(a0,b0,c0)
(u0,v0)
(x1,y1,z1)
(a1,b1,c1)
(u1,v1)
(x2,y2,z2)
(a2,b2,c2)
(u2,v2)
Surface Normals
• Normals define how a surface reflects light
– Application usually provides normals as a vertex atttribute
– Current normal is used to compute vertex’s color
– Use unit normals for proper lighting
• scaling affects a normal’s length
Vector Normalization
Vector Normalization
Why to?
Advanced Lighting, Spotlight
Shadowing
Shadowing
• How to make a shadow?
– Draw the whole object again, projecting it on the shadow plane (the plane in which the
shadow will appear)
Shadowing

More Related Content

What's hot

NVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityNVIDIA's OpenGL Functionality
NVIDIA's OpenGL Functionality
Mark Kilgard
 
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
Unity Technologies
 
NVIDIA OpenGL and Vulkan Support for 2017
NVIDIA OpenGL and Vulkan Support for 2017NVIDIA OpenGL and Vulkan Support for 2017
NVIDIA OpenGL and Vulkan Support for 2017
Mark Kilgard
 
Concorrência e Paralelismo em Elixir (e outras linguagens)
Concorrência e Paralelismo em Elixir (e outras linguagens)Concorrência e Paralelismo em Elixir (e outras linguagens)
Concorrência e Paralelismo em Elixir (e outras linguagens)
Gustavo Chapim
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
Google
 
How to create a high quality, fast texture compressor using ISPC
How to create a high quality, fast texture compressor using ISPC How to create a high quality, fast texture compressor using ISPC
How to create a high quality, fast texture compressor using ISPC
Gael Hofemeier
 
Android - Application Framework
Android - Application FrameworkAndroid - Application Framework
Android - Application Framework
Yong Heui Cho
 
Approaching zero driver overhead
Approaching zero driver overheadApproaching zero driver overhead
Approaching zero driver overhead
Cass Everitt
 
OpenGL Basics
OpenGL BasicsOpenGL Basics
OpenGL Basics
Sandip Jadhav
 
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
OpenGL NVIDIA Command-List: Approaching Zero Driver OverheadOpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
Tristan Lorach
 
Android fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginnersAndroid fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginners
Boom Shukla
 
SIGGRAPH 2012: NVIDIA OpenGL for 2012
SIGGRAPH 2012: NVIDIA OpenGL for 2012SIGGRAPH 2012: NVIDIA OpenGL for 2012
SIGGRAPH 2012: NVIDIA OpenGL for 2012
Mark Kilgard
 
OpenGL ES and Mobile GPU
OpenGL ES and Mobile GPUOpenGL ES and Mobile GPU
OpenGL ES and Mobile GPU
Jiansong Chen
 
mysql-Tutorial with Query presentation.ppt
mysql-Tutorial with Query presentation.pptmysql-Tutorial with Query presentation.ppt
mysql-Tutorial with Query presentation.ppt
aptechaligarh
 
Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)
Khaled Anaqwa
 
Unity advanced computer graphics week 02
Unity advanced computer graphics week 02Unity advanced computer graphics week 02
Unity advanced computer graphics week 02
Tri Thanh
 
Sql lite android
Sql lite androidSql lite android
Sql lite android
Dushyant Nasit
 
GeoTools와 GeoServer를 이용한 KOPSS Open API의 구현
GeoTools와 GeoServer를 이용한 KOPSS Open API의 구현GeoTools와 GeoServer를 이용한 KOPSS Open API의 구현
GeoTools와 GeoServer를 이용한 KOPSS Open API의 구현
MinPa Lee
 
Seminar presentation on OpenGL
Seminar presentation on OpenGLSeminar presentation on OpenGL
Seminar presentation on OpenGL
Megha V
 
Introduction to Eclipse IDE
Introduction to Eclipse IDEIntroduction to Eclipse IDE
Introduction to Eclipse IDE
Muhammad Hafiz Hasan
 

What's hot (20)

NVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityNVIDIA's OpenGL Functionality
NVIDIA's OpenGL Functionality
 
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
 
NVIDIA OpenGL and Vulkan Support for 2017
NVIDIA OpenGL and Vulkan Support for 2017NVIDIA OpenGL and Vulkan Support for 2017
NVIDIA OpenGL and Vulkan Support for 2017
 
Concorrência e Paralelismo em Elixir (e outras linguagens)
Concorrência e Paralelismo em Elixir (e outras linguagens)Concorrência e Paralelismo em Elixir (e outras linguagens)
Concorrência e Paralelismo em Elixir (e outras linguagens)
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
 
How to create a high quality, fast texture compressor using ISPC
How to create a high quality, fast texture compressor using ISPC How to create a high quality, fast texture compressor using ISPC
How to create a high quality, fast texture compressor using ISPC
 
Android - Application Framework
Android - Application FrameworkAndroid - Application Framework
Android - Application Framework
 
Approaching zero driver overhead
Approaching zero driver overheadApproaching zero driver overhead
Approaching zero driver overhead
 
OpenGL Basics
OpenGL BasicsOpenGL Basics
OpenGL Basics
 
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
OpenGL NVIDIA Command-List: Approaching Zero Driver OverheadOpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
 
Android fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginnersAndroid fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginners
 
SIGGRAPH 2012: NVIDIA OpenGL for 2012
SIGGRAPH 2012: NVIDIA OpenGL for 2012SIGGRAPH 2012: NVIDIA OpenGL for 2012
SIGGRAPH 2012: NVIDIA OpenGL for 2012
 
OpenGL ES and Mobile GPU
OpenGL ES and Mobile GPUOpenGL ES and Mobile GPU
OpenGL ES and Mobile GPU
 
mysql-Tutorial with Query presentation.ppt
mysql-Tutorial with Query presentation.pptmysql-Tutorial with Query presentation.ppt
mysql-Tutorial with Query presentation.ppt
 
Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)
 
Unity advanced computer graphics week 02
Unity advanced computer graphics week 02Unity advanced computer graphics week 02
Unity advanced computer graphics week 02
 
Sql lite android
Sql lite androidSql lite android
Sql lite android
 
GeoTools와 GeoServer를 이용한 KOPSS Open API의 구현
GeoTools와 GeoServer를 이용한 KOPSS Open API의 구현GeoTools와 GeoServer를 이용한 KOPSS Open API의 구현
GeoTools와 GeoServer를 이용한 KOPSS Open API의 구현
 
Seminar presentation on OpenGL
Seminar presentation on OpenGLSeminar presentation on OpenGL
Seminar presentation on OpenGL
 
Introduction to Eclipse IDE
Introduction to Eclipse IDEIntroduction to Eclipse IDE
Introduction to Eclipse IDE
 

Viewers also liked

Open GL Tutorial06
Open GL Tutorial06Open GL Tutorial06
Open GL Tutorial06
Roziq Bahtiar
 
OpenGL L05-Texturing
OpenGL L05-TexturingOpenGL L05-Texturing
OpenGL L05-Texturing
Mohammad Shaker
 
OpenGL Starter L02
OpenGL Starter L02OpenGL Starter L02
OpenGL Starter L02
Mohammad Shaker
 
OpenGL L06-Performance
OpenGL L06-PerformanceOpenGL L06-Performance
OpenGL L06-Performance
Mohammad Shaker
 
OpenGL L02-Transformations
OpenGL L02-TransformationsOpenGL L02-Transformations
OpenGL L02-Transformations
Mohammad Shaker
 
OpenGL L03-Utilities
OpenGL L03-UtilitiesOpenGL L03-Utilities
OpenGL L03-Utilities
Mohammad Shaker
 
COMPUTER GRAPHICS DAY1
COMPUTER GRAPHICS DAY1COMPUTER GRAPHICS DAY1
COMPUTER GRAPHICS DAY1
Barnali Gupta Banik
 
OpenGL Starter L01
OpenGL Starter L01OpenGL Starter L01
OpenGL Starter L01
Mohammad Shaker
 
lecture3 color representation in computer graphics(Computer graphics tutorials)
lecture3 color representation in computer graphics(Computer graphics tutorials)lecture3 color representation in computer graphics(Computer graphics tutorials)
lecture3 color representation in computer graphics(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
Opengl basics
Opengl basicsOpengl basics
Opengl basics
pushpa latha
 
OpenGL L07-Skybox and Terrian
OpenGL L07-Skybox and TerrianOpenGL L07-Skybox and Terrian
OpenGL L07-Skybox and Terrian
Mohammad Shaker
 
OpenGL L01-Primitives
OpenGL L01-PrimitivesOpenGL L01-Primitives
OpenGL L01-Primitives
Mohammad Shaker
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Mohammad Shaker
 

Viewers also liked (14)

Open GL Tutorial06
Open GL Tutorial06Open GL Tutorial06
Open GL Tutorial06
 
OpenGL L05-Texturing
OpenGL L05-TexturingOpenGL L05-Texturing
OpenGL L05-Texturing
 
OpenGL Starter L02
OpenGL Starter L02OpenGL Starter L02
OpenGL Starter L02
 
Open GL Tutorial09
Open GL Tutorial09Open GL Tutorial09
Open GL Tutorial09
 
OpenGL L06-Performance
OpenGL L06-PerformanceOpenGL L06-Performance
OpenGL L06-Performance
 
OpenGL L02-Transformations
OpenGL L02-TransformationsOpenGL L02-Transformations
OpenGL L02-Transformations
 
OpenGL L03-Utilities
OpenGL L03-UtilitiesOpenGL L03-Utilities
OpenGL L03-Utilities
 
COMPUTER GRAPHICS DAY1
COMPUTER GRAPHICS DAY1COMPUTER GRAPHICS DAY1
COMPUTER GRAPHICS DAY1
 
OpenGL Starter L01
OpenGL Starter L01OpenGL Starter L01
OpenGL Starter L01
 
lecture3 color representation in computer graphics(Computer graphics tutorials)
lecture3 color representation in computer graphics(Computer graphics tutorials)lecture3 color representation in computer graphics(Computer graphics tutorials)
lecture3 color representation in computer graphics(Computer graphics tutorials)
 
Opengl basics
Opengl basicsOpengl basics
Opengl basics
 
OpenGL L07-Skybox and Terrian
OpenGL L07-Skybox and TerrianOpenGL L07-Skybox and Terrian
OpenGL L07-Skybox and Terrian
 
OpenGL L01-Primitives
OpenGL L01-PrimitivesOpenGL L01-Primitives
OpenGL L01-Primitives
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
 

Similar to OpenGL L04-Lighting

Lighting & Shading in OpenGL Non-Photorealistic Rendering.ppt
Lighting & Shading in OpenGL Non-Photorealistic Rendering.pptLighting & Shading in OpenGL Non-Photorealistic Rendering.ppt
Lighting & Shading in OpenGL Non-Photorealistic Rendering.ppt
CharlesMatu2
 
CS 354 Lighting
CS 354 LightingCS 354 Lighting
CS 354 Lighting
Mark Kilgard
 
Shading in OpenGL
Shading in OpenGLShading in OpenGL
Shading in OpenGL
Syed Zaid Irshad
 
Lighting
LightingLighting
Lighting and shading
Lighting and shadingLighting and shading
Lighting and shading
Sri Harsha Vemuri
 
Rendering basics
Rendering basicsRendering basics
Rendering basics
icedmaster
 
Phong Shading over any Polygonal Surface
Phong Shading over any Polygonal Surface Phong Shading over any Polygonal Surface
Phong Shading over any Polygonal Surface
Bhuvnesh Pratap
 
Open gl basics
Open gl basicsOpen gl basics
Open gl basics
saad siddiqui
 
10CSL67 CG LAB PROGRAM 7
10CSL67 CG LAB PROGRAM 710CSL67 CG LAB PROGRAM 7
10CSL67 CG LAB PROGRAM 7
Vanishree Arun
 
CS3241 Lab7
CS3241 Lab7CS3241 Lab7
CS3241 Lab7
Edison Tsui
 
Graphical Objects and Scene Graphs
Graphical Objects and Scene GraphsGraphical Objects and Scene Graphs
Graphical Objects and Scene Graphs
Syed Zaid Irshad
 
Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3
stevemcauley
 
september11.ppt
september11.pptseptember11.ppt
september11.ppt
CharlesMatu2
 
Light effect
Light effectLight effect
Light effect
Vanitha Chandru
 
Light and Shadows
Light and ShadowsLight and Shadows
Light and Shadows
Wolfgang Engel
 
illuminationmodelsshading-200501081735 (1).pdf
illuminationmodelsshading-200501081735 (1).pdfilluminationmodelsshading-200501081735 (1).pdf
illuminationmodelsshading-200501081735 (1).pdf
SayantanMajhi2
 
Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGL
Syed Zaid Irshad
 
Illumination Models & Shading
Illumination Models & ShadingIllumination Models & Shading
Goo Create - Material Fundamentals
Goo Create - Material FundamentalsGoo Create - Material Fundamentals
Goo Create - Material Fundamentals
Goo Technologies
 
3 D texturing
 3 D texturing 3 D texturing
3 D texturing
krishn verma
 

Similar to OpenGL L04-Lighting (20)

Lighting & Shading in OpenGL Non-Photorealistic Rendering.ppt
Lighting & Shading in OpenGL Non-Photorealistic Rendering.pptLighting & Shading in OpenGL Non-Photorealistic Rendering.ppt
Lighting & Shading in OpenGL Non-Photorealistic Rendering.ppt
 
CS 354 Lighting
CS 354 LightingCS 354 Lighting
CS 354 Lighting
 
Shading in OpenGL
Shading in OpenGLShading in OpenGL
Shading in OpenGL
 
Lighting
LightingLighting
Lighting
 
Lighting and shading
Lighting and shadingLighting and shading
Lighting and shading
 
Rendering basics
Rendering basicsRendering basics
Rendering basics
 
Phong Shading over any Polygonal Surface
Phong Shading over any Polygonal Surface Phong Shading over any Polygonal Surface
Phong Shading over any Polygonal Surface
 
Open gl basics
Open gl basicsOpen gl basics
Open gl basics
 
10CSL67 CG LAB PROGRAM 7
10CSL67 CG LAB PROGRAM 710CSL67 CG LAB PROGRAM 7
10CSL67 CG LAB PROGRAM 7
 
CS3241 Lab7
CS3241 Lab7CS3241 Lab7
CS3241 Lab7
 
Graphical Objects and Scene Graphs
Graphical Objects and Scene GraphsGraphical Objects and Scene Graphs
Graphical Objects and Scene Graphs
 
Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3
 
september11.ppt
september11.pptseptember11.ppt
september11.ppt
 
Light effect
Light effectLight effect
Light effect
 
Light and Shadows
Light and ShadowsLight and Shadows
Light and Shadows
 
illuminationmodelsshading-200501081735 (1).pdf
illuminationmodelsshading-200501081735 (1).pdfilluminationmodelsshading-200501081735 (1).pdf
illuminationmodelsshading-200501081735 (1).pdf
 
Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGL
 
Illumination Models & Shading
Illumination Models & ShadingIllumination Models & Shading
Illumination Models & Shading
 
Goo Create - Material Fundamentals
Goo Create - Material FundamentalsGoo Create - Material Fundamentals
Goo Create - Material Fundamentals
 
3 D texturing
 3 D texturing 3 D texturing
3 D texturing
 

More from Mohammad Shaker

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate
Mohammad Shaker
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with Psychology
Mohammad Shaker
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015
Mohammad Shaker
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game Development
Mohammad Shaker
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and Wearables
Mohammad Shaker
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - Color
Mohammad Shaker
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - Typography
Mohammad Shaker
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and Coupling
Mohammad Shaker
 
Android L05 - Storage
Android L05 - StorageAndroid L05 - Storage
Android L05 - Storage
Mohammad Shaker
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and Threading
Mohammad Shaker
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOS
Mohammad Shaker
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile Constraints
Mohammad Shaker
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and Grids
Mohammad Shaker
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and Gaming
Mohammad Shaker
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / Parse
Mohammad Shaker
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and Utilities
Mohammad Shaker
 
Android L03 - Styles and Themes
Android L03 - Styles and Themes Android L03 - Styles and Themes
Android L03 - Styles and Themes
Mohammad Shaker
 
Android L02 - Activities and Adapters
Android L02 - Activities and AdaptersAndroid L02 - Activities and Adapters
Android L02 - Activities and Adapters
Mohammad Shaker
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
Mohammad Shaker
 
Indie Series 03: Becoming an Indie
Indie Series 03: Becoming an IndieIndie Series 03: Becoming an Indie
Indie Series 03: Becoming an Indie
Mohammad Shaker
 

More from Mohammad Shaker (20)

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with Psychology
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game Development
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and Wearables
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - Color
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - Typography
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and Coupling
 
Android L05 - Storage
Android L05 - StorageAndroid L05 - Storage
Android L05 - Storage
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and Threading
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOS
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile Constraints
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and Grids
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and Gaming
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / Parse
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and Utilities
 
Android L03 - Styles and Themes
Android L03 - Styles and Themes Android L03 - Styles and Themes
Android L03 - Styles and Themes
 
Android L02 - Activities and Adapters
Android L02 - Activities and AdaptersAndroid L02 - Activities and Adapters
Android L02 - Activities and Adapters
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
 
Indie Series 03: Becoming an Indie
Indie Series 03: Becoming an IndieIndie Series 03: Becoming an Indie
Indie Series 03: Becoming an Indie
 

Recently uploaded

Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
YousufSait3
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.
AnkitaPandya11
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
ISH Technologies
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
Karya Keeper
 
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
kalichargn70th171
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 

Recently uploaded (20)

Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
 
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 

OpenGL L04-Lighting

  • 5. How We See Things?
  • 6. How We See Things?
  • 7. Light and Color Systems Additive Colors Subtractive Colors
  • 8. Colors in OpenGL • glColor3f(red, green, blue) [0,1] • glColor4f(red, green, blue, alpha) [0,1]
  • 9. Colors in OpenGL • glColor3f(red, green, blue) [0,1] • glColor4f(red, green, blue, alpha) [0,1] – alpha for transparency [0; full,1: no]
  • 10. Color Filling Mode • Filling Mode – glShadeModel(GL_FLAT); • Fill the polygon with solid color (the same as last vertex color) – glShadeModel(GL_SMOOTH); • Interpolate colors between polygon edges
  • 11. Light’s Type • DIFFUSE color's alpha value actually determines the transparency of the polygon Only ambient light only specular lightonly diffuse light
  • 12. The Modified Phong Model • Computes a color or shade for each vertex using a lighting model (the modified Phong model) that takes into account – Diffuse reflections – Specular reflections – Ambient light – Emission • Vertex shades are interpolated across polygons by the rasterizer
  • 13. Lighting - Types • Ambient Light: doesn’t come from any particular direction. It has an original source somewhere, but the rays of light have bounced around the room or scene and become directionless.
  • 14. Lighting - Types • Diffuse Light: The diffuse part of an OpenGL light is the directional component that appears to come from a particular direction and is reflected off a surface with an intensity proportional to the angle at which the light rays strike the surface. Thus, the object surface is brighter if the light is pointed directly at the surface than if the light grazes the surface from a greater angle.
  • 15. Lighting - Types • Specular light: Like diffuse light, specular light is a highly directional property, but it interacts more sharply with the surface and in a particular direction.
  • 16. The Modified Phong Model • The model is a balance between simple computation and physical realism • The model uses – Light positions and intensities – Surface orientation (normals) – Material properties (reflectivity) – Viewer location • Computed for each source and each color component
  • 17. Material Properties • Define the surface properties of a primitive • you can have separate materials for front and back Property Description Diffuse Base object color Specular Highlight color Ambient Low-light color Emission Glow color Shininess Surface smoothness
  • 18. Material Properties • Define the surface properties of a primitive • you can have separate materials for front and back Property Description GL_DIFFUSE Base color GL_SPECULAR Highlight Color GL_AMBIENT Low-light Color GL_EMISSION Glow Color GL_SHININESS Surface Smoothness
  • 22. Lighting in OpenGL Light Source and Object Material
  • 23. Lighting in OpenGL Light Source and Object Material
  • 24. Turning on the Lights • For any type of light, you should first – Flip each light’s switch glEnable(GL_LIGHT0); – Turn on the power glEnable(GL_LIGHTING);
  • 25. Lighting in OpenGL – Light Source • For the light source: – Set light properties: float Light_Ambient [ ] = {0.2,0.2,0.2,1}; float Light_Diffuse [ ] = {1,1,1,1}; float Light_Specular [ ] = {1,1,1,1}; float Light_Position [ ] = {0,0,20,0}; – Enable a specific light (GL_LIGHT0): glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); – Bind the light properties with the specific light (GL_LIGHT0): glLightfv(GL_LIGHT0 , GL_AMBIENT , Light_Ambient); glLightfv(GL_LIGHT0 , GL_DIFFUSE , Light_Diffuse); glLightfv(GL_LIGHT0 , GL_SPECULAR , Light_Specular); glLightfv(GL_LIGHT0 , GL_POSITION , Light_Position);
  • 26. Lighting in OpenGL – Object Material • For the object material: – Set material properties: float Cone_Ambient [ ] = {0.1,0.1,0.1,1}; float Cone_Diffuse [ ] = {0.2,0.1,0.9,1}; float Cone_Specular [ ] = {1,1,1,1}; float Cone_Shininess = 100; – Bind the material properties with a specific object: glMaterialfv(GL_FRONT_AND_BACK , GL_AMBIENT , Cone_Ambient); glMaterialfv(GL_FRONT_AND_BACK , GL_DIFFUSE , Cone_Diffuse); glMaterialfv(GL_FRONT_AND_BACK , GL_SPECULAR , Cone_Specular); glMaterialf (GL_FRONT_AND_BACK , GL_SHININESS , Cone_Shininess); • Now draw whatever you want. GLUquadric *quadric = gluNewQudric(); gluCylinder(quadric, 4, 1, 7, 32, 32);
  • 32. Why Normals are essential for lighting?
  • 33. Why Normals are essential for lighting?
  • 34. Normals for Lighting • Vertex Normals – Prefixed w/ “vn” (Wavefront) – Contains x,y,z of normal – Not necessarily unit length – Not necessarily in vertex order – Indexed as with vertices (x0,y0,z0) (a0,b0,c0) (u0,v0) (x1,y1,z1) (a1,b1,c1) (u1,v1) (x2,y2,z2) (a2,b2,c2) (u2,v2)
  • 35. Surface Normals • Normals define how a surface reflects light – Application usually provides normals as a vertex atttribute – Current normal is used to compute vertex’s color – Use unit normals for proper lighting • scaling affects a normal’s length
  • 40. Shadowing • How to make a shadow? – Draw the whole object again, projecting it on the shadow plane (the plane in which the shadow will appear)