31
&,6 '5DVWHU*UDSKLFV Roger Crawfis Ohio State University 5HDOLVP7KURXJK6\QWKHVLV 3OD\*DPHV« *RDOVRI&RPSXWHU*UDSKLFV *HQHUDWHV\QWKHWLFLPDJHVWKDWORRNUHDO 'RLWLQDSUDFWLFDOZD\DQGVFLHQWLILFDOO\ VRXQG ,QUHDOWLPHREYLRXVO\ $QGPDNHLWORRNHDV\«

Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

�����

��

��

�� ������

�����

Rog

er C

raw

fis

Ohi

o St

ate

Uni

vers

ity

����������

�����

�����

����

����

�����

������������� ���������

�� � ��� ������� ������� ������������� ����

�������������������������������� �����������

������

����� ����� �������������� ����� ��������� ���!

Page 2: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Maj

or T

opic

s

❚"�� ����#�� � � ��������$ ���%�

� ���������� �� � � ���������

❚& �� ����#�������������� ��� ���� '

���������� ���

❚��� �������#������ �(�������� ���$ ������ �����

❚& ��')� #�� �� ��*�������+,-���� �(� �.

)� �/� �������0������& ����

Mod

elin

g

❚1������� � � ���� ��� ������ ���

❙� � ���#������ ��������� ������� �

❙���� ���#����������������� �� �����

❚1������� ������ � �� � � ��������

❙� �������� ��#������ ��������

❙��� ������ ��#���������

❙�������������#��� ����������+����������

��� �����(� � �����" ������� 2��������.

❙����,��� �����#������������

❙� ��3������ ��'��� ���������� ���*���������� ���

1������ ������

3�����

3������ �

"�� �����'� �������� ��

4�������

Page 3: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

�� ���������� ������

3������ ��5

"�� �����'3��� ������

& �� ����

❚6���7�������� 5

❙���������������������� � �������8��9���:

❚1������� �� � � ����������� ���� �

❙��� �����������9�2 ��:#��;2��<

❚1������� � ��� ���� �������� � �

❙����#��,��� �������������� � ���� ��

❙��$ �������� ��7���� �����

❙������������

=2�� �

Page 4: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Oth

er E

xam

ples

Out

line

•R

evie

w–

Tra

nsfo

rmat

ions

–O

penG

L

•Po

lygo

nal m

odel

s an

d m

odel

con

stru

ctio

n

•V

iew

ing

–Pr

ojec

tions

–C

lippi

ng

Out

line

•3D

pol

ygon

al r

ende

ring

–R

aste

riza

tion

–C

lippi

ng

–H

idde

n su

rfac

e de

term

inat

ion

•Sh

adow

s

•T

extu

re M

appi

ng

>�� ������� ��?�>4@

❚���ABC�D���������,�����������> ��E

❚���AFG�D&���)��������E����������������

❚���HF8�D�������������������� ���'����������4 �����)����

❚���FFG�'� � �����"�� ����

❚���ABC5�D4�� �������0������I�������+�������(4� �(�.

❚���ABC&�D ��������+3�� ��.

Page 5: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Cou

rse

Top

ics

•T

extu

re M

appi

ng–

Tex

ture

Par

amet

eriz

atio

n:

•M

appi

ng a

n im

age

to a

m

odel

–D

eter

min

ing

the

pixe

l va

lue

duri

ng s

can-

conv

ersi

on–

Avo

idin

g A

liasi

ng in

T

extu

re M

appi

ng

��� ���8--G

J�����8---

Quo

te (

CIS

681

and

782

)

“Now

whe

n I

pain

t, I

am a

ble

to s

ee th

e bi

ts a

nd th

e w

hole

at

the

sam

e tim

e, a

nd c

olor

s an

d sh

apes

pop

out

at m

e m

ore

read

ily. F

or e

xam

ple,

now

, ins

tead

of

seei

ng ju

st a

n ap

ple

insi

de a

bow

l, I

see

an a

pple

cat

chin

g th

e re

flec

tion

from

th

e bo

wl a

nd r

ecip

roca

lly th

e co

lor

of th

e ap

ple

tran

sfer

ring

ont

o th

e ce

ram

ic s

urfa

ce o

f th

e bo

wl.

The

bo

wl m

ust t

hen

have

a r

efle

ctiv

e su

rfac

e ca

ptur

ing

othe

r pa

rts

of th

e st

ill li

fe a

nd it

s sh

adow

on

the

whi

te c

loth

be

low

is n

ot g

ray

but i

s ac

tual

ly a

blu

ish

tinge

with

pur

ple

edge

s, a

nd s

o fo

rth.

”-

Ow

en D

emer

s[d

igit

al]

Tex

turi

ng &

Pai

ntin

g, 2

002

Quo

te

“I a

m in

tere

sted

in th

e ef

fect

s on

an

obje

ct th

at s

peak

of

hum

an in

terv

entio

n. T

his

is a

noth

er f

acto

r th

at y

ou m

ust

take

into

con

side

ratio

n. H

ow m

any

times

has

the

obje

ct

been

pai

nted

? W

ritte

n on

? T

reat

ed?

Bum

ped

into

? Sc

rape

d? T

his

is w

hen

thin

gs g

et e

xciti

ng. I

am

cur

ious

ab

out:

the

wea

ring

aw

ay o

f pa

int o

n st

eps

from

con

tinua

l us

e; s

crap

es m

ade

by a

mov

ing

dolly

alo

ng th

e ba

sebo

ard

of a

wal

l; ac

rylic

pai

nt p

eelin

g aw

ay f

rom

a p

revi

ous

coat

of

an

oil b

ase

pain

t; ci

gare

tte b

urns

on

tile

or w

ood

floo

rs;

chew

ing

gum

–th

e bl

ack

spot

s on

city

sid

ewal

ks; l

over

’s

nam

es a

nd in

itial

s sc

ratc

hed

onto

par

k be

nche

s…”

-O

wen

Dem

ers

[dig

ital]

Tex

turi

ng &

Pai

ntin

g, 2

002

Shad

ows

Page 6: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Ess

enti

al P

roce

ss

Um

bra

Pe

nu

mb

ra

Tex

ture

Map

ping

•W

hy u

se te

xtur

es?

Tex

ture

Map

ping

•M

odel

ing

com

plex

ity

����������

� ���

���

������

Page 7: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

)�������

) 2���

��������

���

��� ��������

������

��

)� �3���� ����0���������

E�����"�� �������� ��������'5

Mod

elin

g

•T

ypes

: –

Poly

gon

surf

aces

–C

urve

d su

rfac

es

•G

ener

atin

g m

odel

s:

–In

tera

ctiv

e

–Pr

oced

ural

Page 8: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Pol

ygon

Mes

h

•Se

t of

surf

ace

poly

gons

that

en

clos

e an

ob

ject

inte

rior

, po

lygo

n m

esh

•D

e fa

cto:

tr

iang

les,

tr

iang

le m

esh.

Rep

rese

ntin

g P

olyg

on M

esh

•V

erte

x co

ordi

nate

s lis

t, po

lygo

n ta

ble

and

(may

be)

edge

ta

ble

•A

uxili

ary:

–Pe

r ve

rtex

nor

mal

–N

eigh

borh

ood

info

rmat

ion,

ar

rang

ed w

ith r

egar

d to

ver

tices

and

edg

es

Arr

ivin

g at

a M

esh

•U

se p

atch

es m

odel

as

impl

icit

or p

aram

etri

c su

rfac

es

•B

ezié

rPa

tche

s : c

ontr

ol p

olyh

edro

n w

ith 1

6 po

ints

and

the

resu

lting

bic

ubic

patc

h:

Exa

mpl

e: T

he U

tah

Tea

pot

•32

pat

ches

sing

le s

hade

d pa

tch

wir

efra

me

of th

e co

ntro

l poi

nts

Patc

h ed

ges

Page 9: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Pat

ch R

epre

sent

atio

n vs

. Pol

ygon

Mes

h

•Po

lygo

ns a

re s

impl

e an

d fl

exib

le b

uild

ing

bloc

ks.

•B

ut, a

par

amet

ric

repr

esen

tatio

n ha

s ad

vant

ages

:

–C

onci

sene

ss•

A p

aram

etri

c re

pres

enta

tion

is e

xact

and

ana

lytic

al.

–D

efor

mat

ion

and

shap

e ch

ange

•D

efor

mat

ions

app

ear

smoo

th, w

hich

is n

ot g

ener

ally

th

e ca

se w

ith a

pol

ygon

al o

bjec

t.

Shap

e C

onst

ruct

ion

Ope

rati

ons

•E

xtru

de: a

dd a

hei

ght t

o a

flat

pol

ygon

•R

evol

ve: R

otat

e a

poly

gon

arou

nd a

cer

tain

axi

s

•Sw

eep :

sw

eep

a sh

ape

alon

g a

cert

ain

curv

e (a

ge

nera

lizat

ion

of th

e ab

ove

two)

•L

oft :

sha

pe f

rom

con

tour

s (u

sual

ly in

par

alle

l sl

ices

)

•Se

t ope

ratio

ns (

inte

rsec

tion,

uni

on, d

iffe

renc

e),

CSG

(con

stru

ctiv

e so

lid g

eom

etry

)

Swee

p (R

evol

ve a

nd E

xtru

de)

Con

stru

ctiv

e So

lid

Geo

met

ry

(CSG

)

•T

o co

mbi

ne th

e vo

lum

es o

ccup

ied

by o

verl

appi

ng 3

D

shap

es u

sing

set

ope

ratio

ns.

unio

nin

ters

ectio

ndi

ffer

ence

Page 10: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

A C

SG T

ree

Exa

mpl

e M

odel

ing

Pac

kage

: A

lias

Stu

dio

P

P

F

Pin

Hol

e M

odel

������

�����

�� �

����

� ��

����

�� �

�� ���

���

���

����

����

�� �

��

� �

����

����

���

���������� ���������

������������

���������

WO

RL

D

OB

JEC

TE

YE

Tra

nsfo

rmat

ions

•M

odel

ing

tran

sfor

mat

ions

•bu

ild c

ompl

ex m

odel

s by

pos

ition

ing

sim

ple

com

pone

nts

•V

iew

ing

tran

sfor

mat

ions

•pl

acin

g vi

rtua

l cam

era

in th

e w

orld

•tr

ansf

orm

atio

n fr

om w

orld

coo

rdin

ates

to

eye

coo

rdin

ates

•Si

de n

ote:

ani

mat

ion:

var

y tr

ansf

orm

atio

ns

over

tim

e to

cre

ate

mot

ion

Page 11: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Vie

win

g P

ipel

ine

•O

bjec

t sp

ace:

coor

dina

te s

pace

whe

re e

ach

com

pone

nt is

def

ined

•W

orld

spa

ce:

all c

ompo

nent

s pu

t tog

ethe

r in

to th

e sa

me

3D s

cene

vi

a af

fine

tran

sfor

mat

ion.

(ca

mer

a, li

ghtin

g de

fine

d in

this

spa

ce)

•E

ye s

pace

:ca

mer

a at

the

orig

in, v

iew

dir

ectio

n co

inci

des

with

the

z ax

is. H

ither

and

Yon

pla

nes

perp

endi

cula

r to

the

z ax

is•

Clip

ping

spa

ce:

do c

lippi

ng h

ere.

All

poin

ts a

re in

hom

ogen

eous

co

ordi

nate

s, i.

e., e

ach

poin

t is

repr

esen

ted

by (

x,y,

z,w

)•

3D im

age

spac

e(C

anon

ical

vie

w v

olum

e): a

par

alle

lpip

ied

shap

e de

fine

d by

(-1

:1,-

1:1,

0,1)

. Obj

ects

in th

is s

pace

are

dis

tort

ed•

Scre

en s

pace

:x

and

y sc

reen

pix

el c

oord

inat

es

Obj

ect

Spac

eW

orld

Sp

ace

Eye

Sp

ace

Clip

ping

Sp

ace

Can

onic

al

view

vol

ume

Scre

en

Spac

e

���

���

���

����

�����

���

!� ��

���

:

eye

3.

Mod

el->

Eye

Spa

ce

Cli

p an

d Im

age

Spac

es

•C

lip S

pace

•Im

age

Spac

e

1.2.

3.4.

5.6.

Page 12: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

2D T

rans

form

atio

n

•T

rans

latio

n

•R

otat

ion

Hom

ogen

eous

Coo

rdin

ates

•M

atri

x/V

ecto

r fo

rmat

for

tran

slat

ion:

Tra

nsla

tion

in H

omog

enou

s C

oord

inat

es

•T

here

exi

sts

an in

vers

e m

appi

ng fo

r ea

ch

func

tion

•T

here

exi

sts

an id

entit

y m

appi

ng

Why

thes

e pr

oper

ties

are

im

port

ant

•w

hen

thes

e co

nditi

ons

are

show

n fo

r an

y cl

ass

of

func

tions

it c

an b

e pr

oven

that

suc

h a

clas

s is

clo

sed

unde

r co

mpo

sitio

n•

i. e.

any

ser

ies

of tr

ansl

atio

ns c

an b

e co

mpo

sed

to a

sing

le tr

ansl

atio

n.

Page 13: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Rot

atio

n in

Hom

ogen

eous

Spa

ce

The

two

prop

ertie

s st

ill a

pply

.

Put

ting

Tra

nsla

tion

and

Rot

atio

n T

oget

her

•O

rder

mat

ters

!!

Aff

ine

Tra

nsfo

rmat

ion

•Pr

oper

ty: p

rese

rvin

g pa

ralle

l lin

es

•T

he c

oord

inat

es o

f th

ree

corr

espo

ndin

g po

ints

uni

quel

y de

term

ine

any

Aff

ine

Tra

nsfo

rm!!

Aff

ine

Tra

nsfo

rmat

ions

•T

rans

latio

n

•R

otat

ion

•Sc

alin

g

•Sh

eari

ng

T

Page 14: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

How

to d

eter

min

e an

Aff

ine

2D

Tra

nsfo

rmat

ion?

•W

e se

t up

6 lin

ear

equa

tions

in te

rms

of o

ur 6

un

know

ns. I

n th

is c

ase,

we

know

the

2D c

oord

inat

es

befo

re a

nd a

fter

the

map

ping

, and

we

wis

h to

sol

ve

for

the

6 en

trie

s in

the

affin

e tr

ansf

orm

mat

rix

Aff

ine

Tra

nsfo

rmat

ion

in 3

D

•T

rans

latio

n

•R

otat

e

•Sc

ale

•Sh

ear

Mor

e R

otat

ion

•W

hich

axi

s of

rot

atio

n?

Glo

bal D

efor

mat

ions

•T

aper

•T

wis

t

•B

end

Page 15: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Glo

bal D

efor

mat

ions

•T

aper

ing:

r =

f(z)

x =

r*x

y =

r*y

z =

z

Glo

bal D

efor

mat

ions

•T

wis

ting:

θ=

f(z)

x =

x*c

osθ

-y*

sin

θy

= x

*sin

θ+

y*c

osθ

z =

z

Glo

bal D

efor

mat

ions

•B

endi

ng:

–M

ore

gene

ral,

bend

abo

ut s

ome

axis

.

Vie

win

g

•Pl

acin

g ob

ject

s in

Wor

ld s

pace

: aff

ine

tran

sfor

mat

ions

•W

orld

spa

ce to

Eye

spa

ce: ?

??

•E

ye s

pace

to C

lippi

ng s

pace

: inv

olve

s pr

ojec

tion

and

view

ing

frus

tum

Page 16: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

����

�������

����

����

� ��

� �

���

���

���

����

� ��

����

���

��

�����

��"�

��������

�"��

�����

�����

��

���

� ��

����

�"�� �������

�"��

���

�� �����

#���

�� ��

����

$�

%�

�����

�" �

��� &

F

Imag

e

Wor

ldI

W

������

���

����

F

Imag

e

Wor

ld

���

� ��

��"�

��� �

����

� ��

����

���

���

��

�" �

���

����

��

���

� ��

��

��

���

����

"�� ��

���

���

���

���

��������

����

���

������

�$�

�������

�����

$�����

���

��

��

����

�� �����

����"������

�� ��

�" �

���

Imag

e

Wor

ld

F

���

������

Page 17: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

���

���

����

�������

��

���

���

� ��

���'�

���

�"�

�����

�$�

�������

����� �

��"��

���

�" �

��� ��

����

�� ���

����

��� �

������

��

Y

Z

[0, d

][0

, 0]

[Y, Z

]

[(d

/Z)Y

, d]

Sim

ilar

Tri

angl

es

����

��������

������

������

����

����

����

����(����"�

����

�)�

*�*+

,���

� ��

���

)#�

-+&�

*#�

-+&�

*�,

���

������ �

�����

���

��������� ���� ����������

����

��

.�����$

���

)�*�*+,

��)#�

-+&�

*#�

-+&�

*�,

d0

00

0d

00

00

d0

00

10

x y z 1

=dx

dydz

z[

]⇒d z

xd z

yd

Div

ide

by 4

th c

oord

inat

e(t

he “

w”

coor

dina

te)

Imag

e Sp

ace

�/�0

��

�" �

���

� �

�����

��������

����

����

������

��

�����

�����$

���

��������

���

���

������

����

���

���

����

Page 18: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

•D

efin

es v

isib

le r

egio

n of

spa

ce, p

yram

id e

dges

are

clip

ping

pla

nes

•F

rust

um :t

runc

ated

pyr

amid

with

nea

r an

d fa

r cl

ippi

ng p

lane

s

–N

ear

(Hith

er)

plan

e ?

Don

’t c

are

abou

t beh

ind

the

cam

era

–Fa

r (Y

on)

plan

e, d

efin

e fi

eld

of in

tere

st, a

llow

s z

to b

e sc

aled

to a

lim

ited

fixe

d-po

int v

alue

for

z-b

uffe

ring

.

Vie

w V

olum

eD

iffi

cult

y

•It

is d

iffi

cult

to d

o cl

ippi

ng d

irec

tly in

the

view

ing

frus

tum

Can

onic

al V

iew

Vol

ume

•N

orm

aliz

e th

e vi

ewin

g fr

ustu

m to

a c

ube,

can

onic

al v

iew

vo

lum

e

•C

onve

rts

pers

pect

ive

frus

tum

to o

rtho

grap

hic

frus

tum

–pe

rspe

ctiv

e tr

ansf

orm

atio

n

Per

spec

tive

Tra

nsfo

rm

•T

he e

quat

ions

alph

a =

hith

er/(

yon-

hith

er)

beta

= y

on*h

ither

/(hi

ther

-yo

n)

s: s

ize

of w

indo

w o

n th

e im

age

plan

e

z

z’

1al

pha

yon

hith

er

Page 19: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Abo

ut P

ersp

ecti

ve T

rans

form

•So

me

prop

ertie

s

Abo

ut P

ersp

ecti

ve T

rans

form

•C

lippi

ng c

an b

e pe

rfor

med

aga

inst

the

rect

iline

ar b

ox

•Pl

anar

ity a

nd li

near

ity a

re p

rese

rved

•A

ngle

s an

d di

stan

ces

are

not p

rese

rved

•Si

de e

ffec

ts: o

bjec

ts b

ehin

d th

e ob

serv

er a

re

map

ped

to th

e fr

ont.

Per

spec

tive

+ P

roje

ctio

n M

atri

x

•A

R: a

spec

t rat

io c

orre

ctio

n, R

esX

/Res

Y

•s=

Res

X,

•T

heta

: hal

f vi

ew a

ngle

, tan

(the

ta)

= s

/d

10

00

00

0

00

tan

tan

00

tan

0

AR

θθ

βθ

=

eye

coi

ρ

hith

eryo

n

Cam

era

Con

trol

and

Vie

win

g

•Fo

cal l

engt

h (d

), im

age

size

/sha

pe a

nd c

lippi

ng p

lane

s in

clud

ed

in p

ersp

ectiv

e tr

ansf

orm

atio

n

–ρ

-A

ngle

or

Fiel

d of

vie

w (

FOV

) –

AR

-A

spec

t Rat

io o

f vi

ew-p

ort

–H

ither

, Yon

-N

eare

st a

nd f

arth

est v

isio

n lim

its (

WS)

.–

Loo

kat –

CO

I–

Loo

kfro

m –

Eye

poi

nt–

Vie

w a

ngle

–Fi

eld-

of-v

iew

Page 20: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Com

plet

e P

ersp

ecti

ve

•Sp

ecif

y ne

ar a

nd f

ar c

lippi

ng p

lane

s -

tran

sfor

m z

betw

een

znea

ran

dzf

aron

to a

fi

xed

rang

e•

Spec

ify

fiel

d-of

-vie

w (

fov)

ang

le•

Ope

nGL

’s g

lFru

stum

and

gluP

ersp

ecti

vedo

th

ese

Mor

e V

iew

ing

Par

amet

ers

Cam

era,

Eye

or

Obs

erve

r:lo

okfr

om:

loca

tion

of f

ocal

poi

nt o

r ca

mer

alo

okat

:po

int t

o be

cen

tere

d in

imag

e

Cam

era

orie

ntat

ion

abou

t the

look

at-l

ookf

rom

axis

vup:

a ve

ctor

that

is p

oint

ing

stra

ight

up

in

the

imag

e. T

his

is li

ke a

n or

ient

atio

n.

Impl

emen

tati

on …

Ful

l Blo

wn

•T

rans

late

by

-loo

kfro

m, b

ring

foc

al p

oint

to o

rigi

n•

Rot

ate

look

at-l

ookf

rom

to th

e z -

axis

with

mat

rix

R:

•v

= (

look

at-l

ookf

rom

) (n

orm

aliz

ed)

and

z=

[0,

0,1]

•ro

tatio

n ax

is:

a=

(vx

z)/| v

xz|

•ro

tatio

n an

gle:

cos θ

= a

• zan

d si

n θ =

| rxz

|

•O

penG

L: g

lRot

ate(

θ, a

x, a

y,a z

)•

Rot

ate

abou

t z- a

xis

to g

etvu

ppa

ralle

l to

the

y-ax

is

Vie

wpo

rt m

appi

ng

•C

hang

e fr

om th

e im

age

coor

dina

te s

yste

m (

x,y,

z)

to th

e sc

reen

coo

rdin

ate

syst

em (

X,Y

).

•Sc

reen

coo

rdin

ates

are

alw

ays

non-

nega

tive

inte

gers

.

•L

et (

v r,v

t) be

the

uppe

r-ri

ght c

orne

r an

d (v

l,vb)

be

the

low

er-l

eft c

orne

r.

•X

= x

* (

v r-v

l) /2

+ (v

r+v l

)/2

•Y

= y

* (

v t-v

b)/2

+ (v

t+v b

)/2

Page 21: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Tru

e O

r F

alse

•In

per

spec

tive

tran

sfor

mat

ion

para

llelis

m is

no

t pre

serv

ed.

–Pa

ralle

l lin

es c

onve

rge

–O

bjec

t siz

e is

red

uced

by

incr

easi

ng d

ista

nce

from

cen

ter

of

proj

ectio

n–

Non

-uni

form

for

esho

rten

ing

of li

nes

in th

e ob

ject

as

a fu

nctio

n of

ori

enta

tion

and

dist

ance

fro

m c

ente

r of

pro

ject

ion

–A

id th

e de

pth

perc

eptio

n of

hum

an v

isio

n, b

ut s

hape

is n

ot

pres

erve

d

Tru

e O

r F

alse

•A

ffin

e tr

ansf

orm

atio

n is

a c

ombi

natio

n of

lin

ear

tran

sfor

mat

ions

•T

he la

st c

olum

n/ro

w in

the

gene

ral 4

x4

affi

ne tr

ansf

orm

atio

n m

atri

x is

[0

0 0

1]T.

•A

fter

aff

ine

tran

sfor

m, t

he h

omog

eneo

us

coor

dina

te w

mai

ntai

ns u

nity

.

Intr

oduc

tion

to O

penG

L

Rog

er C

raw

fis

Thi

s se

t of

slid

es a

re f

rom

Jia

nH

uang

and

are

bas

ed u

pon

the

slid

es f

rom

th

e In

tera

ctiv

e O

penG

L P

rogr

amm

ing

cour

se g

iven

by

Dav

e Sh

rein

e, E

d A

ngel

and

Vic

ki S

hrei

ner

on S

IGG

RA

PH

200

1.

Ope

nGL

an G

LUT

Ove

rvie

w

•W

hat i

s O

penG

L &

wha

t can

it d

o fo

r m

e?•

Ope

nGL

in w

indo

win

g sy

stem

s•

Why

GLU

T•

GLU

T p

rogr

am te

mpl

ate

Page 22: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Wha

t Is

Ope

nGL?

•G

raph

ics

rend

erin

g A

PI

–hi

gh-q

ualit

y co

lor

imag

es c

ompo

sed

of

geom

etric

and

imag

e pr

imiti

ves

–w

indo

w s

yste

m in

depe

nden

t

–op

erat

ing

syst

em in

depe

nden

t

Ope

nGL

Arc

hite

ctur

e

Ope

nGL

as a

Ren

dere

r

•G

eom

etric

prim

itive

s–

poin

ts, l

ines

and

pol

ygon

s–

Imag

e P

rimiti

ves

–im

ages

and

bitm

aps

•se

para

te p

ipel

ine

for

imag

es a

nd g

eom

etry

–lin

ked

thro

ugh

text

ure

map

ping

•R

ende

ring

depe

nds

on s

tate

–co

lors

, mat

eria

ls, l

ight

sou

rces

, etc

.

Rel

ated

AP

Is

•A

GL,

GLX

, WG

L–

glue

bet

wee

n O

penG

L a

nd w

indo

win

g sy

stem

s

•G

LU (

Ope

nGL

Util

ity L

ibra

ry)

–pa

rt o

f Ope

nGL

–N

UR

BS

,tes

sella

tors

, qua

dric

sha

pes,

etc

•G

LUT

(O

penG

L U

tility

Too

lkit)

–po

rtab

le w

indo

win

g A

PI

–no

t offi

cial

ly p

art o

f Ope

nGL

Page 23: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Ope

nGL

and

Rel

ated

AP

IsP

relim

inar

ies

•H

eade

r F

iles

–#i

nclu

de <

GL

gl.h

>–

#inc

lude

<G

Lgl

u.h>

–#i

nclu

de <

GL

glut

.h>

•Li

brar

ies

•E

num

erat

edty

pes

•O

penG

L de

fines

num

erou

s ty

pes

for

com

patib

ility

–G

Lflo

at,G

Lint

,GLe

num

, etc

.

GLU

T B

asic

s

•A

pplic

atio

n S

truc

ture

•C

onfig

ure

and

open

win

dow

•In

itial

ize

Ope

nGL

stat

e

•R

egis

ter

inpu

t cal

lbac

k fu

nctio

ns–

rend

er–

resi

ze–

inpu

t: ke

yboa

rd, m

ouse

, etc

.

•E

nter

eve

nt p

roce

ssin

g lo

op

Sam

ple

Pro

gram

void

mai

n(in

t ar

gc, c

har*

*ar

gv)

{gl

utIn

itD

ispl

ayM

ode(

GL

UT

_RG

B |

GL

UT

_DO

UB

LE

);

glut

Cre

ateW

indo

w(

“Sim

ple

Ope

nGL

Pro

gram

” );

my_

init

();

// in

itia

te O

penG

L s

tate

s, p

rogr

am v

aria

bles

glut

Dis

play

Fun

c( m

y_di

spla

y );

// r

egis

ter

callb

ack

rout

ines

glut

Res

hape

Fun

c( m

y_re

size

);

glut

Key

boar

dFun

c( m

y_ke

y_ev

ents

);gl

utId

leF

unc(

my_

idle

_fun

c);

glut

Mai

nLoo

p();

// e

nter

the

eve

nt-d

rive

n lo

op

}

Page 24: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Ope

nGL

Initi

aliz

atio

n

•S

et u

p w

hate

ver

stat

eyo

u’re

goi

ng to

use

void

my_

init

( vo

id )

{gl

Cle

arC

olor

( 0.

0, 0

.0, 0

.0, 1

.0 );

glC

lear

Dep

th(

1.0

);gl

Ena

ble(

GL

_LIG

HT

0 );

glE

nabl

e( G

L_L

IGH

TIN

G );

glE

nabl

e( G

L_D

EP

TH

_TE

ST )

;

}

GLU

T C

allb

ack

Fun

ctio

ns

•R

outin

e to

cal

l whe

n so

met

hing

hap

pens

–w

indo

w r

esiz

e or

red

raw

–us

er in

put

–an

imat

ion

•“R

egis

ter”

cal

lbac

ks w

ith G

LU–

glut

Dis

play

Fun

c( m

y_di

spla

y );

–gl

utId

leF

unc(

my_

idle

_fun

c);

–gl

utK

eybo

ardF

unc(

my_

key_

even

ts )

;

Ren

derin

g C

allb

ack

•D

o al

l of

our

draw

ing

here

glut

Dis

play

Fun

c( m

y_di

spla

y );

void

my_

disp

lay(

voi

d )

{gl

Cle

ar(

GL

_CO

LO

R_B

UF

FE

R_B

IT )

;gl

Beg

in( G

L_T

RIA

NG

LE

);gl

Ver

tex3

fv(

v[0]

);

glV

erte

x3fv

( v[

1] )

;gl

Ver

tex3

fv(

v[2]

);

glE

nd()

;gl

utSw

apB

uffe

rs()

;

}

Idle

Cal

lbac

ks

•U

sed

for

anim

atio

n, g

ame

AI a

nd o

ther

co

ntin

uous

upd

ates

glut

Idle

Fun

c( m

y_id

le_f

unc

);

void

my_

idle

_fun

c(

void

)

{if

( ro

tate

) t

heta

+=d

t;gl

utP

ostR

edis

play

();

}

Page 25: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Use

r In

put C

allb

acks

•P

roce

ss u

ser

inpu

tgl

utK

eybo

ardF

unc(

my_

key_

even

ts )

;vo

id m

y_ke

y_ev

ents

( c

har

key,

int

x,in

ty

){

swit

ch(

key

) {

case

‘q’

: c

ase

‘Q’

:ex

it(

EX

IT_S

UC

CE

SS )

;br

eak;

case

‘r’

: c

ase

‘R’

:ro

tate

= G

L_T

RU

E;

brea

k;}

}

Ele

men

tary

Ren

derin

g

•G

eom

etric

Prim

itive

s•

Man

agin

g O

penG

L S

tate

•O

penG

L B

uffe

rs

Ope

nGL

Geo

met

ric P

rimiti

ves

•A

ll ge

omet

ric p

rimiti

ves

are

spec

ified

by

vert

ices

Sim

ple

Exa

mpl

e

void

dra

wR

hom

bus(

GL

floa

tco

lor[

] )

{gl

Beg

in(

GL

_QU

AD

S );

glC

olor

3fv(

col

or );

glV

erte

x2f(

0.0

, 0.0

);gl

Ver

tex2

f( 1

.0, 0

.0 );

glV

erte

x2f(

1.5

, 1.1

18 )

;gl

Ver

tex2

f( 0

.5, 1

.118

);

glE

nd()

;

}

Page 26: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Ope

nGL

Com

man

d F

orm

ats

Spe

cify

ing

Geo

met

ric

Prim

itive

s

•P

rimiti

ves

are

spec

ified

usi

nggl

Beg

in(

prim

Typ

e);

glE

nd()

;

•pr

imT

ype

dete

rmin

es h

owve

rtic

es a

re c

ombi

ned

GL

floa

tre

d, g

reed

, blu

e;G

lflo

at c

oord

s[3]

;gl

Beg

in(

prim

Typ

e);

for

( i =

0; i

<nV

erts

; i+

+ )

{gl

Col

or3f

( re

d, g

reen

, blu

e );

glV

erte

x3fv

(co

ords

);}

glE

nd()

;

Ope

nGL

Col

or M

odel

•B

oth

RG

BA

(tr

ue c

olor

) an

d C

olor

Ind

ex

Con

trol

ling

Ren

derin

g

•A

ppea

ranc

e•

Fro

mW

irefr

ame

to T

extu

re m

appe

d

Page 27: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Ope

nGL’

s S

tate

Mac

hine

•A

ll re

nder

ing

attr

ibut

es a

re

enca

psul

ated

in th

e O

penG

L S

tate

–re

nder

ing

styl

es

–sh

adin

g–

light

ing

–te

xtur

e m

appi

ng

Man

ipul

atin

g O

penG

L S

tate

•A

ppea

ranc

e is

con

trol

led

by c

urre

nt s

tate

for

each

( p

rimiti

ve to

ren

der

) {

up

dat

e O

pen

GL

sta

tere

nd

er p

rim

itiv

e

}

•m

anip

ulat

ing

vert

ex a

ttrib

utes

is m

ost

com

mon

way

to m

anip

ulat

e st

ate

–gl

Col

or*(

) /g

lInd

ex*(

)–

glN

orm

al*(

)–

glT

exC

oord

*()

Con

trol

ling

curr

ent s

tate

•S

ettin

g S

tate

glP

oint

Size

( si

ze )

;

glL

ineS

tipp

le(

repe

at, p

atte

rn )

;

glSh

adeM

odel

( G

L_

SMO

OT

H )

;

•E

nabl

ing

Fea

ture

sgl

Ena

ble(

GL

_ L

IGH

TIN

G )

;

glD

isab

le(

GL

_TE

XT

UR

E_2

D )

;

Tra

nsfo

rmat

ions

in O

penG

L

•M

odel

ing

•V

iew

ing

–or

ient

cam

era

–pr

ojec

tion

•A

nim

atio

n•

Map

to s

cree

n

Page 28: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Coo

rdin

ate

Sys

tem

s an

d

Tra

nsfo

rmat

ions

•S

teps

in F

orm

ing

an Im

age

–sp

ecify

geo

met

ry (

wor

ld c

oord

inat

es)

–sp

ecify

cam

era

(cam

era

coor

dina

tes)

–pr

ojec

t (w

indo

w c

oord

inat

es)

–m

ap to

view

port

(scr

een

coor

dina

tes)

•E

ach

step

use

s tr

ansf

orm

atio

ns•

Eve

ry tr

ansf

orm

atio

n is

equ

ival

ent t

o a

chan

ge in

coo

rdin

ate

syst

ems

3D T

rans

form

atio

ns

���������������� ��

�������������

�����

�������� ����� �������

������

���������� �

�����������

� ����� ������

� ��������

������������������ ������������

��������������� ���������������� ������

���������������������������������������������

�����������!

Spe

cify

ing

Tra

nsfo

rmat

ions

•P

rogr

amm

er h

as tw

o st

yles

of s

peci

fyin

g tr

ansf

orm

atio

ns–

spec

ify m

atric

es g

lLoa

dMat

rix,

glM

ultM

atri

x–

spec

ify o

pera

tions

glR

otat

e, g

lOrt

h o

•P

rogr

amm

er d

oes

not h

ave

to r

emem

ber

the

ex

act m

atric

es

•C

heck

App

endi

x of

the

Red

Boo

k

Pro

gram

min

g T

rans

form

atio

ns

•P

rior

to r

ende

ring,

vie

w, l

ocat

e, a

nd o

rient

:–

eye/

cam

era

posi

tion

–3D

geo

met

ry

•M

anag

e th

e m

atric

es–

incl

udin

g m

atrix

sta

ck

•C

ombi

ne (

com

posi

te)

tran

sfor

mat

ions

•T

rans

form

atio

n m

atri

ces

are

part

of

the

stat

e, th

ey m

ust b

e de

fine

d pr

ior

to a

ny v

ertic

es to

whi

ch th

ey a

re to

app

ly.

•O

penG

L p

rovi

des

mat

rix

stac

ks f

or e

ach

type

of

supp

orte

d m

atri

x (M

odel

Vie

w, p

roje

ctio

n, te

xtur

e) to

sto

re m

atri

ces.

Page 29: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Tra

nsfo

rmat

ion

Pip

elin

eM

atrix

Ope

ratio

ns

•S

peci

fy C

urre

nt M

atrix

Sta

ck–

glM

atri

xMod

e( G

L_M

OD

EL

VIE

W o

r G

L_P

RO

JEC

TIO

N )

•O

ther

Mat

rix o

r S

tack

Ope

ratio

n–

glL

oadI

dent

ity(

)gl

Pus

hMat

rix(

)gl

Pop

Mat

rix(

)

•V

iew

port

–us

ually

sam

e as

win

dow

siz

e–

view

port

aspe

ct r

atio

sho

uld

be

sam

e as

pr

ojec

tion

tran

sfor

mat

ion

or r

esul

ting

imag

e m

ay

be d

isto

rted

–gl

Vie

wpo

rt(

x, y

, wid

th, h

eigh

t )

Pro

ject

ion

Tra

nsfo

rmat

ion

•P

ersp

ectiv

e pr

ojec

tion

–gl

uPer

spec

tive

(fo

vy, a

spec

t,zN

ear,

zFar

)–

glF

rust

um(

left

, rig

ht, b

otto

m, t

op,z

Nea

r,zF

ar)

(ver

y ra

rely

use

d)

•O

rtho

grap

hic

para

llel p

roje

ctio

n–

glO

rtho

( le

ft, r

ight

, bot

tom

, top

,zN

ear,

zFar

)–

gluO

rtho

2D(

left

, rig

ht, b

otto

m, t

op )

–ca

lls g

lOrt

how

ith z

val

ues

near

zer

o

•W

arni

ng:

forgluPerspective()

orglFrustum(

), d

on’t

use

zer

o fo

r zNea

r!

App

lyin

g P

roje

ctio

n

•T

rans

form

atio

ns•

Typ

ical

use

( o

rtho

grap

hic

proj

ectio

n)gl

Mat

rixM

ode(

GL

_PR

OJE

CT

ION

);gl

Loa

dIde

ntit

y();

glO

rtho

( le

ft, r

ight

, bot

tom

, top

,zN

ear,

zFar

);

Page 30: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

Vie

win

g T

rans

form

atio

ns

•P

ositi

on th

e ca

mea

/eye

in th

e sc

ene

•T

o “f

ly th

roug

h” a

sce

ne•

chan

ge v

iew

ing

tran

sfor

mat

ion

and

redr

aw

scen

egl

uLoo

kAt(

eye

x ,e

ye y

,eye

z ,

aim

x ,a

im y

,aim

z ,

up x

,up

y ,u

p z

)

•up

vec

tor

dete

rmin

es u

niqu

e or

ient

atio

n•

care

ful o

f deg

ener

ate

posi

tions

Mod

elin

g T

rans

form

atio

ns

•M

ove

obje

ct–

glT

rans

late

{fd}

( x,

y, z

)

•R

otat

e ob

ject

aro

ndar

bitr

ary

axis

–gl

Rot

ate{

fd}(

ang

le, x

, y, z

)

–an

gle

is in

deg

rees

•D

ilate

(st

retc

h or

shr

ink)

obj

ect

–gl

Scal

e{fd

}( x

, y, z

)

Pro

ject

ion

is le

ft ha

nded

•P

roje

ctio

n tr

ansf

orm

atio

n (

gluP

ersp

ecti

ve,

glO

rth o

) ar

e le

ft ha

nded

–th

ink

of

zNea

ran

d z

Far

as d

ista

nce

from

vie

w

poin

t

•E

very

thin

g el

se is

rig

ht h

ande

d, in

clud

ing

the

vert

exes

to

be r

ende

red

Com

mon

Tra

nsfo

rmat

ion

Usa

ge

•E

xam

ple

of r

esiz

e()

rout

ine

–re

stat

e pr

ojec

tion

& v

iew

ing

tran

sfor

mat

ions

•U

sual

ly c

alle

d w

hen

win

dow

res

ized

•R

egis

tere

d a

cal

lbac

k fo

rgl

utR

esha

peF

unc(

)

Page 31: Computer Science and Engineeringweb.cse.ohio-state.edu/~crawfis.3/cis781/Slides/CIS... · 2002. 8. 23. · Course Topics • Texture Mapping –Texture Parameterization: Mapping an

resi

ze()

: P

ersp

ecti

ve &

Loo

kAt

void

res

ize(

int

w,i

nth

){

glV

iew

port

( 0,

0, (

GL

size

i) w

, (G

Lsi

zei)

h )

;gl

Mat

rixM

ode(

GL

_PR

OJE

CT

ION

);gl

Loa

dIde

ntit

y();

gluP

ersp

ecti

ve(

65.0

, (G

Lfl

oat)

w /

h,1.

0, 1

00.0

);

glM

atri

xMod

e( G

L_M

OD

EL

VIE

W )

;gl

Loa

dIde

ntit

y();

gluL

ookA

t( 0

.0, 0

.0, 5

.0,

0.0,

0.0

, 0.0

,0.

0, 1

.0, 0

.0 )

;

}