How 3D Models are Displayed
The graphics processing unit can show 3D animation by rendering information such as textures, lighting and shadows to match a 3D environment created on a computer system.
a GPU will receive information from the CPU about what to render, then it will render this information using the two main ways of rendering, either rasterisation, or raytracing.
If rasterisation is used then a 3D triangle will be placed onto the 2D screen and working out which pixels it is covering. These pixels will then be set to the appropriate colour.
If raytracing is used then the GPU will trace the path of light through the pixels, stopping at the first piece of geometry and simulating the effects. Raytracing can produce much more realistic effects than rasterisation, but it costs a lot more computational power.
Because of this rasterisation is used for more speed reliant rendering, such as in video games. Raytracing can be used for rendering ahead of time, such as in film and TV.
API
An API (Application Programming Interface) is an interface a game engine can use to understand how to interact with an object, using the APIs protocols, routines and tools. An example of an API would be OpenGL for 3D graphics.
Operating Systems can provide an API for programmers to use, which is useful as this means all programs written with the API would have a similar understandable interface for end users. APIs are good for programmers as well since before they were available the graphical part of a program had to be rewritten for each operating system, and would have to be made sure it is compatible with most hardware.
Graphics Pipeline
The graphics pipeline is how the 3D information is converted into images and videos displayed on the monitor. There are many stages to the graphics pipeline.
The first stage is looking at the scene using geometric primitives. This is done using triangles as they can only ever be non-planar(they can only exist on one plane, they can't be 3D shapes). Anything else must be broken down into triangles to be understood and rendered.
Secondly the local coordinates of the object's transform is changed into the 3D world coordinate system.
Next the 3D world coordinate system is changed to the 3D camera coordinate system. For this the location of the camera acts as the origin.
Now the effects of lighting is calculated and shadows are formed. If a bright coloured object is in a room with no light it will appear dark to the camera, as it is in a shadow since the light has been calculated. Reflections are also calculated in this step.
The 3D coordinates are now shown as 2D through the view of the camera. If the view is orthographic then everything will appear to be on the same plane as they keep the same size regardless of distance from the camera. If the view is perspective then the objects 3D position is shown in the camera as objects further away become smaller. This is achieved by dividing the x and y coordinates of each vertex of each primitive by its z coordinate.
Next geometry which isn't inside the view of the camera will not be visible and will be ignored.
At this step the 2D image goes through the rasterisation process, where operations are done to each individual pixel.
Lastly colours are assigned to the image through either a texture saved in memory, or a shader program.