X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space...

Post on 20-Dec-2015

228 views 2 download

Tags:

transcript

x86 and 3D graphics

Quick Intro to 3D Graphics

• Glossary:– Vertex – point in 3D space– Triangle – 3 connected vertices– Object – list of triangles that have the same

material properties (AKA Mesh)– Texture – a 2D image that is wrapped on the

surface of a Mesh

For Each Triangle...• Geometry

– transform each vertex (FP)

• Lighting– compute lighting from light sources and surface

properties (FP)

• Rasterization– setup triangle for rasterization (FP)– perform shading & texture mapping during triangle

fill (INT)

Rendering Processlightsource

objects

viewing planeX

Y

Z

incident light

perspective projection

Mathematical modelsfor light, objects & viewercreate a 2D image viaa 3D process

Coordinate Systems

xw

yw

zw

world xo

yo

zo

object

xv

yv

zv viewer

xl

yl

zl

light

Transformation

• Transformantion change the coordinate system a point lies in

• Examples– Viewing Transformation - translate objects to

viewer coordinate before projection to viewing plane

– Shadows - translate objects to light source coordinates to calculate shadows

NL R

S

Lighting Process

Surface

Diffuse Light scatters in all directions

Specular Light reflects in direction of reflection vector R

V

Rasterization

• Now that we have transformed and lit polygons… actually, the vertices...

• And, we know where they appear on the screen…

• We have to fill their interiors!

Textures

Image maps to apply surfaces.Gives impression of complex surface properties.

Can substitute for lots of polys (eg, tree bitmap on a single rectangle, vs. thousands of leaf polys)

Rasterization (again)

Flat Fill

Some lighting

And textures

DemoSkinnedMesh.exe

History of 3D Pipeline Partitioning

Geometry

Lighting

Edge Setup

Rasterization

Application

Software 3DProcessor Does All

First Generation3D HW Accelerators

Rasterization

HW

Geometry

Lighting

Edge Setup

Application

2nd Generation HW (1998-99)

HW

Geometry

Lighting

Edge Setup

Rasterization

Application

3rd Generation HW (1999-2000)

HW

Geometry

Lighting

Edge Setup

Rasterization

Application

Memory BW: The problem

• Frame buffer - ~3MB

• Z buffer - ~3MB

• For each object:– Mesh (vertices and triangle connectivity) –

1KB – 1MB– Texture(s) - ~256KB

• Typical game frame – 8MB – 20MB

AGP: the Solution• AGP (Accelerated Graphics Port)

– Larger BW than PCI

– Lower HW cost (less local RAM needed)• Frame/Z buffers stored in graphics local memory

• Texturing from system memory

Memory traffic when using AGP

How does it work

The AGP aperture is mapped as one chunk (1:1 mapping in CPU’s paging HW), both the gfx chip and the CPU reference the same addresses

The GART is mapping AGP memory address to the system memory address (like paging HW in the CPU)

In the futureMulti-texturing: More than one texture for surface, used for details maps, reflections, refractions, lighting tricks, etc.

Programmable HW

Helps the developer in customizing its transform, lighting and texture operations

Programmable vertex machine

Programmable HW demos

backup

Shading Techniques

Scan Line

A

B

C

L R

P

Polygon fill is done across the scanline

Flat shading Color the whole polygon with one color Does not show highlights inside polygons

Gouraud shading If the object surfaces are curved, we can

approximate it by polygons Interpolating vertex intensity values along scanline Still does not show highlights inside polygons

Texture Mapping1. Texture coordinates (s,t,q) for each vertex. These are interpolated along polygon edges.

2. Texture coordinate for each point on scanline is interpolated. Linear interpolation, or a quadratic approximation (for perspective correction) is used.

3. The (s,t) value maps into the source texture map. It usually does not fall on the center of a texel.

4. A texture mapping algorithm is applied to the nearest texel, and possibly surrounding texels, to determine the result.

Texturing eats CPU MIPS & bandwidth. 20-70% slower than flat shading.

(s0, t0 , q0)

(s1, t1, q1)

(s2, t2 , q2)

(si, ti)

1

2

3

4

s = 0, t = 0 s = 1, t = 0

s = 1, t = 1