3D Computer Graphics in a Nutshell Guillaume Caumon, January 2002.

Post on 05-Jan-2016

212 views 0 download

transcript

3D Computer 3D Computer Graphics in a Graphics in a

NutshellNutshellGuillaume Caumon, January Guillaume Caumon, January

20022002

IntroductionIntroduction

Computer graphics is concerned Computer graphics is concerned with all the aspects of “drawing” on with all the aspects of “drawing” on computerscomputers

Performance is criticalPerformance is critical 3D Computer Graphics deals with 3D Computer Graphics deals with

the generation images from 3D the generation images from 3D objects.objects.

The Rendering PipelineThe Rendering Pipeline

ApplicationApplication GeometryGeometry RasterizationRasterization

Pipeline = Linear succession of operationsPipeline = Linear succession of operations

Rendering speed = speed of the slowest step (bottleneck)Rendering speed = speed of the slowest step (bottleneck)

ApplicationApplication

Software-based processing / modificationsSoftware-based processing / modifications

3D Model3D Model Rendering Rendering primitivesprimitives

meshingmeshing

decimationdecimation

animationanimation

collision detectioncollision detection

……

GeometryGeometry

TransformsTransforms LightningLightning ProjectionProjection ClippingClipping

Geometry : TransformsGeometry : Transforms

Model CoordinatesModel Coordinates World CoordinatesWorld CoordinatesModel TransformModel Transform

Scaling, etc.Scaling, etc.

View TransformView Transform

Viewing CoordinatesViewing Coordinates

Geometry: lighting and Geometry: lighting and shadingshading

Simulate interaction of light with matter:Simulate interaction of light with matter:- Emission- Emission- Absorption- Absorption- Reflection- Reflection

Geometry: A Lightning Geometry: A Lightning EquationEquation

NN

LL

αα

ββ IIRR(())

νν : r, g or b : r, g or b

Ambient light coefficientAmbient light coefficientEx: (.1, .1, .1)Ex: (.1, .1, .1)

Material colorMaterial colorEx: (1, 0, 0)Ex: (1, 0, 0)

Shininess (s > 1) Shininess (s > 1)

Specular CoeficientSpecular CoeficientEx: (1, 1, 1)Ex: (1, 1, 1)

Geometry: ShadingGeometry: ShadingFlat shadingFlat shading: each triangle has : each triangle has the same colorthe same color

Gouraud shadingGouraud shading: colors are : colors are interpolated between verticesinterpolated between vertices

Phong shadingPhong shading: normal are : normal are interpolated and colors computedinterpolated and colors computedfor each pixelfor each pixel

Geometry: ProjectionGeometry: Projection

Virtual Device CoordinatesVirtual Device CoordinatesViewing CoordinatesViewing Coordinatesnormalizationnormalization

Perspective/Perspective/parallelparallel

Geometry: ClippingGeometry: Clipping

Geometry: Device Geometry: Device CoordinatesCoordinates

My WindowMy Window

Unit CubeUnit Cube

RasterizationRasterization

Per-pixel operations: ray-tracingPer-pixel operations: ray-tracing Screen = matrixScreen = matrix

TexturingTexturing

Aliasing / antialiasingAliasing / antialiasing

Scan conversion of lines: Scan conversion of lines: naive versionnaive versionBresenham algorithmBresenham algorithm

Scan conversion of polygons Scan conversion of polygons

Graphics HardwareGraphics Hardware

Quickly evolvingQuickly evolving

Main principle: use of Main principle: use of buffersbuffers

Color buffer : Color buffer : 1 byte per pixel (256) + lookup tables1 byte per pixel (256) + lookup tables2 bytes per pixel (65 536) “high color”2 bytes per pixel (65 536) “high color”3+1 bytes per pixel bpp (16 millions) “true color” + alpha channel3+1 bytes per pixel bpp (16 millions) “true color” + alpha channel

Depth buffer : Depth buffer : 16 to 32 bit per pixel16 to 32 bit per pixel

Graphics Hardware (II)Graphics Hardware (II)

Double buffering : Double buffering : • show the front buffer while rasterizing the show the front buffer while rasterizing the back bufferback buffer• swap buffers in synchronization with the swap buffers in synchronization with the screen refreshscreen refreshto get the new frameto get the new frameStencil buffer : Stencil buffer :

allows high-level operations (antialiasing, filtering, etc.) allows high-level operations (antialiasing, filtering, etc.)

See OpenGL programmer’s reference for more detailsSee OpenGL programmer’s reference for more details

ConclusionConclusion

3D Graphics require intensive computations3D Graphics require intensive computations

Yet, 3D Graphics are time-critical Yet, 3D Graphics are time-critical BottlenecksBottlenecksDisplay listsDisplay lists

Only low-level graphics have been described.Only low-level graphics have been described.

Scene GraphsScene GraphsSelection and Selection and toolstools

}}See OpenInventor, VTK, etc.See OpenInventor, VTK, etc.

References and further References and further readingreading

Foley, van Dam, Feiner, Hughes,Foley, van Dam, Feiner, Hughes, Computer Graphics Computer Graphics Principle and practice,Principle and practice, 22ndnd edition edition. Addisson Wesley, . Addisson Wesley, 19971997

Moller, Haines,Moller, Haines, Real-Time Rendering. Real-Time Rendering. AK Peters, 1999 AK Peters, 1999 ((http://www.realtimerendering.comhttp://www.realtimerendering.com))

The The Graphic GemsGraphic Gems series, Academic Press. series, Academic Press. Neider, Davis, Woo, Neider, Davis, Woo, OpenGL Programming GuideOpenGL Programming Guide. .

Addisson Wesley, 1993Addisson Wesley, 1993 Wernecke, Wernecke, The Inventor Mentor, release 2, The Inventor Mentor, release 2, Addisson Addisson

Wesley,1994 Wesley,1994 Schroeder, Martin, Lorensen, Schroeder, Martin, Lorensen, The Visualization The Visualization

Toolkit, 2Toolkit, 2ndnd edition. edition. Prenctice Hall, 1998Prenctice Hall, 1998 Proceedings of Siggraph, Visualization, Eurographics, Proceedings of Siggraph, Visualization, Eurographics,

etc.etc.