Sunday, 3 November 2013

Geometric Theory

Video games in today's world require a multitude of artists working in tandem in order to create the technically and aesthetically beautiful visuals. In order to create the worlds and characters who inhabit them, these artists require tools.


But first, an explanation of what a character, prop or a landscape is actually made of. Most virtual objects are made of "polygons". These are flat planes, generated by a linking a series of points. Typically, these planes are triangular, created with three points, although most modelling programs use squares with four points (otherwise known as quads) as these are easier to manipulate into the desire shape.
The points that define a polygon contain its coordinates in three dimensional space, xyz and also uv coordinates, points on a two dimensional plane that instructs the model how to wrap textures around its surface.

Different 3D modelling software packages excel in different areas. Also, they tend to come in two different styles: sculpting and modelling. Some examples of modelling programs include Maya, 3DS Max, Softimage and Blender. The industry standard nowadays is Maya since it encapsulates modelling, animation and basic rendering tools all in one software package and does them all well to a certain degree. On the sculpting side of things its usually either zBrush or Mudbox, with zBrush being the clear winner at this point in time. Sculpting is a process used primarily for super high detail whereas the modelling programs are used for lower detail work.


A typical workflow involves a multitude of programs. Once the concept is finalised, the modeller could begin in either Maya and import that into zBrush or just start in zBrush and build up a million polygon model with immense amounts of detail. Then, if the model is being used for pre-rendered material its pretty much ready to go, after texturing. However, if it is being used for a game that requires real-time rendering, this model (if it is a main character in a realistic game) will be reduced down to around fifteen to thirty thousand polygons and then the detail from the high poly model will be “baked” out into a normal map and an ambient occlusion map.


Example of a normal map
A normal map is an image file that is applied to a model that gives the lighting calculations inside the game engine more information and so makes the object look more detailed without requiring millions of polygons. The files are stored as RGB images (an alpha channel is unnecessary and wastes precious memory) where the RGB values correspond to X, Y, Z coordinates of the surface normal.

Ambient occlusion maps simply detail darker areas around the mesh that might be difficult for the lighting engine to react with properly. Another common texture type is specular maps with describe the shininess of an object.

A quick point about normals, they describe the facing and direction of each face of the model. This helps with lighting an object and detailing how light bounces of the surface. In a basic sense normals can either point perpendicular from the center of a face or at each vertex, averaged from the direction of the surrounding faces.


In games, because they are being rendered in real time, keeping scenes as optimised as possible is an absolute must in order to maximise potential spectacle and frame rate. As such, many little tricks have been developed over the years in order to present the illusion of a detailed scene without taking a hit on performance. One such trick developers have at their disposal is the use of LoD (Level of Detail) meshes for the same object. Essentially, multiple copies of the same model are created, each with varying levels of detail (using less and less polygons). As the object gets further away lower detail meshes are swapped in. This allows for high detail when and where its needed without sacrificing performance and allows for more objects in a scene, especially in cases of things being far away. An example used prevalently include trees in almost all games and also guns in multiplayer first person shooters. When holding a gun from a first person point of view, the gun model is very close to the camera and so requires a great amount of detail. However when seeing other player characters holding a gun, it will always be further away and so using the same model is actually quite wasteful. Therefore, an artist will create a second model of every gun that has fewer polygons and use that for anyone other than the player.
A second use of LoDs is when certain objects are being seen in different contexts. While not common, it’s useful for being able to compare examples of LoDs that will have been noticed by every player of the game. A great example of this are the Final Fantasy games, specifically, Final Fantasy 7. Renowned for beautiful graphics, the series extensively uses pre rendered videos for dramatic set pieces. In Final Fantasy 7, this is what the main character, Cloud, looks like in a pre-rendered scene.


LoD = Super high
Obviously, by today's standards this is unimpressive. But at the time, this amount of detail in a scene is extraordinary and only possible because it has been rendered beforehand. Note the number of polygons spent on getting the hair and folds of the trousers to looks smooth and realistic. Compare this to Cloud's higher detail battle model. (Note: Cloud was unique in that he had two models for battle scene, one higher detail than the other for use in a specific sequence).
LoD = Quite High
Again, unimpressive for todays standards but remember, this was rendered in real time on a processor running slower that 34 Mhz. In comparison to the first image, however, differences are large. The amount of detail for the arms and hair is much lower and the folds of his trousers look much more blocky. Now, the real comparisons begin. Comparing between objects that both need to be rendered in real time. This is the lower detail model for battle scenes.

LoD = Average
As we go further and further down the LoD chain the blockiness and lack of detail becomes more and more apparent. But more importantly, a discussion about why this is necessary. For an artist, having your work look as good as possible is a given. Therefore (most of the time) you want to use as many polygons as possible, you want to push as close to the line as you can. But of course, performance issues become a factor. In a normal battle there are usually around six characters on screen at any one time. But in one specific scene (near the end of the game) there is a fight scene in which the designers knew would have less characters in and so knew they could push the limit a bit further. On the other side of the coin, of course, is when you have more instead of less things that you want to render. And that leaves us with this guy:

Barely recognisable, with cubes for hands, is the main world version of Cloud. This low detail model is used when running around towns and cities of the game, which often contain many characters at once, requiring each on to use less polygons.

There are two different kinds of rendering, pre-rendered and real-time. As games require updating based on player input they must be rendered in real-time at a fast enough pace to look smooth. Movies, on the other hand, contain no interactive elements and so the medium is static. This allows the power intensive computational work to draw each frame to be done before hand and then saved out to a simple video file. This allows for greater amounts of detail since each frame can take minutes or hours to render rather than milliseconds that games require.

Real time rendering in games is typically handled by an API, either OpenGL or Direct3D. This negates the need for programmers to write a graphics engine but there are pros and cons to both. OpenGL's greatest strength is being multiplatform. On the PC side it will work on Windows, Macs and Linux whereas Direct3D is the 3d graphics API of Microsoft's DirectX and so is limited to Windows. However, DirectX was designed from the get go to be used for video games whereas openGL was initially developed with high performance hardware in mind for engineering and CAD software.

There are multiple techniques that 3D artists use to create 3D models. A beginner level technique is Box Modelling and as the name implies, the artist starts with a box and adds in more geometry and gradually pulls out the desired shape, increasing in detail until they have the final model. Another technique is known as extrusion modelling.  Other techniques involve starting with a sculpting program such as zBrush. Using Dynamesh an artist can quickly create a high poly, high detail mesh which is then reduced down to a low poly mesh read for games.

Well, anyway, that's a quick look at Geometric Theory, until next time!

No comments:

Post a Comment