Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

43
Teksture

Transcript of Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Page 1: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Teksture

Page 2: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Lastnosti snovi

Page 3: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

O teksturah

Page 4: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

2D-3D lepljenje tekstur

Page 5: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

2D cilindricno lepljenje

Page 6: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Primeri 2d cilindricnega lep.

Page 7: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Sferično lepljenje

Page 8: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Primeri sferičnega lepljenja

Page 9: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Primerjava cil-sfer

Cilindrično lepljenjetekstur

Sferično lepljenjetekstur

Page 10: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

3D lepljenje - prosevanje

Page 11: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Primeri 3D lepljenja

Page 12: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

3D lepljenje, variacije, les

Page 13: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Lepljenje tekstur (Texture Mapping)

Texture map is an image, two-dimensional array of color values (texels)

Texels are specified by texture’s (u,v) space

At each screen pixel, texel can be used to substitute a polygon’s surface property

We must map (u,v) space to polygon’s (s, t) space

U

V

S

T

Page 14: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Lepljenje tekstur

(u,v) to (s,t) mapping can be explicitly set at vertices by storing texture coordinates with each vertex

How do we compute (u,v) to (s,t) mapping for points in between– Watch for aliasing– Watch for many to one mappings– Watch for perspective foreshortening effects and linear

interpolation

Page 15: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Interpolacija tekstur

Specify where the vertices in world space are mapped to in texture space

Linearly interpolate the mapping for other points in world space– Straight lines in world space

go to straight lines in texture space

Texture maps

t

Triangle in world space

Page 16: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Interpolacija koordinat

(x1, y1), (s1, t1)(x2, y2), (s2, t2)

(x3, y3), (s3, t3)

313

11

13

11 syy

yys

yy

yysR

3

23

22

23

21 syy

yys

yy

yysL

RLR

LL

LR

L sxx

xxs

xx

xxs

1

Page 17: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Tekstura prosojnosti

Page 18: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Prosojnost - refrakcija

Page 19: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Tekstura odbojnosti

Page 20: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Reflektivnost

Page 21: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Tekstura izbočenja

Page 22: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Lepljenje izboklin (bump mapping)

Page 23: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Lepljenje izboklin (bump mapping)

Use textures to modify surface geometry

Use texel values to modify surface normals of polygon

Texel values correspond to height field– Height field models a rough surface

Partial derivative of bump map specifies change to surface normal

Page 24: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Primerjava tekstur in izboklin

Texture mapping simulates detail with a color that varies across a surface

Bump mapping simulates detail with a surface normal that varies across a surface

+* *

tex(s,t)

NL

kskd

H

+* *

tex(s,t)

bump()L

kskd

H

N B

Page 25: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Primerjava lepljenja odmika in izboklin (Displacement v. Bump

Mapping)

Displacement mapping– Changes locations of vertices– Requires mesh to be subdivided to

shader resolution

P’ = P + B N

Bump mapping– Changes only direction of surface

normal– Give illusion of displacement map

N’ = N + Bs(N Pt) – Bt(N Ps)

Silhouettes are a dead giveaway– Displacements alter silhouettes– Bump maps leave silhouette smooth

B

P

P’

N’

1

Bs

Bs

1

Page 26: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Lepljenje odmikov (Displacement Mapping)

Bump mapped normals are inconsistent with actual geometry. Problems arise (shadows).

Displacement mapping actually affects the surface geometry

Page 27: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Celularne teksture

Page 28: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Teksture

Snov bo izgledala bolj zanimivo– Barva– prosojnost (sir, železo)– Umazanija, rja

Nudi dodatno globino človeškemu pogledu

Page 29: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Preslikava tekstur

Maps image onto surface

Depends on a surface parameterization (s,t)– Difficult for surfaces with many features– May include distortion– Not necessarily 1:1

Page 30: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

3D Teksture

Uses 3-D texture coordinates (s,t,r)Can let s = x, t = y and r = zNo need to parameterize surfaceNo worries about distortionObjects appear sculpted out of solid substance

Darwyn Peachey, 1985

SurfaceTexture

featuresdon’t

line up

SolidTexture

featuresdo

line up

Page 31: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Problemi s 3D teksturami

How can we deform an object without making it swim through texture?How can we efficiently store a procedural texture?

Page 32: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Proceduralne teksture

Texture map is a functionWrite a procedure to perform the function– input: texture coordinates - s,t,r – output: color, opacity, shading

Example: Wood– Classification of texture space into cylindrical shells

f(s,t,r) = s2 + t2

– Outer rings closer together, which simulates the growth rate of real trees

– Wood colored color table• Woodmap(0) = brown “earlywood” • Woodmap(1) = tan “latewood”

Wood(s,t,r) = Woodmap(f(s,t,r) mod 1)

f(s,t,r) = s2 + t2

Wood(s,t,r)

Woodmap(f)0 1

Page 33: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Šumne funkcije

Add “noise” to make textures interestingPerlin noise function N(x,y,z)– Smooth– Correlated– Bandlimited

N(x,y,z) returns a single random number in [-1,1]Gradient noise– Like a random sine wave

N(x,y,z)=0 for int x,y,zValue noise– Also like a random sine wave

N(x,y,z)=random for int x,y,z

Page 34: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Uporaba šuma

Add noise to cylinders to warp wood– Wood(s2 + t2 + N(s,t,r))

Controls– Amplitude: power of noise effect

a N(s, t, r)– Frequency: coarse v. fine detail

N(fs s, ft t, fr r)

– Phase: location of noise peaks

N(s + s, t + t, r + r)

Page 35: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Kako naredimo šum

Good:– Create 3-D array of random values– Trilinearly interpolate

Better– Create 3-D array of random 3-vectors– Hermite interpolate

Page 36: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Hermitova interpolacija

Some cubic h(t) = at3 + bt2 + ct + d s.t.– h(0) = 0 (d = 0)– h(1) = 0 (a + b + c = 0)– h’(0) = r0 (c = r0)– h’(1) = r1 (3a + 2b + r0 = r1)

Answer:– h(t) = (r0 + r1) t3 - (2r0 + r1) t2 + r0t

Tricubic interpolation– Interpolate corners along edges– Interpolate edges into faces– Interpolate faces into interior

Page 37: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Pobarvani obroči

Spotted donut– Gray(N(40*x,40*y,40*z))– Gray() - ramp colormap– Single 40Hz frequency

Bozo donut

– Bozo(N(4*x,4*y,4*z))

– Bozo() - banded colormap

– Cubic interpolation means contours are smooth

Page 38: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Obroči s preslikavo izboklin

DNoise(s,t,r) = Noise(s,t,r)

Bumpy donut

– Same procedural texture as spotted donut

– Noise replaced with DNoise

n

x

DN

n += DNoise(x,y,z); normalize(n);

Page 39: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Sestavljene teksture na obročih

Stucco donut– Noise(x,y,z)*DNoise(x,y,z)– Noisy direction– noisy amplitude

Fleshy donut– Same texture– Different colormap

Page 40: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Tekstura z naključnim lomom svetlobe

Page 41: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Brownovo gibanje

random paths

Integral of white noise

1/f 2 distribution

white noise brown noise

d

F F

log power

log f log f

11/f 2

Page 42: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Fraktalsko Brownovo gibanje

1/f distributionRoughness parameter – Ranges from 1 to 3– = 3 - smooth, not flat, still random– = 1 - rough, not space filling, but thick

Construct using spectral synthesis

– Add several octaves of noise function– Scale amplitude appropriately

+

=)2(2)(

4

1

ss i

i

i nf

Page 43: Teksture. Lastnosti snovi O teksturah 2D-3D lepljenje tekstur.

Obroč s fraktalsko nagubano površino

fbm(beta) {val = 0; vec = (0,0,0);for (i = 0; i < octaves; i++) {

val += Noise(2i*x, 2i *y, 2i *z)/pow(2,i*beta);vec += DNoise(2i*x, 2i *y, 2i *z)/pow(2,i*beta);

}return vec or val;

}