Jump to content
  • Advertisement

Computer Graphics




Hi, I'm Paul Miller and today's topic is computer graphics. When you make your first game you will notice that you spend huge amount of time working on your visuals. Delivering great looking graphics is the main challenge in game programming. It's so important that whole companies were built around making things look better. In this article we will explore fundamentals of this field.


Computer graphics history started in the 50's with the first digital machines. Initially drawing anything was a challenge. Hardware was extremely limited and first displays were very primitive. One of the first games ever to feature any visuals was Tennis for Two. It was developed by William Higinbotham from  Brookhaven National Laboratory using an analog computer and it displayed its output on an oscilloscope. This game was somewhat similar to Pong, but it felt more like real tennis. The phrase "computer graphics" itself was coined in 1960 by William Fetter, a graphic designer for Boeing. The 70's saw a lot of progress, especially in the University of Utah. One of the enduring symbols of that era is the famous teapot model created by Martin Newell.

In the 90's first accelerated 3D graphics card were developed for the home market. Although professional graphics workstations were available earlier from Silicon Graphics and others, it's the invention of a modern Graphics Processing Unit or GPU for home computers which transformed the landscape for gaming. The first commercially successful accelerator was 3dfx Voodoo 1 card. It paved the way for all the modern cards we have today. 3dfx pioneered hardware rasterization for the home market and changed the world. Later 3dfx made several business blunders and went bankrupt. Nvidia, today's powerhouse, acquired their assets and hired their best engineers.

Rendering in modern games is highly standardized. The era of wild innovation is over. In the past people like John Carmack could invent whole new rendering systems, unlike anything before. Today it doesn't happen. The closest match would be Minecraft with its voxels, but even that game is largely based on classic rasterized rendering principles. Modern graphics hardware is optimized for drawing very fast lots of triangles with custom shaders. This unification of graphics technology has some big advantages. You aren't expected to reinvent the wheel every few years. If you learn solid theoretical principles you can apply them directly to your games, without a need for some kind of crude optimization hacks. Modern game renderers draw inspiration from the latest graphics research with ease.


Two main methods of creating CGI today are rasterization and ray tracing. Rasterization is a process which takes vector data and converts it to pixel data. For ex. it takes three point description of a triangle with its color and it can draw on screen a group of colored pixels which look like a triangle. All modern computer games use this technique. In the past some games used other methods to draw 3D graphics. For ex. Wolfenstein, Doom and Duke Nukem 3D were based on variants of ray casting. There wasn't a single triangle drawn in those games. Ray tracing is used for offline rendering as seen on TV or in cinemas. It works  by tracing virtual rays from the camera. Early ray casting engines were in many ways more similar to ray tracing than to modern methods. Ray tracing is a technique which allows for higher image fidelity but it's too computationally expensive for interactive software. Recent advances in graphics hardware promise bringing true ray tracing to home computers as an auxiliary method of rendering for those phenomena which can't be accurately reproduced with rasterization.


Computer graphics is a large field with a well developed body of knowledge. However to find your way around all that wealth of information you need to be familiar with just a few key concepts. In the reminder of this article I will mention some fundamental ideas which you should research further to gain practical understanding. The four main elements of any 3D image are: models, lights, cameras and the screens. Models are typically composed of triangles which make meshes. Lights are objects placed in a scene in order to control shading of models. This process of shading is accomplished using little GPU programs called shaders. Cameras are used to control transformations of 3D objects and their operations are implemented using matrices. Finally, the screen is where it all ends, but even at this stage you can apply various image-based effects in order to stylize your output.


In order to render any 3D image on screen there must be some kind of transformation system in place. The problem is that when you have a vector model in a file your computer has countless ways to present it on screen. Transformations are geometric operations implemented using matrices which convert 3D data from object space to screen space. There are three commonly used transformations in a stack: object space to world space, world space to camera space and camera space to screen space. This transformations are combined into a single matrix which is applied to all triangle vertices per frame. Note that this process doesn't show anything on screen. It's just a mathematical conceptualization of operations in 3D space. In order to see something on your monitor the output of transformations must be rasterized or ray traced.

Modern video games commonly use a concept of a scene graph. This graph is data structure which holds description of the main elements of the 3D area which should be rendered. It's a hierarchical structure based on a tree. Each scene graph has a root, various branches and ultimately leaves. These leaves might be for ex. meshes or other primitives supported by the renderer. Scene graphs are very important in games because many optimization techniques depend on them. When you think about a complex 3D environment in a game always remember that it can be completely reduced into a single hierarchy of objects which are then treated in a rather uniform way. An image may look very complex, but inherently it's handled by just one big data structure which handles most spatial relationships between objects.


While thinking about rendering solutions for your game it's useful to have a working model of the whole graphics processing pipeline. Going into details of this could easily fill a book and such books are already written. Now, I would like to share with you a very coarse, but solid, high level view of the stages in frame processing. The four main stages in order are: scene extraction, frustum culling, visibility estimation, occlusion culling. Scene extraction means that your game must define very broadly what should be drawn as a fragment of your whole game world. Frustum culling removes from processing all elements which are certain to be outside of the current camera view. Visibility estimation is often called PVS stage, or Potentially Visible Set. This stage further eliminates hidden objects. Finally, we have occlusion culling which again, removes hidden objects which are occluded by something else looking from the camera position.

There are great many books about computer graphics, but only a few true classics. "Computer Graphics - Principles and Practice" is a classic CGI bible for all people who want to learn the basics. "Real-Time Rendering" by Akenine-Moller is another classic which is more suitable for computer game programming. "Graphics Shaders - Theory and Practice" by Bailey & Cunningham is an excellent introduction to shader development. "The Image Processing Handbook" by Russ & Neal is a solid choice for learning pixel manipulation techniques.

I hope you enjoyed this brief overview of computer graphics. Game development is centered around creation of visuals and it will never change much. Next topic is artificial intelligence. If you enjoyed this article: like it, comment it, share it and consider supporting me on Patreon. That's all for today. Thank you for your time.

My Facebook: https://www.facebook.com/PaulMielcarz
My Twitter: https://twitter.com/PaulMielcarz
My LinkedIn: https://www.linkedin.com/in/paulmielcarz
My Patreon: https://www.patreon.com/PaulMielcarz


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!