Computer graphics introduction


Today we will be learning about how your computer can make all of those beautiful and stunning images appear before your eyes every time you play a game or watch a video.

First of all, how does the human eye work?

The back of the human eye is called the retina, it contains thousands of cells to receive light, there is a nerve that passes through this wall, therefore one spot of your retina doesn't receive light because it is covered by a nerve, this is your blind spot. Your brain can process images in a speed of approximately 13 FPS, which means you should have at least that many FPS for a proper animation experience. Less than that and the film will be glitchy, a lot more than than and the film will look strange, it won't look like a natural movement. Unless you are working with VR goggles, your peripheral vision can process frames faster, unlike a movie where you only use your central vision, with VR goggles you use your peripheral vision as well, meaning they have to draw at least 90 FPS to make sure your experience will be pleasant. An airplane pilot can recognize the image of an airplane in a time window of 50 milliseconds. A curiosity about FPS (frames per second) is the fact that in the beginning cameras would only film at 16 FPS, therefore televisions were calibrated to display 16 FPS, however later the cameras evolved to film at 24 FPS and therefore TVs evolved along, meaning when you watch an old film the images are fast, the guys are moving very fast, that is an accident, it wasn't supposed to be like that, it is because it was filmed in 16 FPS but it is now being displayed in 24 FPS, meaning it is moving 50% faster than it should.

How does a camera work?

The camera only takes pictures, very fast, a film is nothing more than a sequence of successive pictures taken very fast, when you watch the film the pictures are drawn very fast, causing an effect like that when you try to animate a character using a block of paper, many frames per second become movement before your eyes. Some curiosities about films, before the digital age they would use actual films, a thin layer of a material covered in chemicals that would be marked by beams of light, simply put, it was a way to print images on a film, which would then be revealed and transferred to a big piece of paper. They would at first make films out of nitrocellulose, which is very flammable, therefore movie theaters would sometimes catch fire while playing a movie with a projector. Nowadays they use silver to make the films. When you take a picture with a film they call the film a "negative", ever wondered why? Because if you look at it you will see the opposite of the actual colors of the image.

How does your computer screen work?

Your computer screen is made of pixels which are like tiny square light bulbs, some are illuminated by an LED in the back and each pixel allows a certain range of light to pass through, thus creating the colors, at least that is how it works with LCD, it is different with OLED (a much better technology). The computer draws each pixel individually, but it draws them in sequence very fast.

How does your video card work?

Your video card is like a computer, a dedicated one, it has its own memory (VRAM) and its own processor (GPU), its own cooler and it also has CUDA cores which increase its FLOPs, therefore allowing it to perform certain calculations faster than the CPU, and by the way, VRAM is faster than the computer RAM. It basically has to calculate the positions of all points on the screen and draw each pixel, one at a time, tens of times per second, and of course it must use several rendering algorithms to calculate the details of the image, such as the reflex, the shadows, the background perspective and the beams of light in the scenery. Much of the algorithmic witchcraft behind your high end 3D games is thanks to John Carmack, a brilliant computer programmer from the USA who helped make the games Doom, Quake and several others, he is still actively developing algorithms. It has to work super hard just so you can spend the night up playing LoL or GTA.

How are 3D images displayed on your 2D computer screen?

By using matrix operations with trigonometry to calculate the new positions of the pixels after they are rotated, translated, flipped or scaled. Imagine you consider all the pixels of your screen as a matrix, then you multiply each element of this matrix by some special matrices which will allow you to perform all 4 graphical computing operations on the pixels:

This matrix allows you to perform rotation:

[cos(x), -sin(x),

sin(x), cos(x)]

This matrix allows you to perform translation:

[Nx,

Ny]

These matrices allow you to perform flips:

A vertical flip:

[1, 0,

0, -1]

A horizontal flip:

[-1, 0,

0, 1]

This matrix allows you to perform scaling (resizing):

[Sx, 0,

0, Sy]

What are the differences between analogical and digital videos?

Well, simply put, digital technology works with binary code, zeros and ones, the images and sounds must be encoded as a pattern of binary code, which requires some sort of computer, and later the binary needs to be decoded into images and sounds, this part also requires some type of computer, so digital implies binary code and computers. Analogical stuff on the other hand simply converts one type of information (such as radio waves) directly into another type of information (such as images or sounds), which means it requires no computers in the process, however it is subject to distortions and interference from external physical phenomena such as lightnings or vibrations. Now, going back to the original question, how does that apply to videos? Well, when you are playing analogical videos, meaning those using actual films like in the good old days, each frame in the film is displayed on the screen as the film moves very fast thanks to a rotating engine, and of course a separate machine plays the audio of the film, do it fast enough and you will get people walking around the screen while a nice music plays in the background. Just as the images are just tons of frames being drawn successively, the soundtrack of the film is just many short fast sounds being played successively.

How can you apply what you've learned here when you are making your own games?

Think about how many FPS this game will require, remember that less FPS means the game will be more backwards compatible with older computers, more FPS means the game will have a better quality but it will require a better computer. However nowadays the computing power of the modern personal computers is so high that you can usually make your game with high FPS and it will run smoothly on most PCs out there.

How do you make your own computer animations?

It is not too difficult, if you have all the frames for the animation then you just need to write a code that will draw the frames on the screen, one at a time, fast enough so it will look alive, the hardest part is coming up with all the frames, you may need help from a visual artist (they deserve a lot more respect than they currently get). Writing the code is easy nowadays because there are game engines out there that will do the trick for you, so you don't need to be a bad ass programmer to make a high end game anymore, the engines make it all easy. One curiosity about animated cartoons is that they only have 8 FPS or 12 FPS, which means each frame must be drawn 2 or 3 consecutive times to make 24 FPS.

To finish this article I would like to suggest you watch the video of the link below, it is very informative, easy to understand and only 7 minutes long.

https://www.youtube.com/watch?v=-4_OU95nKuU

Comments