MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.
-
Upload
lais-prior -
Category
Documents
-
view
216 -
download
1
Transcript of MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.
![Page 1: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/1.jpg)
MGattass
Algoritmo de Rastreamento de Raios
![Page 2: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/2.jpg)
MGattass
Perspectiva e tamanhos relativos
![Page 3: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/3.jpg)
MGattass
Perspectiva e tamanhos relativos
![Page 4: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/4.jpg)
MGattass
Iluminação e posição
O que está na frente?A que distância do apoio?
![Page 5: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/5.jpg)
MGattass
Sombra
![Page 6: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/6.jpg)
MGattass
Oclusão
![Page 7: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/7.jpg)
MGattass
Gradiente de textura
Proposto no século XX!
![Page 8: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/8.jpg)
MGattass
Efeitos Passivos
– Inerentes a aparência do mundo externo– Independem dos nossos olhos– Fotografias parecem 3D
![Page 9: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/9.jpg)
MGattass
Camera obscura
Camera Obscura - San FranciscoThe Camera Obscura at the Cliff House is one of several remaining camera obscuras in the world. The device is an ancient precursor to modern photography, and well worth a visit, especially if you haven't previously visited a camera obscura.
Plymouth, UK
![Page 10: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/10.jpg)
Canaletto (Giovanni Antonio Canal) (1697-1768).
Pintores
Ponto de fuga
![Page 11: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/11.jpg)
A idéia básica do Traçado de Raios
MGattass
![Page 12: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/12.jpg)
Modelo de Iluminação Local e Global
MGattass
Cornell U.
![Page 13: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/13.jpg)
MGattass
Evolução da Camera obscura para as Câmaras fotográficas
Luis-Jacques-Mandé Daguerre (1839)Câmara escura - Leonardo da Vinci -1545
![Page 14: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/14.jpg)
MGattass
A Câmara “Pinhole” e seu modelo
centro deprojeção
raios
plano deprojeção
eixoóptico
eixos doplano deprojeção
plano deprojeção
![Page 15: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/15.jpg)
MGattass
Síntese de imagens
xo
zo
Objetos
Pixel(RGB)
Luz
Iluminação
yo
Câmara
xe
ye
ze eye
![Page 16: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/16.jpg)
MGattass
Algoritmo básico
Para cada pixel da tela;Lance uma raio;Para cada objeto da cena
Calcule a interseção do raio com este o objeto;Armazene a interseção mais próxima;
Se o raio interceptou algum objeto Calcule a contribuição das luzes neste ponto;Pinte o pixel com esta cor;
Objetos
Luz
IluminaçãoCâmara
xe
ye
ze
![Page 17: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/17.jpg)
MGattass
Definição de uma câmera
w (pixels) base
h (p
ixel
s)
altu
ra
janela
ocentro de projeção janela
eixoóptico
centro óptico
oeye
alturahwbase
plano de projeção
centro de projeção
Projeção cônica
![Page 18: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/18.jpg)
MGattass
Abertura de uma câmera
df1df2
fovy1
fovy2altura
2tan
2y
f
fovd
altura
2tan2 y
f
fovdaltura
![Page 19: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/19.jpg)
MGattass
Eixos de uma câmera
eixo óptico
v
u
eyexe
ye
ze
eixo horizontal
eixo vertical
w (pixels) base
h (p
ixel
s)
altu
ra
janela
o xe
ye
t (top)
b (bottom) l (
left)
r (ri
ght)
![Page 20: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/20.jpg)
MGattass
Parâmetros de funções do OpenGL
void glPerspective(GLdouble fovy,GLdouble aspect,GLdouble near_,GLdouble far_);
aspect = w/h
xe
ye
ze
near
far
w
h
ye
ze
fovy
void glViewport(GLint x0, GLint y0, GLsizei width, GLsizei height );
u
v
width
heig
hto1 x0
y0
![Page 21: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/21.jpg)
MGattass
Parâmetros intrínsecos (do OpenGL)parte 2 – Câmera mais geral
void glFrustum( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_, GLdouble far_ );
ye
ze
v
near uxe
xe
ze
near
left right
far
![Page 22: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/22.jpg)
MGattass
Parâmetros internos ou intrínsecos
near = plano próximo
fovy= campo de visão
w h pixels
far = plano distante
neard f
2tan2 y
f
fovdaltura
alturahwbase
Primários: Derivados:
![Page 23: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/23.jpg)
MGattass
Posicionamento da câmera(parâmetros externos ou extrínsecos)
eye = centro ópticocenter = ponto de visada, up = direção para cima
Coordenadas dosObjetos
eyecenter
fovy
vista lateral
upeye
center
up
x0
z0
y0
near
far
![Page 24: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/24.jpg)
MGattass
Calculo do sistema do olho - xe ye ze
center
zeeye
up
z0
y0
x0
view
up
center
eye
z0
y0
x0
dados:eye, center, up
view = center - eye centereye
centereyez
1e
![Page 25: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/25.jpg)
MGattass
Calculo do sistema do olho - xe ye ze
center
eye
vup
z0
y0
x0
view
zexe
center
eye
up
z0
y0
x0
view
zexe
ye
ee
e zupzup
x
1
eee xzy eye
up ze
xeye
center
![Page 26: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/26.jpg)
MGattass
Um modelo de câmera
zo
xoeyeo
eyepd xy
yo
xe
ye
ze
u
v
o1
eyepxy
dop ttraio )(:
d
![Page 27: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/27.jpg)
MGattass
Lançamento de Raios
vuop ˆ)(ˆ)(1 yvxuxy
bwxxu )(
ahyyv )(
o1
pxy
10 2 x3
h-1
uw-1
v
1
2
y
w pixels em b
h pi
xels
em
a
eexy hya
wxb yxop ˆˆ1
![Page 28: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/28.jpg)
MGattass
Canto inferior esquerdo da janela no plano near (ou far)
ea y2
eye
z0
y0
x0
zexe
ye
plano near
canto inferior esquerdo
1o
eeefbad xyzeyeo ˆ2
ˆ2
ˆ1
eeeeefxy hya
wxbbad yxxyzeyep ˆˆˆ
2ˆ
2ˆ
eeef wxb
hyad xyzd ˆ
21ˆ
21ˆ
![Page 29: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/29.jpg)
MGattass
Resultando
zo
xo
eyeo yo
xe
ye
ze
u
v
o1
eyepxy
dop ttraio )(:
d
eeef wxb
hyad xyzd ˆ
21ˆ
21ˆ
![Page 30: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/30.jpg)
MGattass
Tipo Abstrato de Dados: Camera em C
struct _Camera { /* Definição da câmera */ Vector eye, center, up; float fovy; float nearp,farp; int w,h;
/* Parametros derivados */ float f; float a,b; Vector xe,ye,ze;};
typedef struct _Camera Camera;
Camera* camCreate( Vector eye, Vector at, Vector up, double fovy, double nearp, double farp, int w, int h );
Ray camGetRay( Camera camera, double x, double y );
![Page 31: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/31.jpg)
MGattass
Objeto câmera
centereyecentereye
z
1
e ee
e zupzup
x
1 eee xzy
Inicialização (pré-processamento):
Lançamento de raios: o + td
eyeo
neard f
2tan2 fovda f a
hwb
Dados: fov, w, h, near, far, eye, center, up
eeef wxb
hyad xyzd ˆ
21ˆ
21ˆ
Dados: x, y
![Page 32: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/32.jpg)
MGattass
Modelagem dos Objetos
Implícita: Por fronteira:
r cp
p
dados: centro c raio r
p1
p2p3
![Page 33: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/33.jpg)
MGattass
Interseção de um raio com uma esfera
02 ctbta ii
o d
ti
dop ttRaio )(:
22)(: rtEsfera i cp
22 rti cdo
2rtt ii dcodco
0)(2 22 rtt ii cococoddd
aacbbt
242
![Page 34: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/34.jpg)
MGattass
Objeto esfera: métodos (dados o, d, c, r )
Interseção:
2rc coco
dda)(2 cod b
042 acbse
abt
abt
2
2
2
1
),min( 21 ttti
se ti > 0 :
dopp iii tt )(
cpcp
n
ii
i1ˆ
c
piinNormal:
![Page 35: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/35.jpg)
MGattass
Interseção com o plano do triângulo
o
d
01 npondit p1
n
nd
nop
1it
0)(: 1 npp itPlano
dop ttRaio )(:
01 npdo it
dopp iii tt )(
p2
p3
)( itp
2312
2312ˆppppppppn
![Page 36: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/36.jpg)
MGattass
Ponto interno a triângulo
p1
0)( 112 ppvn inti
p2
p3
2312 vvn
v31
v12
v23 0)( 112 ppvn exti
extip
inti
p
![Page 37: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/37.jpg)
MGattass
Coordenadas baricêntricas
p1v12
v23
v31
2/)(ˆ
2/)(ˆ2/)(ˆ
1123
3312
2231
ppvnppvnppvn
i
i
i
AAA
pi é interior se L1, L2 e L3 [0..1]
A3
A1A2
321 AAAAT
T
T
T
AALAALAAL
///
33
22
11
n
p2
p3
extip
intip
3112ˆ vvn unit
![Page 38: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/38.jpg)
MGattass
Coordenadas baricêntricas como funções interpolantes
p1
pi
A3
A1A2
1
1
1
L1
L2
L3
1321 LLL
3
3
3
3
2
2
2
2
1
1
1
1
zyx
Lzyx
Lzyx
Lzyx
i
i
ip3
p2
![Page 39: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/39.jpg)
MGattass
Interpolação de cor e coordenada de textura através das coordenadas baricêntricas
3
3
3
3
2
2
2
2
1
1
1
1
bgr
Lbgr
Lbgr
Lbgr
i
i
i
ou:
3
33
2
22
1
11 v
uL
vu
Lvu
Lvu
i
i
p1
pi
A3
A1A2
p3
p2c1 u1
c2 u2
c3 u3
![Page 40: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/40.jpg)
MGattass
Forma otimizada de calculo
od
p1
n
p2
p3
)( itp
dop ii t
332211 pppp LLLi
33221132 )1( pppdop LLLLtii Tomas Möller, Ben TrumboreFast, Minimum Storage Ray/Triangle Intersection
![Page 41: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/41.jpg)
MGattass
Forma otimizada de cálculo od
p1
n
p2
p3
)( itp
33221132 )1( pppdo LLLLti
1133122 )()( poppppd LLti
1
3
21312 )()( poppppd
LLti
bAx
![Page 42: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/42.jpg)
MGattass
Caixa alinhada com os eixos
x
y
z
(xmin, ymin, zmin)(xmax, ymax, zmax)
o d=(dx, dy, dz)
ti
max
max
min
0
00
zzd
yydxxd
z
y
x
![Page 43: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/43.jpg)
MGattass
Motivação: Uma cena simples
Camera:eye = (100,40,40), center = (0,0,0), up=(0,1,0), fov=90º, near = 30, far=230,
w=230, h=230.Esfera:
c = (0,20,0), r = 25, cor azul = (0,0,1)Caixas alinhadas com os eixos:
p0 = (-80,-50,-50), p1 = (50,-45,50) e cor amarela = (0.7,0.7,0)p0 = (-80,-50,-60), p1 = (50,50,-50) e cor amarela = (0.7,0.7,0)
Luz Pontual:Posição=(60,120,40) e intensidade RGB l=(0.8,0.8,0.8)
![Page 44: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/44.jpg)
MGattass
O que conseguiriamos se simplesmente atribuissemos aos pixels a cor dos objetos?
![Page 45: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/45.jpg)
MGattass
Área aparente
energialuminosa
energialuminosa
A
cos' AA
I (lumens)
I (lumens)
2/ mlumensAIi
2/cos' mlumensAIi
![Page 46: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/46.jpg)
MGattass
Modelo de reflexão de superfíces Lambertianas
luz incidente luz
incidente
luz incidente
1. Reflete igualmente em todas as direções2. A intensidade é proporcional ao co-seno
![Page 47: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/47.jpg)
MGattass
Componente de reflexão difusa
coscoscos
dbb
dgg
drr
b
g
r
klklkl
III
- /2 0 /2
cos
1
n
L
ip
![Page 48: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/48.jpg)
MGattass
Outras maneiras de se escrever:
I, l, k [0 ,1 ]
Eq. 1
LnLnLnLnLn
ˆˆˆˆˆˆ
ˆˆ
ˆˆ
db
dg
dr
b
g
r
dbb
dgg
drr
dbb
dgg
drr
b
g
r
kkk
lll
klklkl
klklkl
III
coscoscos
dbb
dgg
drr
b
g
r
klklkl
III
![Page 49: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/49.jpg)
MGattass
Luz difusa mais ambiente:
Ln ˆˆ
db
dg
dr
b
g
r
b
g
r
kkk
lll
III
Ln ˆˆ
db
dg
dr
b
g
r
db
dg
dr
ab
ag
ar
b
g
r
kkk
lll
kkk
III
III
![Page 50: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/50.jpg)
MGattass
Componente de reflexão especular
I, l, k [0 ,1 ]
Eq.2
n
L
rv Brilho
-1 -0,5 0 0,5 1
n=4n=1
n=8
nvr ˆˆ
nsbb
nsgg
nsrr
especularb
g
r
klklkl
III
coscoscos
![Page 51: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/51.jpg)
MGattass
Reflexão especular
n
sb
sg
sr
b
g
r
db
dg
dr
b
g
r
db
dg
dr
ab
ag
ar
b
g
r
kkk
lll
kkk
lll
kkk
III
III
vrLn ˆˆˆˆ
![Page 52: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/52.jpg)
MGattass
Reflexão especular
n
L
r v
ip
luzrefletida
![Page 53: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/53.jpg)
MGattass
Cálculo da reflexão de um vetor sobre outros
LnnLr ˆˆˆˆ2ˆ
LLh n
h hLn
nnLL ˆ)ˆˆ( n
hLr nˆ
n
L r
![Page 54: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/54.jpg)
MGattass
Distribuição da luz direta sobre um ponto
nsluzdifluzamb kCkCCC vrLn ˆˆˆˆ
nL
rv
ip
Ambient Diffuse Specular
![Page 55: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/55.jpg)
MGattass
Modelo de várias luzes
luzes
n
sb
sg
sr
b
g
r
db
dg
dr
b
g
r
db
dg
dr
ab
ag
ar
b
g
r
kkk
lll
kkk
lll
kkk
III
III
vrLn ˆˆˆˆ
vnnvr ˆˆ)ˆˆ(2ˆ r
luzes
n
r
sb
sg
sr
b
g
r
db
dg
dr
b
g
r
db
dg
dr
ab
ag
ar
b
g
r
kkk
lll
kkk
lll
kkk
III
III
LrLn ˆˆˆˆ
uma reflexão apenas
LnnLr ˆˆ)ˆˆ(2ˆ para cada fonte de luz
![Page 56: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/56.jpg)
MGattass
Sombra
A luz não chega a superfíce
ip
sr
si ttsombradeRaio rpp ˆ)(:
![Page 57: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/57.jpg)
MGattass
Modelo de várias luzes e sombra
contráriocasosombrase
f s 10
luzes
n
r
sb
sg
sr
b
g
r
db
dg
dr
b
g
r
s
db
dg
dr
ab
ag
ar
b
g
r
kkk
lll
kkk
lll
fkkk
III
III
LrLn ˆˆˆˆ
![Page 58: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/58.jpg)
MGattass
Fontes de luz especiais: Onidirecional
Fonte: Mauricio Hofmam
![Page 59: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/59.jpg)
MGattass
Fontes de luz especiais: Direcional
Fonte: Mauricio Hofmam
![Page 60: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/60.jpg)
MGattass
Fontes de luz especiais: Farolete
Fonte: Mauricio Hofmam
![Page 61: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/61.jpg)
MGattass
Uma revisão
![Page 62: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/62.jpg)
MGattass
Reflexão de outros objetos
Superfície especular
nv
iprr
ri ttrefletidoRaio rpp ˆ)(:
![Page 63: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/63.jpg)
MGattass
Transparência
Objeto transparente
nv
ip
tr
ti ttrefratadoRaio rpp ˆ)(:
1
2
2
1
sinsin
lei de Snell
![Page 64: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/64.jpg)
MGattass
n
t
tt
vv
t 1ˆ
Cálculo do Raio Refratado
i
n vnnvv ˆˆ)ˆˆ( t
v
ip
tr
nvtv
ti vsin
it
it
sinsin
tt 2sin1cos
)ˆ(cosˆsin ntr ttt
ti ttrefratadoRaio rpp ˆ)(:
t
![Page 65: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/65.jpg)
MGattass
Advertência: Refração não é simples!
![Page 66: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/66.jpg)
MGattass
Iluminação considerando superfícies refletoras e objetos transparentes
redução datransparência
redução da reflexão
)()()(
)1()()()(
ˆˆˆˆ
tb
tg
tr
rb
rg
rr
luzes
n
r
sb
sg
sr
b
g
r
db
dg
dr
b
g
r
s
db
dg
dr
ab
ag
ar
b
g
r
III
oIII
kkkk
lll
kkk
lll
fkkk
III
III
rrr
rrr
LrLn
![Page 67: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/67.jpg)
MGattass
Natureza recursiva do algoritmo de Rastreamento de Raios
R1
T1
R2
T2
R3
L1
L3
L2
R1
R2
L1
L3L2
T1
T2R3
![Page 68: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/68.jpg)
MGattass
Resultado de curso
Alunos de CGI98
![Page 69: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/69.jpg)
MGattass
Algoritmo de traçado de raios
Color trace (Scene scene, Vector3d eye, Vector3d ray, int depth){ determine a interseção mais próxima com um objeto if (intercepta objeto) { calcule a normal no ponto de interseção return ( shade ( scene, object, ray, point, normal, depth)); } return BACKGROUND;}
selecione o centro de projeção(eye) e uma janela no plano de projeçãofor (cada pixel da tela) { determine o raio ray que vai do centro de projeção ao pixel; pixel = trace ( ray, 1); }}
![Page 70: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/70.jpg)
Color shade (Scene scene, Object object, Vector3D ray, Vector3D point, Vector3D normal, int depth){ color = termo ambiente do material do objeto ;
for (cada luz) { L = vetor unitário na direção de point para a posição da luz; if (L • normal>0) { if (a luz não for bloqueada no ponto) { color += componente difusa (Eq.1) + componente especular (Eq.2) } }
if (depth >= maxDepth) return color;
if (objeto é refletor) { rRay = raio na direção de reflexão; rColor = trace(scene, point, rRay, depth+1); reduza rColor pelo coeficente de reflexão especular e some a color; }
return color;}
![Page 71: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/71.jpg)
MGattass
Texturas
u
v
1.0
1.0
0 u1.0
1.0
0
v
u1.0
1.0
0
v
Texturas 2D = Imagens onde o domínio é u, v [0,1]×[0,1] R2
![Page 72: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/72.jpg)
MGattass
Sistemas de coordenada de textura na caixa
uv
u
v
x
y
z
uv
(1,1)(0,0)
(0,0)
(0,0)face x=xmax
minmax
min
yyyyu
minmax
min
zzzzv
![Page 73: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/73.jpg)
MGattass
Sistema de coordenada de textura na esfera
x
y
z
sinsincossin
cos
yxz
zyx
xy22
tan
/tan
1
1
v
u
)1()1(
wujhvi
i
j
![Page 74: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/74.jpg)
MGattass
Sistema de coordenada de textura no triângulo
u
v
(u1,v1)
(u2,v2)
(u3,v3)
u1= u3 u2
v1= v2
v3
12
3
![Page 75: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/75.jpg)
MGattass
Textura no triângulo e coordenadas baricêntricas
p1v12
v23
v31
2/)(ˆ
2/)(ˆ2/)(ˆ
1123
3312
2231
ppvnppvnppvn
i
i
i
AAA
A3
A1A2
321 AAAAT
T
T
T
AALAALAAL
///
33
22
11
n
p2
p3
intip
3
33
2
22
1
11 v
uL
vu
Lvu
Lvu
i
i
)(1 213 LLL
![Page 76: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/76.jpg)
MGattass
Textura
![Page 77: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/77.jpg)
MGattass
Texturas de rugosidade (bump textures) eTexturas de deslocamentos (displacement mapping)
Pertubar aleatóriamenteas normais dos objetos
n
),(ˆ'ˆ nn
Pertubar aleatóriamenteas posições dos pontos
![Page 78: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/78.jpg)
MGattass
Textura ambiente (environment maps)
x yz
u
v
(0,0)
(1,1)face dos raios x>y e x>z
xxyu
2
xxzv
2
y=-x
y=x
z=-x
z=x
![Page 79: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/79.jpg)
MGattass
Tratamento anti-alias
•Lance um raio para cada sub-pixel•Faça uma média dos valores obtidos
dx, dy = variáveis randômicas
dxdya sub-pixels
pixel
![Page 80: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/80.jpg)
MGattass
Anti-alias
(a) original (b) uniforme (c) “jittered”
pixel pixel pixel
![Page 81: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/81.jpg)
MGattass
Refinamento Progresivo
subdivisão finalsegunda subdivisão
primeira subdivisãoamostragem inicial
pixels sendo visitados pixels já visitados
![Page 82: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/82.jpg)
MGattass
Radiosidade e Ray Tracing
Klaus Mueller, Stony Brook University, Computer Science (CSE 564)
global illuminationstandard raytracing
![Page 83: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/83.jpg)
Feb 3rd, 2003 Afrigraph 2003
Todays State of the ArtTodays State of the Art- Some Snapshots- Some Snapshots
![Page 84: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/84.jpg)
![Page 85: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/85.jpg)
![Page 86: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/86.jpg)
![Page 87: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/87.jpg)
![Page 88: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/88.jpg)
![Page 89: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/89.jpg)
MGattass
Aceleracao do RT
• Cálculos mais eficientes• Uso de uma Kd Tree
![Page 90: MGattass Algoritmo de Rastreamento de Raios. MGattass Perspectiva e tamanhos relativos.](https://reader036.fdocuments.net/reader036/viewer/2022070507/570638421a28abb8238f16e2/html5/thumbnails/90.jpg)
MGattass