09-texturas
TRANSCRIPT
-
7/30/2019 09-texturas
1/59
Cap. 9
Texturas
Engenharia Informtica (5385) - 2 ano, 2 semestre
-
7/30/2019 09-texturas
2/59
Sumrio Objectivos" Noo de textura" Motivao" Mapeamento de textura, padres de textura e texels" Mapeamento de texturas em polgonos, interpolao de texturas" Rasterizao: modos de aplicao de texturas" Mapeamento de texturas em objectos geomtricos"
mapeamento planar" mapeamento cilndrico" mapeamento esfrico" mapeamento paralepipdico"
Modos de revestimento (wrapping)" ..."
-
7/30/2019 09-texturas
3/59
Objectivos Introduzir mtodos de mapeamento
Mapeamento de textura (texture mapping) Mapeamento ambiental (environmental mapping) Mapeamento rugoso (bump mapping) Mapeamento de luz (light mapping)
Considera-se duas estratgias bsicas: Especificao manual de coordenadas Mapeamento automtico em duas fases
-
7/30/2019 09-texturas
4/59
Noo de Textura Uma textura uma imagem com
componentes RGB e alpha..." Mapeamento de textura: um mtodo
para criar complexidade numa imagemsem o nus de construir grandes
modelos geomtricos"
-
7/30/2019 09-texturas
5/59
Motivao:
(1) adicionarrealismo
texture map
light map
bump map
reflection map
-
7/30/2019 09-texturas
6/59
Motivao: (2) adicionardetalhe
superfcie A soluo mais bvia no a melhor"
Dividir uma cena em polgonos cada vez mais pequenos aumenta odetalhe"
Mas muito difcil de modelar e muito oneroso de renderizar emtermos de tempo"
A soluo preferida usar mapeamento de textura" tipicamente uma imagem 2D decalcada em objectos"
Exemplos:" Modelo de t-shirt com logo"
no h necessidade de modelar as letras nem nenhum processamentode tringulos"
usa-se um polgono de dimenses grandes" colora-se o polgono com uma foto
Iluminao sbtil da parede
no h necessidade de calcul-la em cada frame"
no h necessidade de model-la com vrios tringulos de cor constante" decalca-se a foto num polgono grande
Tambm funciona em superfcies no complanares subdivide surface into planar patches" assign photograph subregions to each individual patch"
Exemplos de modulao de cor, rugosidade, brilho, e transparnciacom a mesma geometria esfrica"
-
7/30/2019 09-texturas
7/59
Texturas: em que ponto as coisas
comeam a parecer reais?
modelo geomtrico modelo geomtrico+
coloraomodelo geomtrico
+colorao
+texturas
Superfcies de objectos do mundo selvagem so muito complexas No podem modelar as mais finas variaes Precisamos de encontrar formas de adicionardetalhe superfcie. Como?"
-
7/30/2019 09-texturas
8/59
Mapeamento de textura, padro
de textura e texels Desenvolvido por Catmull (1974), Blinn e
Newell (1976), e outros investigadores." Mapeamento de textura: adiciona detalhe
superfcie atravs de mapeamento depadres de texturas sobre a superfcie. "
Padro repetido. Por exemplo, o padrode textura para o cubo ao lado o seguinte: "
Texel: abreviatura para texture element." Um texel um pixel da textura. Por
exemplo, uma textura de resoluo 128x128tem 128x128 texels. No ecr, isto poderesultar em mais ou menos pixels, o quedepender da distncia a que o objecto seencontra na cena, ou seja, de como atextura escalada para a superfcie."
-
7/30/2019 09-texturas
9/59
Tcnicas de Mapeamento
Mapeamento de Texturas Mapeamento Ambiental
Mapeamento de Rugosidade Mapeamento de Luz
-
7/30/2019 09-texturas
10/59
Mapeamento (manual) de
Textura Questo: Que ponto da textura se usa
para um dado ponto da superfcie? A textura simplesmente uma imagem
com um sistema de coordenadas 2D (s,t) Parameteriza-se pontos da textura com
coordenadas: (s,t)
Define-se o mapeamento de (x,y,z) nodomnio da cena para o domnio datextura (s,t) Para determinar a cor em (x,y,z) usa-se o
correspondente (s,t) para determinar a cor
da textura nesse ponto Com polgonos:
Especifica-se (s,t) nos vrtices Interpola-se (s,t) para os pontos
intermdios entre os vrtices e no interiordo polgono
s
t
-
7/30/2019 09-texturas
11/59
s
t
u
v
(s,t) = (u,v)
Mapeamento automtico da
textura para a superfcie O problema bsico est em encontrar a
funo (mapping) que mapeia a texturapara a superfcie
Dada uma posio (s,t) da textura, qual a posio (x,y,z) na superfcie?
Este problema requer 3 funesparamtricas: x = X(s, t) y = Y(s, t) z = Z(s, t)
No caso de a superfcie j estar formuladaparametricamente, ento temos outros
sistemas de coordenadas envolvidos: o daimagem (s,t) e o da prpria superfcie (u,v)
s
t
(x,y,z)
-
7/30/2019 09-texturas
12/59
Como se define as coordenadas
paramtricas (u,v)?
Manualmente: Ns atribuimos as coordenadas da textura a cada vrtice da
superfcie
Automaticamente: Usa-se um algoritmo que atribui as coordenadas da textura
-
7/30/2019 09-texturas
13/59
Especificao manual de
coordenadas Podemos especificar manualmente as coordenadas da textura em cada vrtice
(0,0)texture 2D polygon textured polygon
+ =(1,1)
(0,0)
(1,1)
Podemos escolher coordenadas de textura alternativas
(0,0)
texture 2D polygon textured polygon
+ =
(1,1)
(0,0)
(1,0.5)
-
7/30/2019 09-texturas
14/59
Mapeamento de texturas em
polgonos Especificamos explicitamente
as coordenadas (u,v) nosvrtices do polgono
Ou seja, afixamos a textura nosvrtices
Faz-se ento a interpolaodentro do tringulo na altura darasterizao (scan conversion)no domnio de ecr.
uv
glTexCoord2f(0.5, 0.5);
glVertex3fv (10.2,3.4,4.5);
-
7/30/2019 09-texturas
15/59
Interpolao de texturas
A interpolao feita durantea fase de scan conversion, semelhana do que feito nacolorao de Gouraud
Mas e vez de interpolar osvalores RGB, obtemos osvalores (u,v) que permitemaceder correspondente corna textura.
Isto , o mapeamento datextura feito no domniocannico do ecr quando o
polgono rasterizado No entanto, quando se
descreve uma cena, assume-se muitas vezes que omapeamento feito nodomnio da cena
(x1, y1), (u1, v1)(x2, y2), (u2, v2)
(x3, y3), (u3, v3)
R
LR
L
L
LR
Ls
xx
xxs
xx
xxs
+
= 1
sR = 1y y
1
y3 y
1
u1 +
y y1
y3 y
1
u3
sL = 1y y
2
y3 y
2
u2 +
y y2
y3 y
2
u3
-
7/30/2019 09-texturas
16/59
Rasterizao:
modos de aplicao de texturas Aps saber os valores de uma textura,
podemos us-los para modificar um oumais atributos de um polgono/superfcie atravs das chamadasfunes de mistura (combinefunctions ou texture blendingoperations): replace: substitui cor da superfcie pela
cor da textura decal: substitui cor da superfcie pela
cor da textura, misturando ento a corcom o valor alpha da textura, ainda quea componente alpha no sejamodificado no framebuffer
modulate: multiplica a cor da superfciepela cor da textura (shaded + texturedsurface). Precisa-se disto para a multi-texturizao (i.e., lightmaps).
blend: semelhante modulao mascom mistura alpha
Textura Polgono Textura Mapeada
Textura Polgono Textura Mapeada
operao REPLACE
operao MODULATE
-
7/30/2019 09-texturas
17/59
Questes relevantes em
mapeamento de texturas O que acontece quando se faz zoom aumentativo e zoom
diminuitivo?
Como geramos as coordenadas de texturas?
O que acontece quando usamos coordenadas de textura menoresdo que 0 e maiores do que 1?
Ser que as aplicaes (maps) de textura s servem para por cornos objectos?
-
7/30/2019 09-texturas
18/59
Aplicao de uma textura numa
superfcie A aplicao de uma textura numa
superfcie tem lugar durante arenderizao.
semelhante ao mtodo decolorao de Gouraud: Tringulo rasterizado Cada pixel do tringulo mapeado de
volta textura Usa-se valores conhecidos nos
vrtices para interpolar sobre a textura Cada pixel est associado com uma
pequena regio da superfcie e a umapequena rea da textura. H 3 possibilidades de associao:
1. um texel a um pixel (raramente)2. magnificao: um texel a muitos pixels3. minificao: muitos texels a um pixel
Magnificao
Minificao
-
7/30/2019 09-texturas
19/59
Aplicao de uma textura numa
superfcie (cont.): zoom in: filtro de
magnificao Um pixel mapeado para uma pequena poro de um texel O resultado que muitos pixels so mapeados para o mesmo texel Sem um mtodo de filtragem surge o fenmeno de aliasing Filtro de magnificao: suaviza a transio entre pixels
Magnificao
muitos pixels correspondem a um texel blockiness / jaggies / aliasing
soluo: aplicar mdia(magnification filter)
-
7/30/2019 09-texturas
20/59
Aplicao de uma textura numa
superfcie (cont.): zoom out: filtro
de minificao Um pixel mapeado para muitos texels comum em perspectiva (foreshortening)
Minificao
Perspectiva (foreshortening)e mapeamento pobre detextura provoca adeformao visual dopavimento
Mipmaps melhoram o mapeamento,restaurando a forma do pavimento
-
7/30/2019 09-texturas
21/59
Aplicao de uma textura numa
superfcie (cont.): melhor filtro de
minificao: Mipmaps mip significa multum in parvo, ou muitas coisas num pequeno
lugar Ideia bsica: criar muitas texturas de tamanho decrescente e usar
uma delas quando for apropriado
Texturas pr-filtradas = mipmaps
Minificao
-
7/30/2019 09-texturas
22/59
Aplicao de uma textura numa
superfcie (cont.): Mipmaps:
otimizao de armazenamento obrigatrio fornecer
todos os tamanhos datextura em potncias de2 em relao originalem 1x1
-
7/30/2019 09-texturas
23/59
Sumrio: filtragem Zoom-in requer a utilizaao dum filtro de magnificao
Zoom-out requer a utilizaao dum filtro de minificao
Filtros mais avanados requerem mais tempo/computao, masproduzem melhores resultados
Mipmapping um filtro de minificao avanado
Precauo: mipmapping sem pr-definir mipmaps desligar (turn off)a texturizao (veja-se Filtering in OpenGL)
-
7/30/2019 09-texturas
24/59
Wrapping Modes Can assign texture coords outside of
[0,1] and have them eitherclamp orrepeatthe texture map
Wrapping modes:
repeat: start entire texture over Repeat Issue: making the texture borders
match-up
mirror: flip copy of texture in eachdirection get continuity of pattern
clamp to edge: extend texture edgepixels
clamp to border: surround with bordercolor
courtesy of Microsoft
(0, 0) (3, 0)
(3, 3)(3, 0)
REPEAT
MIRROR
CLAMP
TO EDGE
CLAMP TO
BORDER
-
7/30/2019 09-texturas
25/59
Wrapping modes:
Repetitive texture tiling A texture can also be repeatedly tiled across the surface by repeating the
(s,t) parameterization over the surface
But, best results are obtained when the texture is seamlessly tilable This means that the right side of the texture joins seamlessly with the left side
(same with the bottom and top)
Seams will appear for most textures when tiled:
But, we can edit or re-synthesize textures to be seamlessly repeatable (this isanother topic onto itself):
-
7/30/2019 09-texturas
26/59
Texturing in OpenGL
Procedure" Example"
-
7/30/2019 09-texturas
27/59
Texturing in OpenGL
Procedure: Texture Mapping" uploading of the texture to the video memory" set up texture parameters" enable texturing" the application of the texture onto geometry"
-
7/30/2019 09-texturas
28/59
Texturing in OpenGL:
main steps1. Create texture and load with
glTexImage() Three methods:
read in an image in a jpg, bmp, ... File generate the texture yourself within application copy image from color buffer
2. define texture parameters as to how texture is applied glTexParameter*() wrapping, filtering, etc
3. enable texturing
glEnable(GL_TEXTURE_*D)
4. assign texture coordinates to vertices the mapping function is left up to you glTexCoord*(s,t); glVertex*(x,y,z);
-
7/30/2019 09-texturas
29/59
Step 1: Specifying Texturing
Image Define a texture image as an array oftexels
(texture elements) in CPU memory:
Glubyte myTexture[width][height][3];
Each RGB value is specified to be an unsignedbyte, between 0 and 255
For example, a blue color would be (0, 0, 255)
Warning:
this [3]
seems to be
missing in
thetextbook
-
7/30/2019 09-texturas
30/59
Step 1: Defining an Image as a
Texture Call glTexImage2D. It uploads the texture to the video memory where it will be ready for
us to use in our programs.
void glTexImage2D(target,level,components,w,h,border,format,type,texture);"Parameters: target : type of texture, e.g. GL_TEXTURE_2D level : used for mipmapping = 0 (discussed later) components : elements per texel (for RGB) w, h : width and height of texture in pixels border : used for smoothing = 0 (dont worry about this) format : texel format e.g. GL_RGB type : rgb component formate.g. GL_UNSIGNED_BYTE texture : pointer to the texture array
Example, set the current texture:glTexImage2D(GL_TEXTURE_2D, 0, 3, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, texture);
-
7/30/2019 09-texturas
31/59
Step 1 (alternative):
Generating a Random Texture Here is a function for a random texture:
GLubyte texture[64][64][3];
int u, v;
for(u=0; u
-
7/30/2019 09-texturas
32/59
Step 2:
Specifying Texture Parameters OpenGL has a variety of parameters that determine how textures are
applied: Wrapping parameters determine what happens if s and t are outside the
(0,1) range
Filter modes allow us to use area averaging instead of point samples Mipmapping allows us to use textures at multiple resolutions
The glTexParameter() function is a crucial part of OpenGL texturemapping, this function determines the behavior and appearance oftextures when they are rendered.
Take note that each texture uploaded can have its own separateproperties, texture properties are not global.
-
7/30/2019 09-texturas
33/59
Step 2:
glTexParameter()Texture Paramete r Accepted value s Descripti o n
GL_TEXTURE_MIN_FILTER GL_NEAREST , GL_LINEAR,
GL_NEAREST_MIPMAP_NEAREST,GL_LINEAR_MIPMAP_NEAREST,GL_NEAREST_MIPMAP_LINEAR and
GL_LINEAR_MIPMAP_LINEA R
The texture minification function is used
when a single screen pixel maps tomore than one texel, this means thetexture must be shrunk in size.
Default setting isGL_NEAREST_MIPMAP_LINEAR.
GL_TEXTURE_MAG_FILTE R GL_NEAREST or GL_LINE A R
The texture magnification function isused when the pixel being texturedmaps to an area less than or equal to
one texel, this means the texture mustbe magnified.
Default setting is GL_LINE A R .
GL_TEXTURE_WRAP_ S GL_CLAMP or GL_REPEATSets the wrap parameter for the stexture coordinate. Can be set to eitherGL_CLAMP or GL_REPEAT .
Default setting is GL_REPEAT.
GL_TEXTURE_WRAP_T GL_CLAMP or GL_REPEATSets the wrap parameter for the t
texture coordinate. Can be set to eitherGL_CLAMP or GL_REPEAT .
Default setting is GL_REPEAT. GL_TEXTURE_BORDER_COLO R Any four values in the [0, 1] range
Sets the border color for the texture, if
border is present .
Default setting is (0, 0, 0, 0) .
GL_TEXTURE_PRIORITY [0, 1]Specifies the residence priority of thetexture, use to prevent OpenGL from
swapping textures out of video memory.Can be set to values in the [0, 1] range.See glPrioritizeTextures() for more
information or this article onGamasutra.
Target Specifies the target textur e GL_TEXTURE_1 D One dimensional texturing. GL_TEXTURE_2 D Two dimensional texturing.
-
7/30/2019 09-texturas
34/59
Step 2:
glTexParameter()Parameter Value DescriptionGL_CLAMP Clamps the texture coordinate in the [0,1] range. GL_REPEAT
Ignores the integer portion of the texture coordinate, only thefractional part is used, which creates a repeating pattern. Atexture coordinate of 3.0 would cause the texture to tile 3 timeswhen rendered .
GL_NEAREST Returns the value of the texture element that is nearest (inManhattan distance) to the center of the pixel being textured.Use this parameter if you would like your texture to appear
sharp when rendered .
GL_LINE A R Returns the weighted average of the four texture elements thatare closest to the center of the pixel being textured. These caninclude border texture elements, depending on the values ofGL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T, and onthe exact mapping. Use this parameter if you would like yourtexture to appear blurred when rendered .
GL_NEAREST_MIPMAP_NEARESTChooses the mipmap that most closely matches the size of thepixel being textured and uses the GL_NEAREST criterion (thetexture element nearest to the center of the pixel) to produce atexture value.
GL_LINEAR_MIPMAP_NEARESTChooses the mipmap that most closely matches the size of thepixel being textured and uses the GL_LINEAR criterion (aweighted average of the four texture elements that are closestto the center of the pixel) to produce a texture value.
GL_NEAREST_MIPMAP_LINE A R Chooses the two mipmaps that most closely match the size ofthe pixel being textured and uses the GL_NEAREST criterion(the texture element nearest to the center of the pixel) toproduce a texture value from each mipmap. The final texture
value is a weighted average of those two values.
GL_LINEAR_MIPMAP_LINE A R Chooses the two mipmaps that most closely match the size ofthe pixel being textured and uses the GL_LINEAR criterion (aweighted average of the four texture elements that are closestto the center of the pixel) to produce a texture value from eachmipmap. The final texture value is a weighted average of thosetwo values.
-
7/30/2019 09-texturas
35/59
Step 2:
Wrapping Modes Clamping : if s,t> 1 use color at 1, ifs,t< 0 use color at 0
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
Repeating : uses,tmodulo 1
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
textures
t
Wrap S : GL_REPEATWrap T : GL_REPEAT
Wrap S : GL_REPEATWrap T : GL_CLAMP
Wrap S : GL_CLAMPWrap T : GL_REPEAT
Wrap S : GL_CLAMPWrap T : GL_CLAMP
-
7/30/2019 09-texturas
36/59
Step 2:
Filter Modes Minification and magnification
-
7/30/2019 09-texturas
37/59
Step 2:
Mipmapping
-
7/30/2019 09-texturas
38/59
Step 3: Enable Texturing
To enable/disable just call: glEnable(GL_TEXTURE_2D) glDisable(GL_TEXTURE_2D);
What does texture mapping affect? the current shading color of a pixel (after lighting) is multiplied by the
corresponding texture color
So, if the object is a near white color (0.8, 0.8, 0.8) at some point and thecurrent texture color at that point is red (1, 0, 0), then when multiplied, itproduces (0.8, 0, 0)
-
7/30/2019 09-texturas
39/59
Step 4:
Mapping a Texture Assign the texture coordinates glTexCoord*() is specified at each vertex
s
t1, 1
0, 1
0, 0 1, 0
(s, t) = (0.2, 0.8)
(0.4, 0.2)
(0.8, 0.4)
A
B C
a
b
c
Texture Space Object Space
-
7/30/2019 09-texturas
40/59
Step 4:
Mapping a Texture: example How to texture a quad? The following code assumes that texturing has been enabled
and that there has been a texture uploaded with the id of 13. "glBindTexture (GL_TEXTURE_2D, 13);!
glBegin (GL_QUADS); !glTexCoord2f (0.0, 0.0); glVertex3f (0.0, 0.0, 0.0); !glTexCoord2f (1.0, 0.0); glVertex3f (10.0, 0.0, 0.0); !glTexCoord2f (1.0, 1.0); glVertex3f (10.0, 10.0, 0.0);!glTexCoord2f (0.0, 1.0); glVertex3f (0.0, 10.0, 0.0); !
glEnd ();"
(0.0f,0.0f) (1.0f,0.0f)
(1.0f,1.0f)(0.0f,1.0f)
texture coordinates
-
7/30/2019 09-texturas
41/59
Texturing Mapping in OpenGL:
summing up
-
7/30/2019 09-texturas
42/59
What about complex 3D
objects? It is easy to set texture coordinate for a single 2D
polygon, but can be difficult to set the texturecoordinates for complex 3D regions or objects.
Besides: in rendering based on pixel-to-pixel approach, the
inverse mapping from screen coordinates to texturecoordinates is needed
because of shading, mapping areas-to-areas and notpoint-to-point is required, which causes antialisingproblems, moire patterns etc.
Two-Stage Mapping: An automatic solution to themapping problem is to first map the texture to asimple intermediate surface then map the simpleintermediate surface to the target surface
-
7/30/2019 09-texturas
43/59
Automatic: cylindrical mapping
Example: first map to a cylinder Like wrapping a label around a can of soup
Convert rectangular coordinates (x, y, z) to cylindrical (r, , h), use only (h, ) to indextexture image
h
u
v
-
7/30/2019 09-texturas
44/59
Automatic: cylindrical mapping
Example: first map to a cylinder Like wrapping a label around a can of
soup
Convert rectangular coordinates (x, y, z) tocylindrical (r, , h), use only (h, ) to indextexture image
Parametric cylinder:x = rcos (2u)y = v/hz= rsin (2u)
Maps rectangle in u, vspace to cylinderof radius r and height h in worldcoordinates:
s = ut = v
h
u
v
-
7/30/2019 09-texturas
45/59
Automatic: spherical mapping
Example: first map to a sphere
Convert rectangular coordinates (x,y,z)to spherical (,)
Parametric sphere:x = rcos (2u)y = rsin (2u) cos (2v)z= rsin (2u) sin (2v)
For example: paste a world map onto asphere to model the earth. But in the
case of the sphere there is distortion atthe poles (north and south)
-
7/30/2019 09-texturas
46/59
Automatic: box mapping
Example: first map to a box
-
7/30/2019 09-texturas
47/59
Automatic: stage-two mapping
Now, we still need to map from an intermediate object (sphere, cylinder, or box) to thetarget object
1. Intersect the normals from intermediate surface to target surface2. Intersect the normals from target surface to intermediate surface3. Intersect vectors from center of target surface to intermediate
-
7/30/2019 09-texturas
48/59
Mapping Techniques
Texture Mapping Environmental Mapping Bump Mapping Light Mapping
-
7/30/2019 09-texturas
49/59
Environmental Maps
Use texture to represent reflectedcolor Texture indexed by reflection
vector
Approximation works whenobjects are far away from thereflective object
Environment mapping producesreflections on shiny objects
Texture is transferred in thedirection of the reflected ray fromthe environment map onto theobject
Reflected ray: R=2(NV)N-V What is in the map? spherical map
-
7/30/2019 09-texturas
50/59
Approximations Made
The map should contain a viewof the world with the point ofinterest on the object as the eye We cant store a separate map
for each point, so one map is
used with the eye at the center ofthe object Introduces distortions in the
reflection, but the eye doesntnotice
Distortions are minimized for asmall object in a large room
The object will not reflect itself The mapping can be computed
at each pixel, or only at thevertices
cubic map
-
7/30/2019 09-texturas
51/59
Types of Environment Maps
The environment map may take one ofseveral forms: Cubic mapping
Easy to produce with rendering system Possible to produce from phtographs uniform resolution Sim ple texture coordinates calculation
Spherical mapping (two variants) Spatially variant resolution
Parabolic mapping Describes the shape of the surface on
which the map resides Determines how the map is generated
and how it is indexed What are some of the issues in
choosing the map?
cubic map
spherical maps
-
7/30/2019 09-texturas
52/59
Mapping Techniques
Texture Mapping Environmental Mapping Bump Mapping Light Mapping
-
7/30/2019 09-texturas
53/59
Bump Mapping
-
7/30/2019 09-texturas
54/59
Bump Mapping:
how does it work? To create a bump-like effect, we
use texture to perturb normals Many textures are the result of
small perturbations in thesurface geometry
Modeling these changes wouldresult in an explosion in thenumber of geometric primitives.
Bump mapping attempts to alterthe lighting across a polygon toprovide the illusion of texture.
We can model this as deviationsfrom some base surface.
The question is then how thesedeviations change the lighting.
N
N
S(u,v) +B(u,v) = S(u,v)original surface bumpedsurfacebump map
-
7/30/2019 09-texturas
55/59
Bump Mapping:
step 1 and 2 Step 1: Putting everything into
the same coordinate frame as B(u,v). x(u,v), y(u,v), z(u,v) this is given
for parametric surfaces, but easyto derive for other analyticalsurfaces.
OrS(u,v) Step 2: Define the tangent plane
to the surface at a point (u,v) byusing the two vectors S
uand S
v.
The normal is then given by:N= SuSv
N
Su
Sv
-
7/30/2019 09-texturas
56/59
Bump Mapping:
step 3, 4, and 5 Step 3: The new surface positions are then given by:
S(u,v) =S(u,v) +B(u,v)N where,N=N / |N|
Step 4: Differentiating leads to: Su = Su +BuN+B(N)uSu = Su +BuN Sv = Sv +BvN+B(N)v Sv = Sv +BvNIfB is small.
Step 5: This leads to a new normal: N(u,v) = SuSv -Bu(NSv) +Bv(NSu) +BuBv(NN)
= N -Bu(NSv) +Bv(NSu) = N+ D
N
Su
SvN
D
For efficiency, can store Bu and Bv in a 2-component texture map. The cross products are geometry terms only. Nwill of course need to be normalized after the calculation and before lighting.This
floating point square root and division makes it difficult to embed into hardware.
-
7/30/2019 09-texturas
57/59
Mapping Techniques
Texture Mapping Environmental Mapping Bump Mapping Light Mapping
-
7/30/2019 09-texturas
58/59
Light Mapping
Gouraud shading is establishedtechnique for rendering but haswell known limitations Vertex lighting only works well for
small polygons but we dont want lots of
polygons! Solution is to pre-compute some
canonical light effects as texturemaps
For example Suppose we want to show effect
of a wall light Create wall as a single polygon Apply vertex lighting Apply texture map In a second rendering pass, apply
light map to the wall
=
=reflectance irradiance radiosity
-
7/30/2019 09-texturas
59/59
Light Mapping
Widely used in games industry Latest graphics cards will allow
multiple texture maps per pixel