Difference between revisions of "3D Fundamentals Tutorial 7"

From Chilipedia
Jump to: navigation, search
(Video)
(Video)
Line 10: Line 10:
 
:* Mapping a picture onto a geometry (triangles)
 
:* Mapping a picture onto a geometry (triangles)
 
:* Basically, to create real life imagery with high fidelity
 
:* Basically, to create real life imagery with high fidelity
 +
</div>
 
* How to approach texture mapping [https://youtu.be/UaOJxtWxICc?t=2m45s 2:45]
 
* How to approach texture mapping [https://youtu.be/UaOJxtWxICc?t=2m45s 2:45]
 
:* How NOT to do it: sccaling and rotating points of a sprite
 
:* How NOT to do it: sccaling and rotating points of a sprite
Line 38: Line 39:
 
* [https://youtu.be/UaOJxtWxICc?t=0m1s 0:1]
 
* [https://youtu.be/UaOJxtWxICc?t=0m1s 0:1]
 
* [https://youtu.be/UaOJxtWxICc?t=0m1s 0:1]
 
* [https://youtu.be/UaOJxtWxICc?t=0m1s 0:1]
</div>
+
 
 
</div>
 
</div>
  

Revision as of 05:42, 17 May 2020

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