Texture mapping - CNRvcg.isti.cnr.it/~tarini/teaching/mod14/textures_part1.pdf · 2014. 3. 25. ·...

9
Uni Pisa - Modellazione 3D 25/03/2014 Marco Tarini - 2014 1 Texture mapping Ogni texel è… Un colore RGB (color map, RGB map, diffuse map) Una normale (bump map, o normal map) Il coefficiente speculare (specular map) Un fattore di trasparenza (alpha map, o cutout texture) Una scavo dalla superfice (displacemnt map, o height texture) Un lighiting precalcolato (light map , baked light texture) Texture maps come assets Vari texture «sheets» associati ad una mesh o anche: più meshes sullo stesso sheet (bene) tipica struttura dati: mesh divisa in sottomesh ogni sottomesh associata a un materiale ogni materiale: 1 sheet di diffuse-map 1 sheet bumpmap (se serve) 1 sheet di alphamap (se serve) 1 vertex + fragment shader vari parametri (es, shininess, …)

Transcript of Texture mapping - CNRvcg.isti.cnr.it/~tarini/teaching/mod14/textures_part1.pdf · 2014. 3. 25. ·...

Page 1: Texture mapping - CNRvcg.isti.cnr.it/~tarini/teaching/mod14/textures_part1.pdf · 2014. 3. 25. · Texture mapping Ogni texel è… Un colore RGB ( color map , RGB map , diffuse map

Uni Pisa - Modellazione 3D 25/03/2014

Marco Tarini - 2014 1

Texture mapping

� Ogni texel è…

� Un colore RGB (color map, RGB map, diffuse map)

� Una normale (bump map, o normal map)

� Il coefficiente speculare (specular map)

� Un fattore di trasparenza (alpha map, o

cutout texture)

� Una scavo dalla superfice

(displacemnt map, o height texture)

� Un lighiting precalcolato (light map ,

baked light texture)

Texture maps come assets

� Vari texture «sheets»associati ad una mesh� o anche: più meshes sullo stesso sheet (bene)

� tipica struttura dati:� mesh divisa in sottomesh

� ogni sottomesh associata a un materiale

� ogni materiale:� 1 sheet di diffuse-map

� 1 sheet bumpmap (se serve)

� 1 sheet di alphamap (se serve)

� 1 vertex + fragment shader

� vari parametri

� (es, shininess, …)

Page 2: Texture mapping - CNRvcg.isti.cnr.it/~tarini/teaching/mod14/textures_part1.pdf · 2014. 3. 25. · Texture mapping Ogni texel è… Un colore RGB ( color map , RGB map , diffuse map

Uni Pisa - Modellazione 3D 25/03/2014

Marco Tarini - 2014 2

Texture maps come assets

� Caratteristiche:

� Size:

� risoluzione

� canali (es: alpha?)

� MIP-maps precalcolati?

� Tileable?

AA

B

B

Vincoli ricorrenti:

� res come potenze di 2 � (richiesto da sempre meno engines)

� sia in U che in V

� (es: 256x256 o 1024x512)

� res per lato < max� (es: max = 4096 o 2048)

Tileable textures

Page 3: Texture mapping - CNRvcg.isti.cnr.it/~tarini/teaching/mod14/textures_part1.pdf · 2014. 3. 25. · Texture mapping Ogni texel è… Un colore RGB ( color map , RGB map , diffuse map

Uni Pisa - Modellazione 3D 25/03/2014

Marco Tarini - 2014 3

Tileable textures

� Tipico utilizzo:

Molto efficiente in spazio!

MIP map levels

� Pre-filtering delle tessiture

� “LOD levels per immagini”!

� Hardware sceglie livello giusto per pixel

� Evita artefatti di sottocampionamento

1024x1024

512x512

256x256

1x1

Page 4: Texture mapping - CNRvcg.isti.cnr.it/~tarini/teaching/mod14/textures_part1.pdf · 2014. 3. 25. · Texture mapping Ogni texel è… Un colore RGB ( color map , RGB map , diffuse map

Uni Pisa - Modellazione 3D 25/03/2014

Marco Tarini - 2014 4

Texture maps come assets:formati files

� x immagini generiche(decomprimere tutta immagine

prima di accedere ai pixel)

☺ compressione: ottima

� loading: pesante:

� decomprimere da RAM,

(forse) ricomprimere in

GPU-RAM

� MIP-map lvls etc:

controllato dall’engine

� x textures(random accessibility ai texels

senza decomprimere)

� compressione: cattiva

☺ loading: leggero

� direct copy

Disco => RAM =>

GPU RAM

☺ MIP-map lvls etc:

controllato dall’artista

Texture maps come assets:formati files� x immagini generiche:

� .JPG / .JPEG

� lossy,

☺ > compresisone,

☺ immagini “fotografiche”: best

� solo 3 canali (no choice)

� 8 bit x canale (no choice)

� .PNG

☺ lossless

� < compressione

☺ disegni: best

☺ anche canale alpha possibile

☺ anche 16 bits possibile

� .TIFF e .RAW (rari)

☺ lossless

� � compressione: vabbe’

☺ max flessibilità canali etc

� .PNM (davvero raro)

� � � compressione: ahah

☺ ma parsing facilissimo! (no lib)

� x textures:

� .DDS(direct draw surface)

� lossy

� compresisone: poco (a rate fisso)

☺ GPU ready

☺ inlcude MIPmap levels (volendo)

con compressione a scelta

(S3TC):

� DXT1

� DXT2

� DXT3

� DXT4

� DXT5

(diversi compromessi fra qualità, costo, canali…)

“no / 1-bit alpha”

“rough alpha”

“smooth alpha ”

Page 5: Texture mapping - CNRvcg.isti.cnr.it/~tarini/teaching/mod14/textures_part1.pdf · 2014. 3. 25. · Texture mapping Ogni texel è… Un colore RGB ( color map , RGB map , diffuse map

Uni Pisa - Modellazione 3D 25/03/2014

Marco Tarini - 2014 5

RGB maps:come si ottengono

� Image first, then UV-mapping� e.g. immagine da fotografie

� e.g. tileable images

� UV-mapping first, then paint 2D� paint with 2D app (e.g. photoshop)

� UV-mapping first, then paint 3D� paint within 3D modelling software, � or: 1. export 2D rendering,

2. paint over with e.g. photoshop, 3. reimport images4. goto 1

UV-mapper

UV-mapper 2D painter

UV-mapper 3D painter

RGB maps:come si ottengono

…or:

� first Paint 3D� on hi-res model, � “paint” on vertex attributes� e.g. with Z bursh…

� then coarsen� build / autobuild final low-poly version

� then UV-map� the low-poly model� must be a 1:1 mapping!

� then auto-texture� auto build texture

more

about

this later…

Page 6: Texture mapping - CNRvcg.isti.cnr.it/~tarini/teaching/mod14/textures_part1.pdf · 2014. 3. 25. · Texture mapping Ogni texel è… Un colore RGB ( color map , RGB map , diffuse map

Uni Pisa - Modellazione 3D 25/03/2014

Marco Tarini - 2014 6

Alpha mapping(texels = lvl trasparenza)

Alpha map

RGB map

M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 1 / 1 2 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a

Alpha mapping(texels = lvl trasparenza)

� es: drappi, barba...

by Micheal Filipowski2004

tessitura

Page 7: Texture mapping - CNRvcg.isti.cnr.it/~tarini/teaching/mod14/textures_part1.pdf · 2014. 3. 25. · Texture mapping Ogni texel è… Un colore RGB ( color map , RGB map , diffuse map

Uni Pisa - Modellazione 3D 25/03/2014

Marco Tarini - 2014 7

Texture mapping e Alpha Test

� es: alberi, foliage

M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 1 / 1 2 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a

Texture mapping e Alpha Test

� Es: pelo, pelliccetessitura(ripetuta)

Page 8: Texture mapping - CNRvcg.isti.cnr.it/~tarini/teaching/mod14/textures_part1.pdf · 2014. 3. 25. · Texture mapping Ogni texel è… Un colore RGB ( color map , RGB map , diffuse map

Uni Pisa - Modellazione 3D 25/03/2014

Marco Tarini - 2014 8

Bump-Mapping(see demo)

stessa geometria (una sfera)bumpmaps diverse

Normal maps

� Memorizzati come immagini

� RGB => XYZ (come?)

caratteristico colore RGB

(0.5,0.5,1) - (128,128,255)

Page 9: Texture mapping - CNRvcg.isti.cnr.it/~tarini/teaching/mod14/textures_part1.pdf · 2014. 3. 25. · Texture mapping Ogni texel è… Un colore RGB ( color map , RGB map , diffuse map

Uni Pisa - Modellazione 3D 25/03/2014

Marco Tarini - 2014 9

Normal maps

� Espressi in spazio tangente

� Memorizzare direzioni tangenti

Tangente e Bi-tangente

� Nuovi attributi x vertice!

� Computati automaticamente

a partire da UV mapping (come?)