Difference between revisions of "3D Fundamentals Tutorial 7"

From Chilipedia
Jump to: navigation, search
(Video)
(Video)
Line 6: Line 6:
  
 
<div class="mw-collapsible mw-collapsed"><br />
 
<div class="mw-collapsible mw-collapsed"><br />
* Why do we want textures? [https://youtu.be/UaOJxtWxICc?t=0m14s 0:14]
+
* What is texture mapping and why do we want it? [https://youtu.be/UaOJxtWxICc?t=0m14s 0:14]
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
:* ...
+
:* Mapping a picture onto a geometry (triangles)
 +
:* Basically, to create real life imagery with high fidelity
 +
* 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
 +
:* 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 [https://youtu.be/UaOJxtWxICc?t=5m33s 5:33]
 +
* Pre-stepping [https://youtu.be/UaOJxtWxICc?t=7m20s 7:20]
 +
:* This is done based on the positions of the center of the starting pixel & the scanline
 +
* Implementing these concepts into code [https://youtu.be/UaOJxtWxICc?t=8m42s 8:42]
 +
:* The <code>TexVertex</code> class
 +
:* Incorporating data & methods in <code>Cube.h</code>
 +
:* Implementing <code>DrawTriangleTex(...)</code> triangle drawing with textures in <code>Graphics.h</code> and <code>Graphics.cpp</code> [https://youtu.be/UaOJxtWxICc?t=10m55s 10:55]
 +
 
 +
 
 +
 
 +
* [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]
 +
* [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]
 +
* [https://youtu.be/UaOJxtWxICc?t=0m1s 0:1]
 +
* [https://youtu.be/UaOJxtWxICc?t=0m1s 0:1]
 
</div>
 
</div>
 
</div>
 
</div>

Revision as of 05:41, 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