Thursday, 20 June 2013

Graphics Pipeline

Graphics Pipeline



The compuer determines the positions of all the vertices to make up the models in the scene you're rendering. After this, the computer takes the current view of the scene/object you have it in and then converts it into a 3D image. This is called a render.

The component which is responsible for letting you view 3D objects is the camera. In order to give the 'illusion' of a 3D in a 2D screen. The camera first notices all the vertices, polygons and edges which are closest to the camera and it processes them as the largest parts of the image to give it depth when displayed on screen. There are some issues it would come across when processing all this which the graphics pipeline will sort out. The graphics pipeline is a number of proccesses an object must go through in order for it to be displayed on the screen as it would be displayed in real life.

Lighting is also important for depth. Without the camera, you can't see the object and without lighting or shading, the image looks flat and has no depth. If it didn't have lighting and shading, when the image is rendered in 3d you wouldn't be able to notice the sides of the object and it would just look like a textured 2D shape.

The object would first go through Vertex proccessing. This is when the vertices are transformed into screen space. After this it goes to Triangle Setup and is rasterized which generates the pixels. Occlusion Culling is used on the object which is when it will delete hidden pixels, therefore making it quicker to render. After the hidden pixels are deleted, the valus for all the pixels are rasterized (this is called parameter interpolation). The pixel shading is then applied and the object is texturised which determines the colours, transparancies and depth of the pixel. Lastly, the Pixel Engines. The final hidden surface test, it blends with frame buffer and writes out new color and depth values.

A 3D render of a truck. When the graphics pipeline goes through the process of transforming a 3D object into a 2D image, the final product is the scene converted into pixels.

Shaders

Shaders


Shading is a graphical/physics feature used in 3D modelling. There are many types of shading. 3D computer graphics often rely on a simplified reflection model called 'Phong Reflection Model'. In refraction of light, an important concept is the refractive index which is reffered to 'Index of Refraction (IOR)' in most 3D moddeling software applications.

There are many types and ways to do shading on a 3D object. A simple way to shade a model is via texture mapping. Three types of shading, Flat, Goroud and Phong shading are typically used types shading in 3D objects.

Flat Shading: Flat shading is the most processor friendly. However, the problem with it is it looks rather rough and blocky and even kinda outdated. For simpler 3D applications, Flat shading is a good choice.

Goroud Shading: Is more processor intense than flat shading and could take longer to render but it is much more smoother than flat shading. Where flat shading would bring out the polygons when rendered and lighted, Goroud shaded models look very smooth when rendered. It is a very commonly used type of shading.

Phong Shading: Phong Shading requires the most processing power out of all three of the shading types I am talking about. Phong Shading is better than Goroud Shading for when it is applied to a reflection model that has small specular highlights. It also produces an even smoother surface than Goroud Shading.


Comparision of Flat shading, Goraud Shading and Phong Shading.

Another technique of shading is bump mapping. This is a technique I like very much besause it makes 3D objects look more detailed than they actuallly are. It is composed of two textures, the original texture that is the same colour as the texture that would be used on the object and the 'normal map'. The normal map is the main thing behing bump mapping. It is of a different pallete than it's original texture. A convienant way to create one is to download the NVidia Normal Map Filter onto Photoshop. You then load the texture onto photoshop and apply the filter. You can edit the strength of it and you can also preview it in a 3D view to see how it would turn out like.

 

Example of a normal map.


 
 Bump Mapping: Without and With.

Shaders can be added in game engines like Unity. for example, Cel Shading. Cel Shading is a type of shading which gives the models a cartoony look to it. It is used in many games to achieve this look (e.g. No More Heroes, Zelda: The Wind Waker and Borderlands).

Screenshot of No More Heroes. A game which makes use of Cel-Shading.

Application of 3D

Application of 3D


The use of 3D objects far exceed video games. It is used a lot in the media industry. A very notable example being 3D animated movies.

Most animated films which are given theatrical releases these days are animated in 3D. Pixar and Dreamworks are the most notable companies who produce 3D animated movies.
Dreamwork's Shrek (2001). A very popular movie franchise animated in 3D.
Pixar are noted for the popularity of 3D animated movies. They started making shorts in the 1980s. Their first short was Luxo Jr. (1986) which features a Lamp who then went on to become Pixar's mascot.
Luxo Jr.
In 1996, Pixar's first feature length animated film was released by Disney, Toy Story. The film became a huge worldwide commercial success and made Pixar massive. From then on, CGI animated movies started to get more and more popular and today it has become very common in cinema.

Just like how computer hardware is upgraded allowing users to create more detailed models in games, the same applied for movies. The difference is between games and movies is that a CGI movie doesn't need extremely good hardware to view (although HD has become more common which would require a HD TV and an updated player like a Blu-Ray player). CGI films are fully rendered video files and aren't running in real time, so they can be viewed on any device which allows video viewing. The file size depends on the quality of the movie (HD is more larger in size than Standard Definition films) as well as how long it runs. So it's not any different than any other movie.

Brave (2012) by Pixar. As software and computer hardware got better, they were able to make much more visually appealing movies. Brave also makes use of physics, giving the character more relaistic features (like hair rendering) which gives it more of a realistic feel when compared to earlier movies like Toy Story and A Bug's Life.

3D animation has also been known to have been used in 2D animated cartoons, like Futurama.

In scenes of Futurama (like when the Planet express ship is flying through space), objects in the scene rotates around the ship very smoothly, these are often cel-shaded objects.

It's also used in live action movies for special effects. For example, putting a character like a dragon in. They would have been created using 3D software.

James Cameron's Avatar (2009). The movie used a lot of 3D software and the hardware required for it was very intense and expensive. The entire movie costed between $280 and $310 million to create.

Comparing 3D Software Applications

Comparing 3D Software Applications

There are many different 3D software applications. Good examples being Maya, 3DS Max and Google Sketchup. I am going to compare Google Sketch-up and 3DS Maz as these are the only 3D Software applications I have a significant amount of experience with. and then give my personal opinion on what I think is best.

1. Google Sketchup
Google Sketchup has its pros and cons. A big pro is that it's free, unlike Maya and 3DS Max. Other features include the sketch-up store where you can download models people have have uploaded using sketch-up and import them into your own. It's rather simple making rectangular based objects (like buildings) and you don't have to convert each object to an editable poly to change and manipulate polygons on the object. However, Making more rounded objects is more difficult in this when compared to 3DS Max and you can't extrude rounded sides of objects (like the size of a cylinder). You can't add segments on objects and options are rather limited with most of the editing options being limited to the toolbar.

2. 3DS Max.
3DS Max is the software I'm most familiar with as I used it a lot in college. There are many things you can do using the software. For example, unlike Sketch-up you have hundreds of options to choose from. Texturising objects are more convieniant and you can add segments to objects. Although to edit the polygons on the object it must be converted to an editable poly (which also disables the feature to be able to change the number of segments), but it's very simple to convert, all you have to do is right click on the object, select 'convert to' and then select 'convert to editable poly'. When you do this, you are introduced to many different ways in which you can modify the polys on your object. You can select the polys, verticies and edges and change them by moving them around, rotating or changing the size (the more polys you have on an object, the more you can do with it). Other features include extruding the object, inset and bevel. These features also add more polys to your object which is good if you need more to add more features to your object (but too many polys means longer rendering times). It also has it's own rendering tool which is as simple as click on the icon and you get a rendered image of your object, although it's better to add lighting options to it to bring out its detail. It can also handle normal/bump mapping. With the many texturing features it has, you can add normal maps to your object and alter the strenght of it. However, to view how the bump mapping on the object you have to render it. The textures always show up as flat on the editor.

For me it's a no-brainer, 3DS Max is the best. Whilst Sketch-Up is easy for beginners and is the better choice for a person in the construction industry (e.g. creating 3D objects for a house plan), 3DS max is much better in every other field. You can make all sorts of objects even up to a proffesional quality depending on how much experience you have with the software. It takes some time and learning to get used to 3DS max, but for me, it's the ideal 3D Software Application.

Geometry Theory

Geometry Theory

3D objects are made up of 3 elements. The first are the polygons. Polygons in 3D modelling is similar to polygons in 2D. Polygons are 2D shapes which connect to the vercities in order to put together the 3D mesh. Vertices are the points which bring the polygons together. Vertices are the 2nd elemant which makes polygons. The third are the edges. The edges are the same as edges in anything else, they are the sides of the polygon. There are different software applications to create 3D models. Examples being 3DS Max, Google Sketchup, Maya and Blender.
The Blender test model, showing the edges around it which shows the elements that make the model.

3D modelling is used in many different subjects like Movies, Video Games, Science and in the Architect/Construction industry.
What connects them (triangles, lines, curved surfaces, etc)

Verticies have very much to do with coordination. It has 3 different co-ordinates. Co-ordinates X, Y and Z.
The Z co-ordinate indicates the object's movement up and down.
The X co-ordinate indicates the object's movement from side to side
The Y co-ordinate indicates the object's movement from going forward and backwards.

Screenshot of a sphere from 3DS Max showing the co-ordinates and their directions.

Model Constuction

Model Construction

With my experience of 3DS Max I developed a much larger understanding of how 3D models are contructed. Adding more length/height/width segs to a box object gives it more faces (which also means more polys) so you can morph it onto more complex shapes using the 'edit poly tool'




I added 3 length segs and 3 height segs to my box. I am going to make it into a house.

Converting the object to an editable poly is simple. Using your cursor, right click on the object, select 'convert to' and then select 'convert to editable poly.



Converting my box into an editable poly.
When you convert the object to an editable poly, you are taken to the modifier tab where there are many options which you can use to edit your object. I'm going to be focusing on the selection tools. Slection tools let you select a certain polygon of the object (or multiple parts if you hold down ctrl). Below is a screencap of the tab with the selection tools labeled.


Now I'm going to start editing the object. I will start with selecting the middle polygon on the top of the object. Then, I'm going to click on the 'move' button so I'll be able to move the polygon up (which stretched the ends of other polygons connected to it).

Then, I'll select Edge tool and select one edge of the polygon and move it to the side a little, I will do the same with the other edge but I'll move it in a different direction.

The third set of edges that go through the sides, front and back of the box, I am going to move up a little. After that, I'm going to use the 'extrude' tool. Edxtruding a polygon means expanding it to either the front or back (this adds more polygons to the model)

The last thing I am going to do is select the bottom center polygon in the front and extrufe it backwards to create a hole for an entrance.

After doing that I deleted the selected polygon and made a render of my object.

 
This is a video of a rendered object I made in 3DS Max rotating.

Tuesday, 2 October 2012

Constraints of 3D

Unit 66- Constraints of 3D


Comparison between Yoshi's model in Super Smash Bros (N64)
on the left, and Yoshi's model in Super Smash Bros Melee (GameCube)
on the right.
In video games, 3D models are made up from polygons. As games consoles got more powerful and advanced, this allowed for more detailed 3D objects. The more polygons a model has, the more detail can be added in it. But for games which feature very high poly models and environments, more powerful hardware is required to be able to run these type of games. Because when there are a lot of polygons in a model, the GPU (Graphical Processing unit) needs to be able to process these graphics fluently. And the CPU needs to be able to process the game quickly, for example, games are expected to run at 60 FPS (Frames per second). On a PC, if a game is being run on a machine where the hardware is too limited to be able to play the game, sometimes it wouldn't often work at all, or if it does, it would run too slow (maybe even around 10-20 FPS) because there is so much to process, but the CPU and GPU aren't powerful enough and take too long to process it.

When developing a video game, the developers are given constraints (for example, a character model can be no more than 3000 polys). They generally shouldn't go over these constraints. Of course, when developing a game for a more powerful console (like the PS3) constraints are often higher due to it being able to handle more detailed 3D models. But on a console like the Wii, due to it's much inferior hardware, the constraints will be a lot more lower for the game to be able to run smoothly. This is why when you a game is ported to a platform with lower specs, features of the game (most notably the graphics) have to be dummed down in order for the system to be able to run it.