Lighting and Normal Transformations in Computer Graphics, Slides of Computer Graphics

The concepts of vertex lighting and normal transformations in computer graphics. It discusses how each vertex goes through a lighting process to determine its final color, which is then interpolated across the triangle during scan conversion. The document also covers the importance of accurate measurement of distances and angles for lighting and the different options for lighting in 3d space. It also explains the need to transform normals by the inverse transpose of the matrix to maintain their perpendicularity to the transformed triangle.

Typology: Slides

2012/2013

Uploaded on 04/23/2013

sarasvan
sarasvan 🇮🇳

4.4

(20)

118 documents

1 / 44

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lighting
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c

Partial preview of the text

Download Lighting and Normal Transformations in Computer Graphics and more Slides Computer Graphics in PDF only on Docsity!

Lighting

Triangle Rendering^ „

The main stages in the

traditional graphics

pipeline

are:

„

Transform „

Lighting „

Clipping / Culling „

Scan Conversion „

Pixel Rendering

Lighting^ „

Today, we will mainly focus on vertex lighting „

Each vertex goes through a lighting process whichdetermines its final color „

This color value is then interpolated across the trianglein the scan conversion process „

Usually, each vertex has some sort of initial colorassigned to it, which defines what color it would be if welllit by a uniform white light „

This initial color is then modified based on the positionand normal of the vertex in relation to lights placed in thescene (in other words, a grey vertex dimly lit by red lightswill appear dark red…) „

In GL, you pass in the ‘unlit’ color through glColor3f(). Itwill then compute the ‘lit’ color, which gets interpolated inthe scan conversion process

Normal Transformations^ „^

Lighting requires accurate measurement of distances and angles, so wewant to compute lighting in a regular 3D space (i.e., not 4D un-normalizedview space, or 2.5D device space…) „^

This leaves object space, world space, or camera space as our mostnatural options „^

To light in object space, we would have to transform the lights from worldspace into each object’s space „^

If we are applying shears or non-uniform scales to our object, this will distortthe object which will mean that object space isn’t actually a legitimate placeto do lighting „^

Lighting in world space would be fine, but it would require transforming theobject into world space, which is a step that we usually avoid explicitlydoing „^

Therefore, it makes good sense to light in camera space, as we willprobably want to perform clipping & some culling in this space as well „^

GL does it’s lighting in camera space, which means that we must transformnormals into camera space in addition to the vertex positions

Direction Vector Transformation

z z z y z x z y z y y y x y x z x y x x x

x y z

z

z

z

z

y

y

y

y

x

x

x

x

c n b n a n n c n b n a n n c n b n a n n

n n n

d

c

b

a

d

c

b

a

d

c

b

a

0 1 0 0 0 n M n

Normal Transformations^ „

It’s actually worse than that… „

Let’s say we take the 3 vertices of a triangle andcompute the normal, then we transform the 3 verticesand the normal „

If the transformation contains any shear or non-uniformscaling, then it is possible that the transformed normalwill no longer be perpendicular to the transformedtriangle itself „

To fix this, we should actually transform the normal bythe

inverse transpose

of the matrix, or

M

-1T

„

The transformed normals will also not be unit length anymore, so they must also be renormalized before lighting

Normal Transformations^ „

If we want to compute lighting in camera space,we need to first transform the vertices & normalsinto camera space:

1

1 n n

n

n

M

n

v

M

v

W
C
M

− −

T

[^

]

(^

)

[^

]

(^

) 1 0 z

y

x

z

y

x

n

n

n

v

v

v = = v n

Lighting^ „

Whether we are computing lighting pervertex or lighting per pixel, the basicprocess is the same

„

In either case, we are computing thelighting at some position

v

with some

normal

n

Light Color^ „

However, if we are looking at a white piece ofpaper under uniform light, we can always turnmore lights on, and get more light to reflect off ofthe paper „

There is no upper limit to the intensity of light „

If we want to represent a light intensity (lightcolor), we can store it as red, green, and bluevalues ranging from 0.0 to an arbitrarily highvalue „

In other words, a bright white light bulb mighthave an color of (10, 10, 10)

Color & Intensity^ „

We need to make a distinction between material color and light color „^

Material colors represent the proportion of light reflected „^

Light colors represent the actual intensity of a beam of light „^

We never actually perceive the inherent material color, all we see isthe light reflected off of a material „^

If we shine a red light on a grey surface, the object appears dark redbecause it is reflecting beams of dark red light „^

I will use

m

to represent a material color and

c

to represent an

actual light color

Reflectivity^ „

A white sheet of paper might reflect 95% of thelight that shines on it „

An average mirror might reflect 95% of the lightthat shines on it „

Yet, these two things look completely different,because they reflect light in different directions „

We say that the paper is a

diffuse

reflector,

whereas the mirror is a

specular

reflector

Diffuse Reflection^ „

An

ideal diffuse reflector

will receive light from some

direction and bounce it uniformly in all directions „

Diffuse materials have a dull or matte appearance „

In the real world, materials will not match this behaviorperfectly, but might come reasonably close

Specular (Glossy) Reflection^ „

Sometimes, a material behaves in a specular way, butnot quite perfect like a mirror (like an unpolished metalsurface) „

In CG, this is sometimes referred to as

glossy

reflection

„

Glossy materials look shiny and will show

specular

highlights

Diffuse/Specular Reflection^ „

Many materials have a mixture of diffuse and specularbehavior „

Plastics are a common example of this, as they tend tohave an overall diffuse behavior, but still will catchhighlights