CrashCourse · @crashcourse

3D Graphics: Crash Course Computer Science #27

Uploaded June 8, 2018 · Length 12:41

3D Graphics: Crash Course Computer Science #27

Summary

Learn how 3D graphics are rendered on a 2D screen using projection, wireframe rendering, scanline rendering, and Z-buffering.

  • 3d graphics rendering
  • computer science basics
  • wireframe models
  • scanline algorithm
  • z-buffering explained
  • 3d projection types

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:03

    Hi, I’m Carrie Anne, and welcome to CrashCourse Computer Science!

  2. 0:05

    Over the past five episodes, we’ve worked up from text-based teletype interfaces to

  3. 0:10

    pixelated bitmapped graphics. Then, last episode, we covered Graphical User Interfaces and all

  4. 0:15

    their “Ooey Gooey” richness.

  5. 0:17

    All of these examples have been 2D. But of course “we are living in a 3D world, and

  6. 0:21

    I’m a 3 dimensional girl!”

  7. 0:23

    So today, we're going to talk about some fundamental methods in 3D computer graphics and how you

  8. 0:27

    render them onto a 2D screen.

  9. 0:29

    INTRO

  10. 0:38

    As we discussed in episode 24 we can write functions that draw a line between any two points like A and B.

  11. 0:44

    By manipulating the X and Y coordinates of points A and B, we can manipulate the line.

  12. 0:49

    In 3D graphics, points have not just two coordinates, but three -- X, Y and Z. Or “zee” but

  13. 0:55

    I’m going to say “zed”.

  14. 0:56

    Of course, we don’t have X/Y/Z coordinates on a 2D computer screen, so graphics algorithms

  15. 1:01

    are responsible for “flattening” 3D coordinates onto a 2D plane.

  16. 1:05

    This process is known as 3D Projection. Once all of the points have been converted from

  17. 1:09

    3D to 2D, we can use the regular 2D line drawing function to connect the dots… literally.

  18. 1:15

    This is called Wireframe Rendering.

  19. 1:17

    Imagine building a cube out of chopsticks, and shining a flashlight on it. The shadow

  20. 1:21

    it casts onto your wall – its projection – is flat. If you rotate the cube around,

  21. 1:25

    you can see it’s a 3D object, even though it’s a flat projection.

  22. 1:29

    This transformation from 3D to 2D is exactly what your computer is doing, just with a lot

  23. 1:34

    more math… and less chopsticks.

  24. 1:36

    There are several types of 3D Projection. What you’re seeing right now is an Orthographic

  25. 1:41

    Projection, where, for example, the parallel sides in the cube appear as parallel in the

  26. 1:46

    projection.

  27. 1:47

    In the real 3D world through, parallel lines converge as they get further from the viewer,

  28. 1:50

    like a road going to the horizon. This type of 3D projection is called Perspective Projection.

  29. 1:56

    It’s the same process, just with different math. Sometimes you want perspective and sometimes