3D Fundamentals Tutorial 7

From Chilipedia
Revision as of 05:42, 17 May 2020 by R vdw (Talk | contribs) (Video)

Jump to: navigation, search

Textures. Put purdy pictures onto your triangles. Lot of interpolation and stuff.

Video

The tutorial video is on YouTube here.


  • What is texture mapping and why do we want it? 0:14
  • Mapping a picture onto a geometry (triangles)
  • Basically, to create real life imagery with high fidelity
  • How to approach texture mapping 2:45
  • How NOT to do it: sccaling and rotating points of a sprite
  • Right way: Generate a mapping of vertices of our geometry to points in our texture
  • This requires:
- Transform the vertices to screen space
- Rasterize (using scanlines)
- Interpolate from the geometry's screen coordinates (x,y) to coordinates of the texture (u,v)
- Use the texture's color at (u,v) to draw the pixel on the screen at (x,y)
  • Interpolating between three vertices 5:33
  • Pre-stepping 7:20
  • This is done based on the positions of the center of the starting pixel & the scanline
  • Implementing these concepts into code 8:42
  • The TexVertex class
  • Incorporating data & methods in Cube.h
  • Implementing DrawTriangleTex(...) triangle drawing with textures in Graphics.h and Graphics.cpp 10:55


Downloads

The GitHub repository for the tutorial code is here.

See also