CS 455 Lecture 12 – Specular and Texture
Before Class
Texture
- Watch http://youtu.be/xvML4htJAVU.
- Read chapter 4, sections Introduction through Applying a 2-D Texture, pages 105-110.
Specular
- Watch http://youtu.be/EM4x35haH7c.
- Read chapter 2, section Implementing Per-Vertex ADS Shading, pages 55-62. Read chapter 3, sections Using Per-fragment Shading… through Using the Halfway Vector…, pages 88-93.
In Class
- Augment your maze renderer from last class with a shiny texture:
- Load up W455/blop.ppm on texture unit 0.
- Assign texture coordinates in the vertex shader as a function of the vertex’s world position. (Do not assign a texcoord attribute on the CPU. You are deriving your “attribute” on the GPU.) Since your world coordinates span far beyond the [0, 1] range of texture coordinates, scale the texture coordinates down some. (position.xz / 30.0 works pretty well for me.) Set the texcoords as an out variable so that each fragment will get a texture coordinate.
- In the fragment shader, set the albedo of the geometry by looking up the color associated with the fragment’s texture coordinates.
- Modulate the albedo by your diffuse coefficient and tack on your specular term.
Haiku
We live in 3-D
We never eat shredded wheat
We throw one away
We never eat shredded wheat
We throw one away