Computer Graphics For Games Part 2 - PowerPoint PPT Presentation

1 / 37
About This Presentation
Title:

Computer Graphics For Games Part 2

Description:

Computer Graphics For Games Part 2. The Pink Bunny. Triangle Rasterization ... The Bunny Model. Other topics. Alpha blending. Texture mapping. Bump mapping. Shadows ... – PowerPoint PPT presentation

Number of Views:307
Avg rating:4.0/5.0
Slides: 38
Provided by: aarons4
Category:

less

Transcript and Presenter's Notes

Title: Computer Graphics For Games Part 2


1
Computer Graphics For Games Part 2
2
The Pink Bunny
  • Triangle Rasterization
  • Hidden Surface Elimination
  • Lighting
  • Other stuff

3
Triangles
  • Why do we use triangles in graphics?
  • Normals are unique Important for lighting
  • Space filling triangles tile so they can be used
    to represent surfaces.
  • Atomic All polygons decompose into triangles

4
Scan Conversion
  • Ray tracing determines a pixels color by tracing
    the path of light through the scene to arbitrary
    precision.
  • The result is an extremely realistic image.
  • In scanline rendering surfaces are projected on
    the screen and space filling rasterizing
    algorithms are used to fill in the color.
  • Color values from light are approximated.

5
Quick Math!!
6
Barycentric Coordinates
  • The axis of a coordinate system dont have to be
    perpendicular.
  • If you use two sides of a triangle as axis, you
    can create a coordinate system called barycentric
    coordinates.
  • Basically, in the barycentric coordinate system
    you have three coordinates ?,?,? which represents
    the signed distance from each of the triangle
    edges.

7
Why are Barycentric coordinates useful?
  • For any point x, if the barycentric
    representation of that point x?,x?, x?
  • Also ?,?,? can be used as a mass function across
    the surface of a triangle to be used for
    interpolation.
  • This is used to interpolate normals across the
    surface of a triangle to make polygon surfaces
    look rounder.

8
Definitions
  • In this example the origin is at point a.
  • The ? and ? axis are the normalized vectors

A barycentric coordinate can Be represented by
the equation
Where
And
9
Calculating ?,? and ? for anarbitrary point,
(x,y)
  • These are derived from the implicit line equation.

10
Math Done!!
11
Rasterize This!(Rasterization intuition)
  • When we render a triangle we want to determine if
    a pixel is within a triangle. (barycentric
    coords)
  • Calculate the color of the pixel.
  • Draw the pixel.
  • Repeat until the triangle is appropriately filled.

12
Rasterization Pseudo Code
13
A simple optimization
14
(No Transcript)
15
Hidden Surface Removal
  • Currently our projection and rasterization
    process doesnt preserve any 3d depth
    information.
  • This will cause some problems when triangles
    overlap eachother.

16
BSP Trees
  • A BSP tree is an example of a painters
    algorithm.
  • The polygons are painted in back to front order
    from the perspective of the viewer, this handles
    the hidden surface problem.
  • BSP trees are typically pre-computed in games for
    performance.

17
The Z-Buffer
Note You must use the z value of the 3d
coordinate after perspective projection but
BEFORE the homogenizing step!!
Typically this algorithm is implemented in
hardware
18
Surface Shading
  • For now we will assume that when light interacts
    with objects of various compositions it is either
    diffuse or reflected.
  • Diffuse light represent light that is partially
    absorbed by the surface. Diffuse lighting is also
    called matte shading.
  • Reflected light, is light that bounces directly
    off of the object (like a mirror) and primarily
    maintains the original color of the light source.

19
Lamberts Law
  • We assume Lamberts Law to approximate light.
  • Basically we assume that the effect of a light
    source on the color of a surface is proportional
    to the cosine of the angle between the surface
    normal and the direction to the light.
  • We know when the surface points away from the
    light if the cosine is negative.

20
What is a Normal!?
  • A normal is a vector that is perpendicular to two
    other vectors.
  • It is calculated as the cross product of the two
    vectors.
  • Triangles are nice b.c. theres a unique normal
    (2 actually) for every triangle.
  • Remember the right-hand/left-hand rule applies
    here!

21
How do we compute the Cosine betweenTwo vectors
quickly?!
  • The dot product of two vectors is equal to the
    cosine of the angle between the two vectors!
  • Note The vectors have to be unit vectors for
    this to be true, otherwise youve got to
    normalize them.

22
Diffuse Shading
To Deal with negative light
Add in the ambient light
23
Reflective Shading(phong shading)
  • Phong shading is a simplified reflection model.
  • Basically it puts a bright spot which is colored
    with the light color on surfaces that are nearest
    to the light origin.
  • Generally we want the bright spot to be brightest
    when the reflected component r is going right
    into the viewers eye and fall off from there.

24
Phong Math
p is the phong exponent, which determines the
falloff rate
We can approximate r with h to eliminate negative
values
This gives us our final phong equation
25
What happens when you vary p ?
p 1
p 2
p 8
p 4
26
Final Lighting
27
Our Pipeline is Complete!
The Bunny Model
Triangle and line drawing
Z buffering
Projection matrices
Diffuse/phong shading
28
Other topics
  • Alpha blending
  • Texture mapping
  • Bump mapping
  • Shadows
  • Surface effects
  • Tessellation (curved surfaces)
  • Level Of detail

29
Alpha Blending
30
Texture Mapping
31
Bump Mapping
32
Normal Interpolation
33
Hair
34
Surface Shaders
35
Tessellation
36
Shadows
37
Level of Detail
Write a Comment
User Comments (0)
About PowerShow.com