coreymartingames.weebly.com€¦  · Web view3D objects are stored as points in the 3D world...

12
The Importance of a Renderer What exactly is the renderer and why is it important? Well, without it you are not able to see anything. It visualises the scene for the player/viewer so he or she can make appropriate decisions based upon what is displayed. In this section we will explain key aspects of what a renderer does and why it is so necessary. The renderer is generally the first thing you tend to build when constructing an engine. But without seeing anything, how do you know whether or not your code is working? The renderer is where 50% of the CPU’s processing time is spent and where game developers will often be judged most harshly. If they get it wrong, the game and the company can become the industry joke in a short time! It is also where they are most dependant on outside vendors and forces, and the area where they have to deal with the widest scope of potential operating targets. Without a good renderer, the game would probably never make the top 10. The business of getting pixels on screen these days involves 3D accelerator cards. API’s application program interface, three dimensional math and understanding of how 3D hardware works and a dash of image dust. For consoles, the same kind of knowledge is required, but at least with consoles you are trying to hit a moving target. A console’s hardware configuration is a frozen ‘snapshot in time’ and, unlike the PC, it does not change at all over the lifetime of the console. 3D objects are stored as points in the 3D world (called vertices). With a relationship to each other, so that the computer knows to draw lines or fill surfaces between these points in the world. Therefore, a box would have 8 points, one for each of the corners. There are six surfaces for the box, one for each of its sides. This is how the basis of 3D objects are stored. When you start getting down on some of the more complicated 3D stuff, like a ‘Quake’ level for example, you are talking about thousands of vertices. Culling Methods Corey Martin

Transcript of coreymartingames.weebly.com€¦  · Web view3D objects are stored as points in the 3D world...

Page 1: coreymartingames.weebly.com€¦  · Web view3D objects are stored as points in the 3D world (called vertices). With a relationship to each other, so that the computer knows to draw

The Importance of a Renderer

What exactly is the renderer and why is it important? Well, without it you are not able to see anything. It visualises the scene for the player/viewer so he or she can make appropriate decisions based upon what is displayed. In this section we will explain key aspects of what a renderer does and why it is so necessary.

The renderer is generally the first thing you tend to build when constructing an engine. But without seeing anything, how do you know whether or not your code is working? The renderer is where 50% of the CPU’s processing time is spent and where game developers will often be judged most harshly. If they get it wrong, the game and the company can become the industry joke in a short time! It is also where they are most dependant on outside vendors and forces, and the area where they have to deal with the widest scope of potential operating targets. Without a good renderer, the game would probably never make the top 10.

The business of getting pixels on screen these days involves 3D accelerator cards. API’s application program interface, three dimensional math and understanding of how 3D hardware works and a dash of image dust. For consoles, the same kind of knowledge is required, but at least with consoles you are trying to hit a moving target. A console’s hardware configuration is a frozen ‘snapshot in time’ and, unlike the PC, it does not change at all over the lifetime of the console.

3D objects are stored as points in the 3D world (called vertices). With a relationship to each other, so that the computer knows to draw lines or fill surfaces between these points in the world. Therefore, a box would have 8 points, one for each of the corners. There are six surfaces for the box, one for each of its sides. This is how the basis of 3D objects are stored. When you start getting down on some of the more complicated 3D stuff, like a ‘Quake’ level for example, you are talking about thousands of vertices.

Culling Methods

Here is a problem. Consider a world described by several hundred thousand vertices polygons. Imagine a first person view that is located on one side of our 3D world. In this view there are some of the world’s polygons, though others are not visible, because some object or objects, like a visible wall, is obscuring them. Even the best game coders cannot handle 300,000 triangles in the view on a current 3D card and still maintain 60FPS (a key goal). The cards simply cannot handle it, so we have to do some coding to remove those polygons that are not visible before handing them to the card. The process is called Culling.

Corey Martin

Page 2: coreymartingames.weebly.com€¦  · Web view3D objects are stored as points in the 3D world (called vertices). With a relationship to each other, so that the computer knows to draw

Portal Rendering

For example, in a computer game such as Descent, the game area might be divided into several zones. These zones would be then connected to each other by small openings such as doors or windows. These doors are referred to as portals. When the zone behind a portal needs to be drawn, the only parts that are visible are the parts that can be seen through the portal. Therefore, the zone can be clipped against the portal boundaries to remove overdraw.

The use of portals simplifies the game engine’s task of determining visible areas and objects from any given point of view of the level and simplifies rendering by allowing it to use a portal as a viewing frustum for the area it leads to. Ideally, portals are formed of confined areas (like doors or tunnels), connecting to complex areas of the scene, where each of the areas would be enclosed in such a polygonal body.

Portals are best suited for indoor scenes such as mazes. Outdoor scenes do not usually have door-like objects that would clearly separate one zone from another.

Binary Space Partitioning

In computer science, binary space partitioning (BSP) is a method for recursively subdividing a space into convex space by hyperplanes. This subdivision gives rise to a representation of objects within the space by means of a tree data structure known as a BSP tree.

BSP was developed in the context of 3D computer graphics, where the structure of a BSP tree allows spatial information about the objects in a scene that is useful in rendering, such as their ordering from front-to-back with respect to a viewer at a given location, to be accessed rapidly. Other applications include geometrical operations with shapes (constructive solid geometry) in CAD, collision detection in robotics and 3D video games, ray tracing and other computer applications that involve handling of complex spatial scenes.

Back-face Culling

In computer graphics, back-face culling determines whether a polygon of a graphical object is visible. It is a step in the graphical pipeline that tests whether the points in the polygon appear in clockwise or counter-clockwise order when projected onto the screen. If the user has specified that front-facing polygons have a clockwise winding, if the polygon projected on the screen has a counter-clockwise winding it has been rotated to face away from the camera and will not be drawn.

The process makes rendering objects quicker and more efficient by reducing the number of polygons for the program to draw. For example, in a city street scene, there is generally no need to draw the polygons of buildings facing away from the camera as they won’t be seen.

A related technique is clipping, which determines whether polygons are within the camera’s field of view at all.

Another technique is Z-culling or occlusion culling, which skips polygons that are covered from the viewpoint of the camera by other visible polygons.

Corey Martin

Page 3: coreymartingames.weebly.com€¦  · Web view3D objects are stored as points in the 3D world (called vertices). With a relationship to each other, so that the computer knows to draw

Culling Methods: Clipping Planes

These are the distances that the camera starts and stops rendering at. In Forza 4 the developed clips the planes as on Fujimi Kaido while you are going up one side of the mountain you can’t see the other side of it so it isn’t drawn until you can see it but then the parts you can’t see aren’t drawn. This is done so that the game can be run on a less powerful machine so the game will sell better as some of the track isn’t rendered.

Shaders

The shader in a game is a computer program that does the shading of objects in the game and it controls the colours and the levels of light. They also now control the special effects for the game and can calculate rendering effects on the graphics hardware with flexibility. Shading languages are used to program the GPU (graphics processing unit). The position, hue, etc. are used to create the final image of the object.

Anti-Aliasing

This is a way of smoothing the edges of the polygons. Computers use pixels but real objects have curves and straight lines. When these are displayed on a monitor they have jagged edges instead on curves. It slightly blurs the edges so that they look better and don’t look as jagged as they usually do.

Level of Detail

The graphics in a computer game can be decreased which makes everything less complex but also makes the game run easier and usually faster. This can involve decreasing the range it is seen at or even the speed it looks like it is going like in racing games a car. For the computer to run a high level of detail it will need to have a high power processer and other high power parts.

Occlusion Culling

This is important to remember when getting a good balance in size of objects and also cells. Cells should be made so they aren’t too small but also not to big so they don’t cover too many cells. A way of improving culling is to break large objects into smaller pieces. You can still merge small pieces together to reduce the drawing cells as long as they are all connected to the same cell. The collection of the cells and the visibility of them determines which are visible from any other cell and is known as PVS (Potentially Visible Set).

Corey Martin

Page 4: coreymartingames.weebly.com€¦  · Web view3D objects are stored as points in the 3D world (called vertices). With a relationship to each other, so that the computer knows to draw

Vertex Shaders

These are run once for every vertex given to the processer and their purpose is to transform each one’s 3D position in virtual space to a 2D position which appears on the screen. These shaders can change properties like the objects colour or its position but can’t create more vertices. Vertex shaders can give good control over the position, lighting, movement and colour in scenes involving 3D models.

Frustum Culling

This is the region of space in the game world that has a chance of appearing on the screen as it is the field of view of the notional camera. The shape of the region can vary depending on what shape is being simulated but it is usually the frustum of a rectangular pyramid. The planes that cut the frustum’s perpendicular are the near and far planes. Objects that are either closer than the near plane or beyond the far plane aren’t drawn but sometimes the far plane is set infinitely far away from the camera so all the objects in the frustum are drawn no matter how far away they are from the camera.

Radiosity

Radiosity is a more complicated way of looking at light that is reflected. It includes taking tiny elements and calculating how light reflects off of different objects. This makes it so that light is able to be reflected off of different objects in the game and not only able to directly reflect like the reflection of the road in Forza 4 from the sun onto the road and then reflected into your eye so that you see it.

Ray Tracing

This is a technique that includes tracing the light path through the pixels of an image plane and by simulating the effects of the lights encounters with any of the virtual objects. It is also a technique that can help to create a high degree of visual realism and can create a better level of visual realism than the typical scanline rendering methods but it is a lot more expensive. It is capable of simulating a big range of different optical effects such as reflection and dispersion phenomena.

Texture Mapping

This is applied to the surface of a polygon or even a shape and is similar to the process of applying a pattern to a blank object. In texture mapping every vertex of a polygon is given a texture coordinate through either of procedural definition or explicit assignment. Image sampling locations are then inserted along the face of the polygon to create a visual result that is much better than achievable with a limited number of polygons.

Corey Martin

Page 5: coreymartingames.weebly.com€¦  · Web view3D objects are stored as points in the 3D world (called vertices). With a relationship to each other, so that the computer knows to draw

Multitexturing

This is the use of multiple textures at one time on a polygon like if a light map is applied to light up a surface as another way instead of having to recalculate the lighting every time the surface has to be rendered. Another technique of this is bump mapping which allows a texture to control the direction the surface is facing directly so the lighting can be calculated. It has started to become popular in modern video games for graphics hardware as now they are powerful enough to use it real-time.

Fogging

This is a technique used to clip polygons as old processers weren’t powerful enough to render far distances. However it sometimes was distracting as some pieces of the polygons would flicker out of and into view constantly that meant that by applying a middle ranging fog the polygons that had been clipped would fade in more realistically.

Shadow Mapping

This is a technique in which shadows are added to 3D computer graphics. They are created by testing if a pixel is visible from a source of light by comparing it to the z-buffer (depth) of the image from the light source’s view which is stored in the form of a texture. Then the scene is rendered by comparing the depth of every point that has been drawn on the depth map. It is less accurate than shadow volumes but is a faster technique depending on how much fill time is required for each in a particular application which therefore could make it more suitable for real-time applications. They also don’t require the use of an additional stencil buffer and can be used to create shadows with smooth edges however its accuracy is limited by the resolution being used.

Z-Buffering

This is the management of an image’s depth coordinates in 3D graphics which is usually done by using hardware or sometimes in software. It is a solution to the visibility problem which is a problem that decides which elements of a rendered scene are visible and which are hidden. Also the painter’s algorithm can be used although it is less efficient to handle non-opaque scene elements. When an object is rendered the depth of a pixel is stored inside the buffer which is usually arranged in a 2D array with one element per screen pixel but if another object is to be rendered inside the same pixel then the buffer compares the two depths and overrides the current pixel if the object is closer to the player. The buffer in the end allows the method to reproduce a close object hides the further object which is called z-culling. Also the granularity of a z-buffer can have a huge influence on the quality of a scene like a 16-bit z-buffer can result in artifacts which is called z-fighting and this occurs when two objects are very close to each other. 24-bit and 32-bit z-buffers behave a lot better although they will still have the same problem without additional algorithms but an 8-bit is never used as they have way too little precision.

Corey Martin

Page 6: coreymartingames.weebly.com€¦  · Web view3D objects are stored as points in the 3D world (called vertices). With a relationship to each other, so that the computer knows to draw

Pixel Shaders

These shaders compute the colour and properties of each fragment and they range from always outputting the same colour, to applying a light value, to doing bump mapping, shadows, translucency and other phenomena. They can alter the depth of a fragment or even output multiple colours if multiple render targets are active while in 3D graphics they alone can’t produce any complex results because they only operate on a single fragment without any knowledge of the scene’s geometry. Although they have knowledge of the screen coordinate that is being drawn and can even sample the screen and any nearby pixels if the contents are passed as a texture to the shader. It can enable some 2D post-phenomena effects like blurring and edge enhancement for cel shaders. They also can be applied in the immediate stages of any 2D images (sprites and textures) in the pipeline whereas vertex shaders require a 3D model. They are also the only type of shader that can act as a postprocessor or filter for a video after it has been rasterized.

A.I

It is a branch of computer science research that studies and designs ‘intelligent agents’. They are highly technological and specialised so they will fail to communicate sometimes. A.I is a system that recognises its environment and then chooses what actions to take to maximise its chances of success. They were founded as some scientists say human intelligence can be copied digitally and it is accurate.

They have a knowledge base which consists of rules and depending on how good the rules are made determines how effective the game A.I are in different situations.

When making decisions the longer an A.I spends calculating the different options the better the resultant play. I have seen this in Forza 4 in which on easy difficulty they crash and won’t go fast and brake early for corners, while on hard they are fast and brake late for corners and will do what they can to win.

State Machines

The different NPCs will have different states which are also determined by what unit they are and also the state is important as it determines what the NPC will do. An example of this is in Rome: Total War as when you throw a peasant into battle they usually run away quickly while if you throw a squad of general’s bodyguards into a fight they will fight on not matter how bad it is going.

Planning System

It is goal based in which each step in each goal is clearly defined and all the subtasks are clearly identified. In GTA V a police officer is given a choice based on what the wanted person is doing. An example is that if the player is driving along then they will ram them off the road.

Terrain

A 3D mesh scene allows the NPCs to know what part of the terrain they can move in and where they can’t. In every mesh path finding is needed so that NPCs can find their way around the level.

Corey Martin

Page 7: coreymartingames.weebly.com€¦  · Web view3D objects are stored as points in the 3D world (called vertices). With a relationship to each other, so that the computer knows to draw

Neural Nets

This is used to try to stimulate the human brain when they are playing a game and it revolves around the idea that some of the key properties of the biological neurons can be extracted and then applied to stimulations. The reason A.I can be stupid one minute and smart the next is because the connection speed is increased which is how different in-game difficulties are made.

Fuzzy Logic

This is different from Boolean algebra as it is more accurate value wise as it allows not only true or false but also the in-between. It is also the logic of using terms to process an action through deciding what to do like in S.T.A.L.K.E.R Call Of Pripyat if a A.I is trying to kill the player in a building then they need to decide what gun to use and also if to go into a certain room or to run straight at the player. An example of this is if an explosive happens and the character is behind a door if it uses Boolean algebra then it only chooses if he was hit or not while using fuzzy logic it decides how much damage he takes.

A.I Program

All A.I should be independent of the problem domain as much as possible and should have a knowledge base, navigational capability and an inferencing. A knowledge base should make it so that the A.I programs should be learning in nature and have its knowledge updated accordingly. IT should also consist of facts and rules. The characteristics of knowledge are that it is voluminous in nature and requires a proper level of structuring. IT also may be incomplete and imprecise and it also may keep changing dynamically. The navigational capability contains various control strategies which determines the rule to be applied and it also may apply some heuristics (thump rules). The inferencing requires to search through the knowledge base and to derive new knowledge. The behaviour of the A.I can be changed depending on different situations sometimes if it is programed to change the sets of rules it will follow depending on the situation at hand.

Path-Based

This is where an in-game object or character will follow a certain path that has been programmed into its programming for it to follow when it is moving around or performing an action in the game. These usually include an enemy that is patrolling an area in an FPS game like Arma 2 where an enemy might be set a path to follow for a patrol route where it is set so that if the player comes within a certain range of the path it will attack them.

Inverse Kinematics

This is when the movement of an animated character is modelled through the use of different kinetic equations that are used to determine how it will move when it performs certain actions in a game. It is the process of converting the motion plans into the joint movement in the character as it performs the different actions.

Corey Martin

Page 8: coreymartingames.weebly.com€¦  · Web view3D objects are stored as points in the 3D world (called vertices). With a relationship to each other, so that the computer knows to draw

Forward Kinematics

This is the use of different kinetic equations of the characters to find the position at the end of a movement or action from the values that are found through the use of the equations that show the different joint parameters that are needed for the character in the game.

Particle Systems

This is a graphics technique that uses a very large number of small sprites or other graphics to make certain kinds of “fuzzy” phenomena which would normally be very hard to make using normal methods of animation. A few examples of these phenomena are fire, explosions and water in a game that all move when they are seen in a game.

Middleware

These are the off the shelf components like the rendering or the physics. They are most of the time done by game developers and are only helped with problems by the machine makers. They are the software that connects two separate applications like a render and physics and it is usually used to help make a piece of software that is being used to make a game better. A popular middleware developer is Havok who have helped with games like Mercenaries: Playground of Destruction which had good physics and also was very fast at rendering objects during gameplay so the player wouldn’t have to wait for it to render in-game objects all the time. Some other pieces of middleware can include sound, A.I, animation, modelling and texturing.

Conclusion

In games the most important thing about a game and decides highly whether the game is successful or not is the gameplay of the game as the game needs to be fun to play for the player so that they will keep playing it and will tell others that it is good as if the game doesn’t have fun gameplay but has amazing graphics it won’t do well as it will get boring for the player. Whilst a game that has really bad graphics but has fun gameplay will be successful as the player will have fun playing it and won’t care about the bad graphics as they are only a help to make the game more realistic. A good example of a game that was successful thanks to having good gameplay but had bad graphics was Carmageddon as it is still played a lot today by people and it was out in 1997. This shows that graphics aren’t really that important whilst the gameplay of the game needs to be fun to play for the player for the game to be successful.

Corey Martin