Triangles to Pixels - Computerphile

Computerphile · Intermediate ·📐 ML Fundamentals ·12y ago
Skills: CV Basics80%

Key Takeaways

The video explains the process of converting 3D representations into pixels on a screen, covering topics such as 3D graphics, graphics programming, and computer vision.

Full Transcript

we have taken our 3D object specified its vertices relative to an origin in a coordinate reference frame what happens to a triangle to turn it from this representation that we've got the vertices the faces into pixels on the screen we've got faces we can now transform them um by applying um a transformation at every vertex so we can turn them and scale them and move them around um but how does that now fit into the bigger picture how do we go from the local space of our 3D object in which its vertices are defined into a 2d representation on a screen well there are several stages and they're all trans different Transformations that we apply the first one is um from the local object space of um our representation into World space so we pick an origin for the world which I suppose we'll say is the middle of the table and we then apply a transformation which respecifies all of the vertices of our 3D object in local space in terms of the world origin so what we're basically doing is saying well we want our pyramid to be at um uh plus one in in X or minus one in X um minus one in zed 2 in y uh we can also then rotate it and uh scale it if we like and we can do that with several objects and move them all to different places and each will have a different transformation which places it um in the world it moves it from its local space to World space and that is called a world space transformation what we can also do because we can combine Transformations together is specify one object in terms of another so that we can Nest these different Transformations so that we might want to stick this pyramid to that one um and so it has first has a transformation that moves it from its own local space to the space of this pyramid which then moves to the the world space wherever we want to place it in the world and so we can nest things that way all we need to know really is where each vertex is in the world we need to know it World space position all of the vertices then need to be respecified from World space in terms of the space of the Viewpoint if the Viewpoint is here say this is our little camera and it's looking out on the world as we turn the camera this way what we actually do is apply a transformation to everything in the world which swings it over this way so the camera really never moves all we're doing is applying a transformation that appears to move everything relative to the camera we're respecifying all of our objects in terms of the local space of the camera and this is view space or eye space if you like so it's really it's just another transformation all we're doing is moving from World space into view space where're respecifying one coordinate frame of reference in terms of another so just like we moved from object space the local space of uh the pyramid to World space where it was positioned in our world um we're now moving from World space into view space which is again just another transformation and we can actually just combine those Transformations and have a a world view transformation which combines both of them into one and so all we need to do is apply that operation at every vertex on every single shape we then need to project down from 3D space into 2D space which again is just another transformation everything is just another transformation a projective transformation is a little bit different to the others because whereas before we were just applying translations and scales and rotations to move objects from one space to the next to the next now what we have to do is have a special transformation um which removes all of the depth information from the scene and squashes all of these vertices down onto a 2d plane and also because uh we might want to have a perspective effect whereby objects in the distance seem smaller we need to collapse and scale them down based on their distance and so on and so forth and all of that is encoded in the projective transformation so yeah so what have we done we've we've taken our local representation moved it into World space constructed a scene out of our pyramids and uh then moved all of those relative to the eye so we know exactly what's in front of us and what's going to be seen and then we collapse all of those down um into two Dimensions so what happens to a triangle to turn it from this representation that we've got the vertices the faces into pixels on the screen well let's just draw some pixels out not very many pixels the resolution is a bit low so let's just take a random triangle and draw it on let's draw it in purple so here's our representation now it's been squashed down into two dimensions and what we now have to do to turn it into pixels is go through every pixel here and decide whether or not it's inside the triangle now I've not drawn very many pixels on here so it's not going to look very good but we can say that um this one is pretty much inside the triangle um this one is pretty much inside the triangle and for argument sake I'll go with this one and this one and these two as well and so now what we've done is taken that simple geometric representation and discretized it we've turned it into a representation that no longer has any information about um vertices and faces it just says this pixel is inside this triangle when we collapse down from 3D to 2D um some of the vertices are going to lie outside our field of view and in that case we need to clip them what we have to actually do is generate another two vertices here because we don't know what's happening to this because it's not part of our representation anymore because we have clipped it to uh the viewport as it's called the problem is now as you can see we've no longer got a triangle so well we just use our old trick of turning an odd polygon into a triangle representation into two triangles and then the process of deciding which pixels are in the Triangle proceeds but for these two new triangles that now fit perfectly inside our Viewpoint and that's called clipping and then The Next Step Beyond that is just coloring in the pixels and deciding exactly uh how to shade them and light them we'd like to thank audible.com for their support of this computer file video and if you'd like to download one of their huge range of books go to audible.com computer file and you can download one for free I'd like to recommend one today um my favorite uh computer related book and one of the first books that made me think hang on computers could be cool and that's Neuromancer by William Gibson so get on to audible.com computer file download your free book and thanks again to audible.com for supporting this computer file video we'll incorporate the table into this because this is where the shadow is being cast the table is another 3D object in our 3D World and we're doing a a sheer operation in four dimensional space

Original Description

Audible free book: http://www.audible.com/computerphile How do we go from 3D representations within a computer to pixels on a screen? John Chapman has the details! John Chapman is a graphics programmer who blogs here: http://www.john-chapman.net Graphics series with John Chapman: 1/ Universe of Triangles : http://youtu.be/KdyvizaygyY 2/ Power of the Matrix : http://youtu.be/vQ60rFwh2ig 3/ Triangles to Pixels : http://youtu.be/aweqeMxDnu4 4/ Visibility Problem : http://youtu.be/OODzTMcGDD0 5/ Light and Shade in Computer Graphics: Coming Soon http://www.facebook.com/computerphile https://twitter.com/computer_phile This video was filmed and edited by Sean Riley. Computerphile is a sister project to Brady Haran's Numberphile. See the full list of Brady's video projects at: http://bit.ly/bradychannels
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Computerphile · Computerphile · 39 of 60

1 Follow the Cookie Trail - Computerphile
Follow the Cookie Trail - Computerphile
Computerphile
2 EXTRA BITS - Follow the Cookie Trail - Computerphile
EXTRA BITS - Follow the Cookie Trail - Computerphile
Computerphile
3 Musical Floppy Drives - Computerphile
Musical Floppy Drives - Computerphile
Computerphile
4 The Hair Algorithm - Computerphile
The Hair Algorithm - Computerphile
Computerphile
5 Getting Sorted & Big O Notation - Computerphile
Getting Sorted & Big O Notation - Computerphile
Computerphile
6 Quick Sort - Computerphile
Quick Sort - Computerphile
Computerphile
7 Hyper History and Cyber War - Computerphile
Hyper History and Cyber War - Computerphile
Computerphile
8 Entropy in Compression - Computerphile
Entropy in Compression - Computerphile
Computerphile
9 Original Elite on the BBC B - Computerphile
Original Elite on the BBC B - Computerphile
Computerphile
10 IP Addresses and the Internet - Computerphile
IP Addresses and the Internet - Computerphile
Computerphile
11 A Career in Video Games - Computerphile
A Career in Video Games - Computerphile
Computerphile
12 Error Detection and Flipping the Bits - Computerphile
Error Detection and Flipping the Bits - Computerphile
Computerphile
13 Programming BASIC and Sorting - Computerphile
Programming BASIC and Sorting - Computerphile
Computerphile
14 Birthplace of the World Wide Web - Computerphile
Birthplace of the World Wide Web - Computerphile
Computerphile
15 Punch Card Programming - Computerphile
Punch Card Programming - Computerphile
Computerphile
16 Programming Paradigms - Computerphile
Programming Paradigms - Computerphile
Computerphile
17 CERN Computing Centre (and mouse farm) - Computerphile
CERN Computing Centre (and mouse farm) - Computerphile
Computerphile
18 Error Correction - Computerphile
Error Correction - Computerphile
Computerphile
19 Home-Made Code - Computerphile
Home-Made Code - Computerphile
Computerphile
20 Security of Data on Disk - Computerphile
Security of Data on Disk - Computerphile
Computerphile
21 Gesture Controls - Computerphile
Gesture Controls - Computerphile
Computerphile
22 How Intelligent is Artificial Intelligence? - Computerphile
How Intelligent is Artificial Intelligence? - Computerphile
Computerphile
23 Encryption and Security Agencies - Computerphile
Encryption and Security Agencies - Computerphile
Computerphile
24 Virtual Machines Power the Cloud - Computerphile
Virtual Machines Power the Cloud - Computerphile
Computerphile
25 Hacking Websites with SQL Injection - Computerphile
Hacking Websites with SQL Injection - Computerphile
Computerphile
26 How Huffman Trees Work - Computerphile
How Huffman Trees Work - Computerphile
Computerphile
27 Cracking Websites with Cross Site Scripting - Computerphile
Cracking Websites with Cross Site Scripting - Computerphile
Computerphile
28 Cloud Computing (Cloudy with a Chance of Pizza) - Computerphile
Cloud Computing (Cloudy with a Chance of Pizza) - Computerphile
Computerphile
29 Texting Cabbage with a Recorder - Computerphile
Texting Cabbage with a Recorder - Computerphile
Computerphile
30 Hashing Algorithms and Security - Computerphile
Hashing Algorithms and Security - Computerphile
Computerphile
31 How YouTube Works - Computerphile
How YouTube Works - Computerphile
Computerphile
32 How NOT to Store Passwords! - Computerphile
How NOT to Store Passwords! - Computerphile
Computerphile
33 A New Golden Age of Video Games - Computerphile
A New Golden Age of Video Games - Computerphile
Computerphile
34 A Universe of Triangles - Computerphile
A Universe of Triangles - Computerphile
Computerphile
35 Cross Site Request Forgery - Computerphile
Cross Site Request Forgery - Computerphile
Computerphile
36 The True Power of the Matrix (Transformations in Graphics) - Computerphile
The True Power of the Matrix (Transformations in Graphics) - Computerphile
Computerphile
37 The Great 202 Jailbreak - Computerphile
The Great 202 Jailbreak - Computerphile
Computerphile
38 EXTRA BITS - Printing and Typesetting History - Computerphile
EXTRA BITS - Printing and Typesetting History - Computerphile
Computerphile
Triangles to Pixels - Computerphile
Triangles to Pixels - Computerphile
Computerphile
40 The Problem with Time & Timezones - Computerphile
The Problem with Time & Timezones - Computerphile
Computerphile
41 The Visibility Problem - Computerphile
The Visibility Problem - Computerphile
Computerphile
42 Lights and Shadows in Graphics - Computerphile
Lights and Shadows in Graphics - Computerphile
Computerphile
43 The Penguin Barcode - Computerphile
The Penguin Barcode - Computerphile
Computerphile
44 Typesetters in the '80s - Computerphile
Typesetters in the '80s - Computerphile
Computerphile
45 The Font Magicians - Computerphile
The Font Magicians - Computerphile
Computerphile
46 The Little Mac with the Big Bite - Computerphile
The Little Mac with the Big Bite - Computerphile
Computerphile
47 EXTRA BITS - More on the Original Mac at 30 - Computerphile
EXTRA BITS - More on the Original Mac at 30 - Computerphile
Computerphile
48 XP to Ubuntu with an 8yr old Hacktop - Computerphile
XP to Ubuntu with an 8yr old Hacktop - Computerphile
Computerphile
49 EXTRA BITS - Hacktop Real-Time Boot Comparison - Computerphile
EXTRA BITS - Hacktop Real-Time Boot Comparison - Computerphile
Computerphile
50 EXTRA BITS - Making a Bootable USB in Linux - Computerphile
EXTRA BITS - Making a Bootable USB in Linux - Computerphile
Computerphile
51 EXTRA BITS - Installing Ubuntu Permanently - Computerphile
EXTRA BITS - Installing Ubuntu Permanently - Computerphile
Computerphile
52 The Dawn of Desktop Publishing - Computerphile
The Dawn of Desktop Publishing - Computerphile
Computerphile
53 What is Bootstrapping? - Computerphile
What is Bootstrapping? - Computerphile
Computerphile
54 Reverse Polish Notation and The Stack - Computerphile
Reverse Polish Notation and The Stack - Computerphile
Computerphile
55 Home-Made Z80 Retro Computer - Computerphile
Home-Made Z80 Retro Computer - Computerphile
Computerphile
56 Should Everybody Learn to Code? - Computerphile
Should Everybody Learn to Code? - Computerphile
Computerphile
57 Programming in PostScript - Computerphile
Programming in PostScript - Computerphile
Computerphile
58 Heartbleed, Running the Code - Computerphile
Heartbleed, Running the Code - Computerphile
Computerphile
59 YouTube's Secret Algorithm - Computerphile
YouTube's Secret Algorithm - Computerphile
Computerphile
60 YouTube Search & Discovery - Computerphile
YouTube Search & Discovery - Computerphile
Computerphile

This video teaches how to convert 3D representations into pixels on a screen, covering key concepts in computer graphics and graphics programming. It provides a foundation for understanding how 3D objects are rendered and displayed on a screen. By watching this video, viewers can gain a deeper understanding of the process and learn how to apply it in their own projects.

Key Takeaways
  1. Understand 3D representations
  2. Apply matrix operations
  3. Render triangles
  4. Solve visibility problem
  5. Apply lighting and shading
💡 The process of converting 3D representations into pixels on a screen involves a series of complex steps, including matrix operations, triangle rendering, and visibility problem solving.

Related Reads

📰
Why Data Structures Still Matter When You're Doing Machine Learning
Learn why data structures are crucial for machine learning performance and efficiency, beyond just interview prep
Dev.to · Ardhansu Das
📰
Stop Feeding FX Bots Price Data Only: Add a Macro Risk Gate in Python
Learn to add a macro risk gate to your FX bots in Python to avoid trading during high-risk events
Dev.to · Robert Tidball
📰
Human-in-the-Loop: Di Titik Mana Otomatisasi Harus Berhenti
Learn when to limit automation in machine learning systems to avoid risks, and why human-in-the-loop is crucial
Medium · Machine Learning
📰
Three Python Concepts That Completely Changed How I Think About Programming
Discover three Python concepts that transformed the author's programming approach and learn how to apply them to improve your own coding skills
Medium · AI
Up next
Dropout in Deep Learning
AnuTech-CH
Watch →