Building Blocks – Vertex and Pixel

In this tutorial which is part of this series, we will discuss two basic elements without which graphics couldn’t exist: the vertex and the pixel. Understanding these building blocks is important moving forward, so pay attention.

As everybody points (hah! pun) out, the correct plural to this verb is vertices. Not that you didn’t know that already, it’s just that this is the standard way to start a talk about vertices. But enough grammar. The vertex is the most basic building block in a computer generated space. It’s the equivalent of a point in geometry. It lacks size (at least in theory, in practice you can actually set the size of the vertex when working in OpenGL) and it occupies (although occupies may not be the right word, because as we have established, it doesn’t have a size) a certain spot in 3D space, as described by 3 coordinates.

As you probably know, 3D space implies that there are 3 dimensions and thus 3 axes in Cartesian Coordinates as we can see in the following image:

The red is X-axis, green is Y-axis and blue is Z-axis

And of course, they all unite in vertex (0,0,0) and if you prolong each of them in the opposite direction, you will get the negative axes. Now, having this world defined by these 3 axes, we find ourselves in the situation of being able to place a vertex at any location imaginable. We can even place 2 vertices at a ludicrously small distance (for example, 0.00003 units in computer space) and they will register as separate vertices (even though on-screen you will see just one vertex, unless you position your camera just right).

Now, as I said, vertices are the building blocks of everything you will see in a 3D environment, the most basic things being primitives, such as lines (or edges), triangles, quads (if you’re running a pre-3.1 OpenGL version). In the next part of this series, you will learn to set up basic shaders and begin to draw vertices, however now we shall move on to the pixel.

The Pixel

We’ve talked about computer space, a virtual environment programmable exclusively through software; however the pixel is more of a physical entity. Presumably right now you are reading this article via electronic means. That screen which you’re staring at (allegedly ruining your eyes in the process) is composed of a large number of tiny cells, each with its own color. The number of the pixels can be determined by knowing the resolution. So, a screen which can accommodate a maximum resolution of 1080p (or 1920×1080) has about 2,073,600 physical pixels.

Moving on to pixels in relation to the OpenGL window created in the previous tutorial, let’s talk a bit about the process of converting the abstract computer space as created in code to what we will see in a window in future tutorials. You see, once you create a virtual space, you will need a point in that space from where you can observe it. Through a series of transformations which will be explained in a future tutorial, an image will result in the window. During that chain of transformations, each pixel makes up a small part of the viewed scene (like a jigsaw puzzle piece) each which has a (2D) location and a color assigned to it.

Zoom in on the nose

This is basically all you need to know about the pixel at this point. It’s the smallest component of an image and it has only one color. Of course, depending on the number of bits the color can be described by, the image can have different levels of quality (for example, 1 bpp – bit per pixel – means a black & white image, 8 bpp means greyscale all the way to 24 bpp, with 8 bits per individual color – red, green and blue – leading to a 2^(8*3) = 2^24 = 16,777,216 possible color permutations). This sounds like a lot but we’ll see that there are reasons to use a higher bit depth — namely quality to better match what the eye+brain really can see. i.e. 256 shades of primary colors aren’t enough.

In a nutshell, the vertex is a 3D point consisting of 3 dimensions: x,y, and z and the pixel is 2D point consisting of 3 (or 4) color channels: red,green,blue, and optionally alpha (we’ll deal with this sucker when we reach transparency).

With these 2 fundamental building blocks, an entire universe of virtual space is at your fingertips. So, let’s begin abusing our power, shall we? See you in future tutorials.

I'm an engineer, currently employed at a financial software company. My interests include gaming, LPing and, of course, reviewing, but also game dev and graphics. Also, in the past I've dabbled in amateur photography, reviewing movies and writing short stories and blog posts. I am also a huge Song of Ice and Fire fan, but that's beside the point. Youtube Channel, Deviantart , Google + , Twitter