Pencahayaan (Lighting) -...

34
Komputer Grafik 2 (AK045206) Pencahayaan (Lighting) Realisme dan Pencahayaan 1/34

Transcript of Pencahayaan (Lighting) -...

Page 1: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Pencahayaan (Lighting)

Realisme dan Pencahayaan 1/34

Page 2: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Outline

• Pengenalang

• Pengenalan Pencahayaan

• Sumber-sumber Cahaya : Ambient, langsung, titik, dll

• Hukum Cosinus Lambert/ difusi

• Model Phong• Model Phong

Realisme dan Pencahayaan 2/34

Page 3: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

IntroductionIntroduction

• Typical three-step yp pdevelopment process1.Understand the real system –

how does light work (Physics)how does light work (Physics)

2.Determine what matters to us –what can we sense (Psyc)

3 E i t th t i3.Engineer a system that remains true to the portion of reality we can appreciate

Realisme dan Pencahayaan 3/34

Page 4: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

S l i th Li hti P blSolving the Lighting Problem

– We somewhat understand the perception of light (color)perception of light (color)

– We engineered a solution to representing and generating

l i tcolor using computers

– We need to understand the interplay of light and objects

Realisme dan Pencahayaan 4/34

Page 5: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Optical Illusion

Realisme dan Pencahayaan 5/34

Page 6: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Li htiLighting

• Remember we know how to• Remember, we know how to rasterize– Given a 3-D triangle and a 3-D

viewpoint, we know which pixels represent the triangle

• But what color should thoseBut what color should those pixels be?

Realisme dan Pencahayaan 6/34

Page 7: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Lighting• If we’re attempting to create a p g

realistic image, we need to simulate the lighting of the surfaces in the scenesurfaces in the scene– Fundamentally simulation of

physics and optics

– As you’ll see, we use a lot of approximations (a.k.a perceptually based hacks) to do this simulation fast enough

Realisme dan Pencahayaan 7/34

Page 8: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Definitions

• Illumination: the transport of energy from light sources to surfaces & points– Note: includes direct and indirect

illumination

Images by Henrik Wann Jensen

Realisme dan Pencahayaan 8/34

Page 9: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Definitions

• Lighting: the process of computing the luminous intensity (i.e., outgoing light) at a particular 3-D point, usually p p , yon a surface

• Shading: the process of i i l t i lassigning colors to pixels

(why the distinction?)

Realisme dan Pencahayaan 9/34

Page 10: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Definitions

• Illumination models fall into two categories:– Empirical: simple formulations that

approximate observed phenomenon

– Physically based: models based on the actual physics of light interacting with matter

W tl i i l d l i• We mostly use empirical models in interactive graphics for simplicity

• Increasingly, realistic graphics are using physically based models

Realisme dan Pencahayaan 10/34

Page 11: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

C f Ill i iComponents of Illumination

• Two components of illumination: light d f tisources and surface properties

• Light sources (or emitters)– Spectrum of emittance (i.e., color of the

light)g )– Geometric attributes

• Position• Direction• Shape

– Directional attenuation– Polarization

Realisme dan Pencahayaan 11/34

Page 12: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Components of Illumination

• Surface propertiesp p– Reflectance spectrum (i.e., color of

the surface)

– Subsurface reflectance

– Geometric attributes• Position

• Orientation

• Micro-structure

Realisme dan Pencahayaan 12/34

Page 13: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Simplifications for Interactive Graphics

– Only direct illumination from emitters to surfaces

– Simplify geometry of emitters to trivial cases

Realisme dan Pencahayaan 13/34

Page 14: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

A bi t Li ht SAmbient Light Sources

• Objects not directly lit are typically still i iblvisible– e.g., the ceiling in this room, undersides of

desks

• This is the result of indirect illumination from emitters, bouncing off intermediate surfaces

• Too expensive to calculate (in real time), so we use a hack called an ambient light source– No spatial or directional characteristics;

illuminates all surfaces equally– Amount reflected depends on surface

properties

Realisme dan Pencahayaan 14/34

p p

Page 15: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Ambient Light Sources

• For each sampled wavelength p g(R, G, B), the ambient light reflected from a surface depends ondepends on– The surface properties, kambient

– The intensity, Iambient, of the ambient light source (constant for all points on all surfaces )

• Ireflected = kambient Iambientreflected ambient ambient

Realisme dan Pencahayaan 15/34

Page 16: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Ambient Light Sources

• A scene lit only with an yambient light source:

Light PositionNot ImportantNot Important

i i iViewer PositionNot Important

Surface AngleNot Important

Realisme dan Pencahayaan 16/34

Page 17: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Di i l Li h SDirectional Light Sources

• For a directional light source we make simplifying assumptions– Direction is constant for all surfaces in

the scene

– All rays of light from the source are parallel

• As if the source were infinitely far away from the surfaces in the scenefrom the surfaces in the scene

• A good approximation to sunlight

• The direction from a surface to the light source is important in lighting the surface

Realisme dan Pencahayaan 17/34

the surface

Page 18: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Directional Light SourcesDirectional Light Sources

• The same scene lit with a directional and an ambient light source

Light PositionNot Important

Surface AngleImportant

Viewer PositionNot Important

Important

p

Realisme dan Pencahayaan 18/34

Page 19: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Point Light Sources

• A point light source emits light p g gequally in all directions from a single point

Th di ti t th li ht f• The direction to the light from a point on a surface thus differs for different points:– So we need to calculate a

normalized vector to the light source for every point we light:y p g

p

l

Realisme dan Pencahayaan 19/34

p

Page 20: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

P i t Li ht SPoint Light Sources

• Using an ambient and a point g plight source:

Light PositionLight PositionImportant

Viewer PositionImportant

Surface AngleImportant

Realisme dan Pencahayaan 20/34

Page 21: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Oth Li ht SOther Light Sources

• Spotlights are point sources p g pwhose intensity falls off directionally.

Requires color point– Requires color, pointdirection, falloffparameters

S t d b O GL– Supported by OpenGL

Realisme dan Pencahayaan 21/34

Page 22: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Other Light Sources

• Area light sources define a 2-D gemissive surface (usually a

disc or polygon)Good example: fluorescent light– Good example: fluorescent light

panels

– Capable of generating soft h d ( h ? )shadows (why? )

Realisme dan Pencahayaan 22/34

Page 23: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

L b t’ C i LLambert’s Cosine Law

• Ideal diffuse surfaces reflect according to Lambert’s cosine law:

The energy reflected by a small portion of a surface from a light source in a given direction is proportional to the cosine of the angleis proportional to the cosine of the angle between that direction and the surface normal

• These are often called Lambertian surfacessurfaces

• Note that the reflected intensity is independent of the viewing direction but does depend on thedirection, but does depend on the surface orientation with regard to the light source

Realisme dan Pencahayaan 23/34

Page 24: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

L b t’ LLambert’s Law

Realisme dan Pencahayaan 24/34

Page 25: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

C ti Diff R fl tiComputing Diffuse Reflection

• The angle between the surface l d th i i li ht inormal and the incoming light is

the angle of incidence:nl

• Idiffuse = kd Ilight cos • In practice we use vector

ith tiarithmetic:

• Idiffuse = kd Ilight (n • l)

Realisme dan Pencahayaan 25/34

Page 26: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Diff Li hti E lDiffuse Lighting Examples

• We need only consider angles y gfrom 0° to 90° (Why?)

• A Lambertian sphere seen at l diff t li htiseveral different lighting

angles:

Realisme dan Pencahayaan 26/34

Page 27: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Ph Li htiPhong Lighting

• The most common lighting model g gin computer graphics was suggested by Phong:

shinynIkI

• The nshiny term is a purely

shinynlightsspecular IkI cos

shiny p yempirical constant that varies the rate of falloff

• Though this model has no

vThough this model has no physical basis, it works (sort of) in practice

Realisme dan Pencahayaan 27/34

Page 28: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Ph Li hti Th TPhong Lighting: The nshiny Term

• This diagram shows how the Phong reflectance term drops off with divergence of the viewing angle from the ideal reflected ray:

Vi i l fl t d l

• What does this term control, visually?

Viewing angle – reflected angle

Realisme dan Pencahayaan 28/34

y

Page 29: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Calculating Phong LightingCalculating Phong Lighting

• The cos term of Phong lighting can be computed using vector arithmetic:

shinynl hl rvIkI

– V is the unit vector towards the viewer

– R is the ideal reflectance direction

shinylightsspecular rvIkI

R is the ideal reflectance direction

• An aside: we can efficiently l l t ?

vcalculate r?

lnlnr 2

Realisme dan Pencahayaan 29/34

Page 30: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Calculating The R Vector

• This is illustrated below:

lnlnr 2

nlnlr 2

Realisme dan Pencahayaan 30/34

Page 31: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Phong Examples

• These spheres illustrate the pPhong model as l and nshiny are varied:

Realisme dan Pencahayaan 31/34

Page 32: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Th Ph Li hti M d lThe Phong Lighting Model

• Let’s combine ambient, diffuse, and specular components:

lights

nisidiambientatotal

shinyrvklnkIIkI#

• Commonly called Phong lighting

i

isidiambientatotal vklnkk1

– Note: once per light

– Note: once per color component

– Do ka, kd, and ks vary with color t?component?

Realisme dan Pencahayaan 32/34

Page 33: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

Phong Lighting: Intensity Plots

Realisme dan Pencahayaan 33/34

Page 34: Pencahayaan (Lighting) - Gunadarmakarmila.staff.gunadarma.ac.id/Downloads/files/37347/3.+Lighting.pdf · Komputer Grafik 2 (AK045206) Di i l Li h SDirectional Light Sources • For

Komputer Grafik 2 (AK045206)

R f iReferensi• 1: , 4:GraphicsSlides09.pdf , 5: , 8: ,

GlobalIllumination.ppt, localIllumination.ppt , 9:Lecture14

• Buku Teks : 1. F.S.Hill, Jr., COMPUTER GRAPHICS – Using Open GL, Second

Edition, Prentice Hall, 20012. Foley, van Dam, Feiner, Hughes, and Philips, Introduction to

Computer Graphics, Addison Wesley, 2000

• Lecture Notes / Slide-Presentation / Referensi lain yang diperoleh melalui internet :

3. Andries van Dam, Introduction to Computer Graphics, Slide-Presentation, Brown University, 2003, (folder : brownUni)

4. _______________, Interactive Computer Graphic, Slide-Presentation, (folder : Lect_IC_AC_UK)

5 ---------------------Michael McCool CS 488/688 :Introduction to5. Michael McCool, CS 488/688 :Introduction to Computer Graphics, Lecture Notes, University of Waterloo, 2003 (lecturenotes.pdf)

6. _______________, Computer Science 559, Slide-Presentation, Wisconsin University,(folder : Lect_Wisc_EDU)

7. http://graphics.lcs.mit.edu/classses/6.837/F98/Lecture4/Slide23.html , Slide-Presentation, MIT, (folder : MIT_CourseNote)

8 CS 319 : Advance Topic in Computer8. _______________, CS 319 : Advance Topic in Computer Graphics, Slide-Presentation, (folder : uiuc_cs)

9. _______________, CS 445/645 : Introduction to Computer Graphics, Slide-Presentation, (folder :COMP_GRAFIK)

10. Gladimir V.G. Baranoski, CS 488 : Introduction to Computer Graphics , Waterloo University

11. Prof. Peter Panfilov , http://cse yeditepe edu tr/~osertel/courses/CSE484/index html

Realisme dan Pencahayaan 34/34

http://cse.yeditepe.edu.tr/~osertel/courses/CSE484/index.html12. http://www.cl.cam.ac.uk/Teaching/1998/AGraphics/l3a.html