3d gaming
1 / 29

Chapter 3 Slides - PowerPoint PPT Presentation

  • Uploaded on

3D Gaming Chapter 3 3D Concepts A computer screen is two dimensional Width and height Need to find a way to represent three dimensions in a two dimension world Need to add “depth” through visual characteristics Shading, shadows, textures Rendering

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Chapter 3 Slides' - adamdaniel

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
3d gaming l.jpg

3D Gaming

Chapter 3

3d concepts l.jpg
3D Concepts

  • A computer screen is two dimensional

    • Width and height

  • Need to find a way to represent three dimensions in a two dimension world

  • Need to add “depth” through visual characteristics

    • Shading, shadows, textures

Rendering l.jpg

  • Process of converting a 3D model to a 2D model

  • Converts an entity to be drawn in a 2D screen or image

  • Includes many processes and calculations

    • Rasterization, clipping, etc

Coordinates l.jpg

  • Math we learned X, Y

  • Z is the third dimension

  • Represented as a triplet in a vector (3 integer array) [x, y, z]

Define a coordinate system l.jpg
Define a coordinate System

  • Must assign a base (origin) point

  • Assign each dimension a positive and negative direction

  • Object space and Global space

    • Reference points

Assigning positive direction l.jpg
Assigning Positive Direction

  • Left Handed

    • X left (+)/right

    • Y up (+)/down

    • Z near(-)/far

  • Right Handed

    • X left (-)/right

    • Y up (+)/down

    • Z near(-)/far

Torque direction l.jpg
Torque Direction

  • Our direction

    • X left (-)/right

    • Y up (+)/down

    • Z near(-)/far

    • Uses Topgraphic/overhead view

3d shapes l.jpg
3D Shapes

  • A coordinate is a vertex

  • Connect 2 vertices for an edge

  • Connect 3 or more vertices that is closed for a polygon

    • Simplest shape is a polygon

    • Decomposing a complex polygon into triangles is a mesh

Surfaces l.jpg

  • The area enclosed by a triangle (polygon) is called facet (or face)

  • Each surface has two sides, but only one is visible

    • Side that is visible has a Normal

  • Hidden Lines – Lines that other polygons cover up

    • Culling is used to determine which lines are hidden and which are not

Transformations l.jpg

  • Must move the object from object space to world (global) space

  • Done through scaling, rotation, and translation

  • Uses matrix operations in a pipeline

Scaling l.jpg

  • A set of triplet factors held as quantifiers for X, Y, and Z

  • A scale of 1 does not move the object

  • A scale > 1 increases the size

  • A scale <1 decreases the size

  • [1,1,1] is the default

Rotation l.jpg

  • A set of triplet values quantifying the amount of rotation per access.

  • Can be represented by degrees, radians, or gradians.

  • Roll-pitch-yaw used by aviators are commonly refered to in gaming

    • Roll is longitudinal Z, pitch is lateral X, yaw is vertical Y

Translation l.jpg

  • A set of triplet factors for moving the positional coordinates

  • Done last in the pipeline to finally convert into world coordinates

  • XYZ triplet describes the number of units to shift ALL coordinates of the object (Applied in world space, not object space)

Rendering techniques l.jpg
Rendering techniques

  • Flat Shading – each face gets a different shade to differintiate between polygons

    • Z-flat shading decreases the color as the polygons get further away from the camera

  • Lambert Shading – A special form of Flat Shading that uses a brighter color and slowly changes the color to adjacent triangles to give the illusion of light effects

Rendering cont l.jpg
Rendering (cont.)

  • Uses normals to determine color through averaging

  • Normals are calculated per vertex

  • Distance between to vertices is used to calculate the normal that affects the color per pixel

  • Commonly used for a more natural appearance

Rendering cont16 l.jpg
Rendering (cont.)

  • Phong Shading – A more intense form of gouraud shading that determines normals per pixel to determine color

    • Very costly and computer intensive

  • Fake Phong Shading – a technique that speeds up Phong Shading by using bitmaps

Rendering cont17 l.jpg
Rendering (cont.)

  • Texture Mapping – Uses an image to “wallpaper” an object. Usually combined with a shading technique

    • Most common

Shaders l.jpg

  • Vertex Shaders – Uses vertex data to manipulate values for color, texture, fog, point size, and spatial orientation

  • Pixel Shaders – Inputs vertex shader output to determine values at a specified pixel. Usually done in the Video Card

Bump mapping l.jpg
Bump Mapping

  • Enhances the shape detail of the object

  • Modifies the shape of the object through the map without adding complexion to the object

  • Can be used in conjunction with a texture map when more detail is required

More mapping l.jpg
More Mapping

  • Environmental Mapping – uses texture mapping on environmental factors such as representing chrome, window reflects, and other shiny objects

  • Mipmapping – uses multiple maps to represent the same pattern at different distances

    • Reduces computer work

Mapping again l.jpg
Mapping Again

  • Parallax Mapping – a further step to bump mapping that creates the illusion of holes and protrusions without adding polygons

    • Used for computations like a water ripple

    • Calculates where pixels would be based on perspective

Scene graphs l.jpg
Scene Graphs

  • See example on page 128

  • Used to determine what is rendered at what time during the game

  • Uses a tree based structure, usually a directed graph

Audio considerations l.jpg
Audio Considerations

  • Using sounds based on distance

  • Done by the 3d engine

  • Some engines give audio levels at the closest and furthest

  • Deals with fade and drop-off

Coding movement l.jpg
Coding Movement

  • Given two variables, the shape and distance, add in the distance.

  • %xform = %shape.getTransform();

  • %lx = getword(%xform, 0) + %dist;

  • %ly = getword(%xform, 1);

  • %lz = getword(%xform, 2);

  • %shape.setTransform(%lx SPC %ly SPC %lz SPC “0 0 1 0”);

Coding rotation l.jpg
Coding Rotation

  • Similar to Movement, but the second triplet are the rotation of x, y, z

  • The last parameter is the rotation angle to rotate direction

Scaling26 l.jpg

  • Similar to the previous examples, except that setScale is used

  • %shape.setScale(%scale SPC %scale SPC %scale);

Simple animation l.jpg
Simple animation

  • Using the previous techniques, a simple animation can be made using one or more of these techniques

  • Used “schedule” function to call a function at a specified number of seconds later

Sound l.jpg

  • Uses special descriptor called “datablock” to define an audio sound.

    datablock AudioProfile(Sound){

    filename = “path”;

    description = “reference name”;

    preload = true;


Slide29 l.jpg

  • Perform the fish tutorial, by 8:20 on February 15th. Show to me.

  • Programming Assignment due by February 22.

    • Write a script that uses at least two functions to find the area of a triangle based on being given the length of all three sides and one that finds the standard deviation of 10 random numbers.

    • Standard deviation is the square root of ((the sum of the difference between the number and the median)) divided by the total number of variables)