Visualización Computacional II
Edificio PLADEMA Quienes somos? Profesor: Ayudantes: Dr. Marcelo Javier Vénere: venerem@exa.unicen.edu.ar Ayudantes: Ing. Juan P. D’Amato: jpdamato@exa.unicen.edu.ar Ing. Cristian García Bauza: crgarcia@exa.unicen.edu.ar Edificio PLADEMA
Logística (o como va a ser la cosa…) Seis clases teóricas repartidas entre esta semana y la que viene. Dos prácticas (a confirmar) para explicación de conceptos (OpenGL) y uso de tutoriales. Tres prácticas adicionales Forma de evaluación: Cursada y Final con un trabajo. Una entrega a corto plazo (antes de fin de año) y entrega final posterior. http://www.exa.unicen.edu.ar/catedras/visdat2/index.html
Horarios y Lugares Teórica: Martes 21/10: Aula 2 (Facultad) 19-22 hs. Miércoles 22/10: Aula 2 (Facultad) 19-21 hs. Viernes 24/10: Aula 1 (Facultad) 18-21 hs. Lunes 27/10: Aula 3 (Facultad) 19-22 hs. Martes 28/10: Aula 2 (Facultad) 19-22 hs. Miércoles 29/10: A confirmar
Información Bibliografía: Foley, van Dam, Feiner, Hughes “Computer Graphics: Principles and Practice”. Woo, Neider, Davis, Shreiner: “OpenGL Programming Guide”. Alan Watt “3D Computer Graphics”. IEEE Computer Graphics an applications.
Objetivo Idea: Entender los principios y metodologías para lograr efectos especiales en aplicaciones 3D.
Resumen de la materia Iluminación y transformaciones. Texturas. Raycasting, Raytracing y Radiosity. Sombras. Animación y comportamiento físico. Optimizaciones.
Transformaciones Las transformaciones se aplican sobre los puntos que definen el objeto Pi P1 P2 Pi = (px, py)
Transformaciones Simples Escala isotrópica Pi = (px, py) sx 0 0 sy S = Pi = S.Pi
Transformaciones Simples Traslación dx dy Pi = Pi + D Pi = (px, py) D = (dx, dy)
Transformaciones Simples Rotación Pi = (px, py) cos -sin sin cos R = Pi = R.Pi
Como representar las transformaciones? x' = ax + by + c y' = dx + ey + f x' y' a b d e x y c f = + p' = M p + t
Coordenadas homogeneas Se agrega una dimensión extra en 2D, se usa 3 x 3 matrices en 3D, se usa 4 x 4 matrices Cada punto tiene entonces un valor extra, w x' y' z' w' a e i m b f j n c g k o d h l p x y z w = p' = M p
Pasar a coordenadas homogeneas x' = ax + by + c y' = dx + ey + f Forma Afín Forma Homogénea x' y‘ 1 a b d e 0 0 c f 1 x y 1 x' y' a b d e x y c f = = + p' = M p + t p' = M p
Traslación (tx, ty, tz) x' y' z' 1 x' y' z' 1 1 1 tx ty tz 1 x y z 1 = Por que utilizar coordenadas homogéneas? Porque ahora las traslaciones se expresan como matriz! x' y' z' 1 x' y' z' 1 1 1 tx ty tz 1 x y z 1 =
Escala (sx, sy, sz) x' y' z' 1 sx sy sz 1 x y z 1 = Scale(s,s,s) p' p Isotrópica (uniforme) scaling: sx = sy = sz q' q x x' y' z' 1 sx sy sz 1 x y z 1 =
Rotación x' y' z' 1 cos θ sin θ -sin θ cos θ 1 1 x y z 1 = ZRotate(θ) p' Sobre eje z θ p x z x' y' z' 1 cos θ sin θ -sin θ cos θ 1 1 x y z 1 =
V’ = R . V Rotación x' y' z' 1 r11 r21 r31 r12 r22 r32 r13 r23 r33 1 x General x' y' z' 1 r11 r21 r31 r12 r22 r32 r13 r23 r33 1 x y z 1 = V’ = R . V
Proyección en perspectiva x' y' z' w’ 1 1 1 1/d x y z 1 = V’ = P. R . V
Necesidad de un modelo de iluminación
Difusor perfecto I R = I.Kr G = I.Kg B = I.Kb Asumimos que la superficie refleja igual en todas las direcciones. Ejemplo: tiza, arcilla, algunas pinturas R = I.Kr G = I.Kg B = I.Kb I Superficie
Cantidad de luz recibida Surface n I0 I = I0.cos R = I0.cos .Kr G = I0.cos .Kg B = I0.cos .Kb
Reflejos Reflexión ocurre solo en la dirección especular. n r l Depende de la posición relativa de la fuente de luz y el punto de vista A second surface type is called a specular reflector. When we look at a shiny surface, such as polished metal or a glossy car finish, we see a highlight, or bright spot. Where this bright spot appears on the surface is a function of where the surface is seen from. This type of reflectance is view dependent. At the microscopic level a specular reflecting surface is very smooth, and usually these microscopic surface elements are oriented in the same direction as the surface itself. Specular reflection is merely the mirror reflection of the light source in a surface. Thus it should come as no surprise that it is viewer dependent, since if you stood in front of a mirror and placed your finger over the reflection of a light, you would expect that you could reposition your head to look around your finger and see the light again. An ideal mirror is a purely specular reflector. In order to model specular reflection we need to understand the physics of reflection. n r l Surface
Reflectores no ideales Materiales reales no son como espejos. Brillos no son puntuales sino borrosos At this point we will introduce an empirical model that is consistent with our experience, at least to a crude approximation. In general, we expect most of the reflected light to travel in the direction of the ideal ray. However, because of microscopic surface variations we might expect some of the light to be reflected just slightly offset from the ideal reflected ray. As we move farther and farther, in the angular sense, from the reflected ray we expect to see less light reflected.
Reflectores no ideales Modelo empírico simple: Se supone que la luz se reflejará en la dirección del rayo ideal. Sin embargo, debido a imperfecciones microscópicas de la superficie, algunos rayos reflejados se apartarán un poco de la dirección ideal.
El modelo Phong I = I0.Ks.cosq Parámetros n r L Cámara V ks: coeficiente reflexión especular q : exponente reflexión especular I = I0.Ks.cosq n r One function that approximates this fall off is called the Phong Illumination model. This model has no physical basis, yet it is one of the most commonly used illumination models in computer graphics. The cosine term is maximum when the surface is viewed from the mirror direction and falls off to 0 when viewed at 90 degrees away from it. The scalar nshiny controls the rate of this fall off. L Cámara V Surface
El modelo Phong Efecto del coeficiente q The diagram below shows the how the reflectance drops off in a Phong illumination model. For a large value of the nshiny coefficient, the reflectance decreases rapidly with increasing viewing angle.
Cálculo de la dirección especular R = I0.((1-Ks).Kr. L.n + Ks. (V.r)q) G = I0.((1-Ks).Kg. L.n + Ks. (V.r)q) B = I0.((1-Ks).Kb. L.n + Ks. (V.r)q) r L r Surface
Modelo de iluminación simple R =Ia.Kr + I0.((1-Ks).Kr. L.n + Ks. (V.r)q) G = Ia.Kg + I0.((1-Ks).Kg. L.n + Ks. (V.r)q) B = Ia.Kb + I0.((1-Ks).Kb. L.n + Ks. (V.r)q) Surface
Modelos de iluminación (resumen) R = Ia.Kr + Σ Ii.((1-Ks).Kr. Li.n + Ks. (V.ri)q) G = Ia.Kg + Σ Ii.((1-Ks).Kg. Li.n + Ks. (V.ri)q) B = Ia.Kb + Σ Ii.((1-Ks).Kb. Li.n + Ks. (V.ri)q) L Kr, Kg, Kb Ks, q Propiedades del cuerpo r n V Surface
Intensidad de la luz En realidad se usa 1/r Decae como 1/r2 Misma energía en todas las direcciones En realidad se usa 1/r
Modelo de iluminación simple Flat shading Gourard shading
Gourard shading n1 , n2 , n3 Ir1 , Ig1 , Ib1 Ir2 , Ig2 , Ib2 Irpixel= (Ir1.A1+Ir2.A2+Ir3.A3)/A
Phong shading n1 , n2 , n3 npixel Ir , Ig , Ib
Modelo de iluminación simple
Modelo de iluminación simple
Que falta tener en cuenta? Para obtener imágenes realistas Texturas Sombras Transparencias Reflexiones Refracciones Fuentes no puntuales Iluminación proveniente de otros objetos
Resumen - Texturas Por qué usar texturas Conceptos básicos Mapeo y Tiling Filtros y Mipmapping Lightmaps y efectos. Environment Mapping
Resumen - Sombras Fake shadows Planar & Projective Shadow Mapping Shadow volumes
Transparencias
Refracción
Reflexiones
Ray Tracing I = Ilocal + Ireflejada + Irefractada
Sombras difusas
Radiosity
Que falta tener en cuenta? Para lograr realidad virtual Inmersión Comportamientos realistas Matrix
Efectos físicos
Efectos físicos