26
x86 and 3D graphics

X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

  • View
    228

  • Download
    2

Embed Size (px)

Citation preview

Page 1: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

x86 and 3D graphics

Page 2: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

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

Page 3: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

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)

Page 4: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

Rendering Processlightsource

objects

viewing planeX

Y

Z

incident light

perspective projection

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

Page 5: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

Coordinate Systems

xw

yw

zw

world xo

yo

zo

object

xv

yv

zv viewer

xl

yl

zl

light

Page 6: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

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

Page 7: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

NL R

S

Lighting Process

Surface

Diffuse Light scatters in all directions

Specular Light reflects in direction of reflection vector R

V

Page 8: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

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!

Page 9: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

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)

Page 10: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

Rasterization (again)

Page 11: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

Flat Fill

Page 12: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

Some lighting

Page 13: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

And textures

Page 14: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

DemoSkinnedMesh.exe

Page 15: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

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

Page 16: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

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

Page 17: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

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

Page 18: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

Memory traffic when using AGP

Page 19: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

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)

Page 20: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

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

Page 21: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

Programmable HW

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

Page 22: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

Programmable vertex machine

Page 23: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

Programmable HW demos

Page 24: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

backup

Page 25: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

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

Page 26: X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that

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