Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction...

32
Computing & Information Sciences Kansas State University Lecture 10 of 42 CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics Lecture 10 of 42 William H. Hsu Department of Computing and Information Sciences, KSU KSOL course pages: http://snipurl.com/1y5gc Course web site: http://www.kddresearch.org/Courses/CIS636 Instructor home page: http://www.cis.ksu.edu/~bhsu Readings: Sections 20.5 – 20.13, Eberly 2 e – see http://snurl.com/1ye72 Next class (Lab 2): Textures in OpenGL: A Primer (Angel, 3 e ) Surface Detail 4: Mappings

Transcript of Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction...

Page 1: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

CIS 636/736 Computer GraphicsLecture 10 of 42

William H. Hsu

Department of Computing and Information Sciences, KSU

KSOL course pages: http://snipurl.com/1y5gc

Course web site: http://www.kddresearch.org/Courses/CIS636

Instructor home page: http://www.cis.ksu.edu/~bhsu

Readings:

Sections 20.5 – 20.13, Eberly 2e – see http://snurl.com/1ye72

Next class (Lab 2): Textures in OpenGL: A Primer (Angel, 3e )

Surface Detail 4:Mappings

Page 2: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Review: Texture MappingReview: Texture Mapping

parametric coordinates

texture coordinates

world coordinateswindow coordinates

Page 3: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Review:Common Texture Coordinate Mappings

Review:Common Texture Coordinate Mappings

OrthogonalCylindricalSpherical Perspective

ProjectionTexture

Chart

© 2006, Durand & Cutler, MIT CSAIL (6.837)

Page 4: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Projective Texture ExampleProjective Texture Example

Modeling from photographs Using input photos as textures

Figure from Debevec, Taylor & Malik http://www.debevec.org/Research

Page 5: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Texture Mapping & IlluminationTexture Mapping & Illumination

Texture mapping can be used to alter some or all of the constants in the illumination equation: pixel color, diffuse color, alter the normal, ….

Phong's Illumination Model

Constant Diffuse Color Diffuse Texture Color Texture used as Label Texture used as Diffuse Color

Page 6: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Texture ChartTexture Chart

Pack triangles intoa single image

Page 7: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Questions?Questions?

Page 8: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

TodayToday

2D Texture Mapping Procedural Solid Textures Other Mapping Techniques Texture Aliasing

Page 9: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Procedural TexturesProcedural Textures

Image by Turner Whitted

f (x,y,z) → color

Page 10: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Advantages: easy to implement in ray tracer more compact than texture maps

(especially for solid textures) infinite resolution

Disadvantages non-intuitive difficult to match existing texture

Procedural TexturesProcedural Textures

Page 11: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Questions?Questions?

Ken Perlin

Justin Legakis

Justin Legakis

Page 12: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

TodayToday

2D Texture Mapping Procedural Solid Textures Other Mapping Techniques:

Bump Mapping Displacement Mapping Environment Mapping (for Reflections) Light Maps (for Illumination)

Texture Aliasing

Page 13: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

What's Missing?What's Missing?

What's the difference between a real brick wall and a photograph of the wall texture-mapped onto a plane?

What happens if we change the lighting or the camera position?

Page 14: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Remember Gouraud Shading?Remember Gouraud Shading?

Instead of shading with the normal of the triangle, shade the vertices with the average normal and interpolate the color across each face

Illusion of a smooth surface with smoothly

varying normals

Page 15: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Phong Normal InterpolationPhong Normal Interpolation

Interpolate the average vertex normals across the face and compute per-pixel shading

(Not Phong Shading)

Must be renormalized

Page 16: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Bump MappingBump Mapping

Use textures to alter the surface normal Does not change the actual shape of the surface Just shaded as if it were a different shape

Sphere w/Diffuse Texture Swirly Bump Map Sphere w/Diffuse Texture & Bump Map

Page 17: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Bump MappingBump Mapping

Treat the texture as a single-valued height function Compute the normal from the partial derivatives in the texture

Page 18: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Another Bump Map ExampleAnother Bump Map Example

Cylinder w/Diffuse Texture Map

Bump Map

Cylinder w/Texture Map & Bump Map

Page 19: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

What's Missing?What's Missing?

There are no bumps on the silhouette of a bump-mapped object

Bump maps don’t allow self-occlusion or self-shadowing

Page 20: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Displacement MappingDisplacement Mapping

Use the texture map to actually move the surface point The geometry must be displaced before visibility is determined

Page 21: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Displacement MappingDisplacement Mapping

Image from:

Geometry Caching for Ray-Tracing Displacement Maps

by Matt Pharr and Pat Hanrahan.

note the detailed shadows cast by the stones

Page 22: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics Ken Musgrave

Displacement MappingDisplacement Mapping

Page 23: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

TodayToday

2D Texture Mapping Procedural Solid Textures Other Mapping Techniques:

Projective Shadows and Shadow Maps Bump Mapping Displacement Mapping Environment Mapping (for Reflections) Light Maps (for Illumination)

Texture Aliasing

Page 24: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Environment MapsEnvironment Maps

We can simulate reflections by using the direction of the reflected ray to index a spherical texture map at "infinity".

Assumes that all reflected rays begin from the same point.

Page 25: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

What's the Best Chart?What's the Best Chart?

Page 26: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Environment Mapping ExampleEnvironment Mapping Example

Terminator II

Page 27: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Texture Maps for IlluminationTexture Maps for Illumination

Quake

Also called "Light Maps"

Page 28: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Questions?Questions?

Image by Henrik Wann JensenEnvironment map by Paul Debevec

Page 29: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

TodayToday

2D Texture Mapping Procedural Solid Textures Other Mapping Techniques: Texture Aliasing

Page 30: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Textures can AliasTextures can Alias

Aliasing is the under-sampling of a signal, and it's especially noticeable during animation

nearest neighbor

mipmaps & linear interpolation

Page 31: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Textures can AliasTextures can Alias

Small details may "pop" in and out of view

nearest neighbor mipmaps & linear interpolation

Page 32: Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.

Computing & Information SciencesKansas State University

Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics

Next Time:Next Time:

Lab 2:

Shading and Texturing in OpenGL