Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea...

19
Texture Mapping Jung Lee

Transcript of Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea...

Page 1: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Texture Mapping

Jung Lee

Page 2: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 2 KUCG |

Texture Mapping*

• Adds visual detail to surfaces of 3D objects

*Edwin Catmull, Ph.D. Thesis, 1974

Page 3: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 3 KUCG |

Texture Mapping Example

Page 4: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 4 KUCG |

Texture and Texel

• Texel : Texture Element

GPUs can handle usually 2m x 2n texels

• Where m and n are nonnegative integers

• Texture Coordinates (s, t)

Page 5: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 5 KUCG |

2D Texture Space

• Continuous (s, t) Coordinate Space [0, 1]

For mapping it into a discrete texture image space

[Texture Map] [2D Texture Image]

Page 6: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 6 KUCG |

Texture Mapping Overview

1. Define a texture image

2. Specify mapping from the texture to surface

Texture coordinate

3. Lookup texture values during scan conversion

t

s

v

(0, 1)

(0, 0)

(1, 0)

y

x

u

Page 7: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 7 KUCG |

Texture Value Lookup

• Bilinearly interpolate texture coordinates

In the scan conversion step

α β

(u1, v1)

(u3, v3)

(u2, v2)

Page 8: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 8 KUCG |

Texture Modulation

Texture

Shaded Color

L

n

SLDALAE IKIKIKItsTI )RV()LN(, Texture Shading

Page 9: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 9 KUCG |

Bump Mapping

• Perturbs surface normal vectors

So called ‘normal mapping’

• Normal Information

Normal information can be stored in a RGB image

• Convert (x, y, z) to (R, G, B)

Page 10: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 10 KUCG |

Bump Mapping Example (1/5)

[Bump Map] [Bump Mapped Sphere]

Page 11: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 11 KUCG |

Bump Mapping Example (2/5)

Page 12: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 12 KUCG |

Bump Mapping Example (3/5)

Page 13: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 13 KUCG |

Bump Mapping Example (4/5)

Page 14: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 14 KUCG |

Bump Mapping Example (5/5)

4M Triangles 500 Triangles

Page 15: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 15 KUCG |

Displacement Mapping

• Modifying the actual surface geometry

Page 16: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 16 KUCG |

How to Assign Normal Vectors in OpenGL

• Face Normal Vector

• Vertex Normal Vector

glBegin(GL_POLYGON);

glNormal3f(a, b, c);

glVertex3f(x1, y1, z1);

glVertex3f(x2, y2, z2);

glVertex3f(x3, y3, z3);

glEnd();

P1(x1, y1, z1)

N(a, b, c)

P2(x2, y2, z2) P3(x3, y3, z3)

glBegin(GL_POLYGON);

glNormal3f(a1, b1, c1);

glVertex3f(x1, y1, z1);

glNormal3f(a2, b2, c2);

glVertex3f(x2, y2, z2);

glNormal3f(a3, b3, c3);

glVertex3f(x3, y3, z3);

glEnd();

P1(x1, y1, z1)

N1(a1, b1, c1)

P2(x2, y2, z2) P3(x3, y3, z3)

N2(a2, b2, c2)

N3(a3, b3, c3)

Page 17: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 17 KUCG |

Environment Mapping

• Maps a surrounding environment texture Around a surface of an object

To approximate effects like reflection or refraction

• View dependant Due to reflective mapping process

• Not need the texture coordinates Since surface normals are used to map the environment

texture

• Cubic Environment Mapping

• Spherical Environment Mapping

Page 18: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 18 KUCG |

Cubic Environment Mapping

Page 19: Texture Mappingkucg.korea.ac.kr/.../CNCE340/tutor/11texture_mapping.pdf · 2002-01-16 · Korea University Computer Graphics Lab. KUCG | Jung Lee | September 26, 2012 | # 17 Environment

Korea University Computer Graphics Lab.

Jung Lee | September 26, 2012 | # 19 KUCG |

Environment Mapping Example