visual appearance chapter 4 tomas akenine-möller department of computer engineering chalmers...

17
Visual Appearance Visual Appearance Chapter 4 Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Upload: corey-fox

Post on 19-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Visual AppearanceVisual AppearanceChapter 4Chapter 4

Tomas Akenine-Möller

Department of Computer Engineering

Chalmers University of Technology

Page 2: Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Mőller © 2002

Overview of today’s lectureOverview of today’s lecture

Refresher on simple lighting models– Plus some new stuff

FogGamma correctionTransparency and alpha

Page 3: Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Mőller © 2002

Compute lighting at vertices,Compute lighting at vertices,then interpolate over trianglethen interpolate over triangle

How compute lighting? We could set colors per vertex manually For a little more realism, compute lighting from

– Light sources– Material properties– Geometrical relationships

light

Geometry

blue

red green

Rasterizer

Page 4: Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Mőller © 2002

Refresher on lightingRefresher on lightingDiffuse component : Diffuse component : iidiffdiff i=iamb+idiff+ispec

Diffuse is Lambert’s law: cos lndiffi

Photons are scattered equally in all directions

diffdiffdiff smlni )(

Page 5: Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Mőller © 2002

LightingLightingSpecular component : Specular component : iispecspec

Diffuse is dull (left)Specular: simulates a highlight

Page 6: Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Mőller © 2002

Specular component: PhongSpecular component: PhongPhong specular highlight modelReflect l around n:

l)n2(nlr

n

lr

-lnln )(

lnshishi mm

speci )(cos)( vr

specspecm

specshi smvri ))(,0max(

Read about Blinns highlight formula: (n.h)m

Page 7: Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Mőller © 2002

Ambient component: Ambient component: iiambamb

Ad-hoc – tries to account for light coming from other surfaces

Just add a constant color:

ambambamb smi

Page 8: Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Mőller © 2002

LightingLightingi=ii=iambamb+i+idiffdiff+i+ispecspec

This is just a hack!Has little to do with how reality works!

++

=

DEMO

Page 9: Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Mőller © 2002

Additions to the lighting equationAdditions to the lighting equationDepends on distance: 1/(a+bt+ct )Can have more lights: just sum their

respective contributionsDifferent light types:

2

Page 10: Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Mőller © 2002

What’s lighting andWhat’s lighting andwhat’s shading?what’s shading?Lighting: the interaction between light

and matterShading: do lighting (at vertices) and

determine pixel’s colors from theseThree types of shading:

– Flat, Goraud, and Phong

Page 11: Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Mőller © 2002

FogFog

Simple atmospheric effect– A little better realism – Help in determining distances

Color of fog: color of surface: fc sc

]1,0[ )1( fff ssp ccc How to compute f ? 3 ways: linear, exponential, exponential-squared Linear:

startend

pend

zz

zzf

Page 12: Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Mőller © 2002

Fog exampleFog example

Often just a matter of – Choosing fog color– Choosing fog model– Turning it on

Page 13: Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Mőller © 2002

Gamma correctionGamma correction

If input to gun is 0.5, then you don’t get 0.5 as output in intensity

Instead, gamma correct that signal: gives linear relationship

Page 14: Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Mőller © 2002

Gamma correctionGamma correction

I=intensity on screenV=input voltage (electron gun)a,and are constants for each systemCommon gamma values: 2.3-2.6Assuming =0, gamma correction is:

)( VaI

)/1( icc

Page 15: Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Mőller © 2002

Why is it important to care about Why is it important to care about gamma correction?gamma correction?

Portability across platforms Image quality

– Texturing– Interpolation

One solution is to put gamma correction in hardware…

Page 16: Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Mőller © 2002

Transparency and alphaTransparency and alpha

Transparency– Very simple in real-time contexts

The tool: alpha blending (mix two colors)Alpha () is another component in the

frame buffer, or on triangle– Represents the opacity – 1.0 is totally opaque– 0.0 is totally transparent

The over operator: dso ccc )1( Rendered object

Page 17: Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Mőller © 2002

TransparencyTransparency

Need to sort the transparent objects– Render back to front

Lots of different other blending modes

Can store RGB in textures as wellTwo ways:

– Unmultiplied– Premultiplied