13
Ray Tracing using Ray Tracing using Programmable Programmable Graphics Hardware Graphics Hardware Andrew Wood, Brendan Andrew Wood, Brendan McCane & Scott A. King McCane & Scott A. King Graphics & Vision Research Group Department of Computer Science University of Otago IVCNZ 2004

Ray Tracing using Programmable Graphics Hardware

  • Upload
    olaf

  • View
    27

  • Download
    0

Embed Size (px)

DESCRIPTION

Ray Tracing using Programmable Graphics Hardware. Andrew Wood, Brendan McCane & Scott A. King. Graphics & Vision Research Group Department of Computer Science University of Otago. IVCNZ 2004. Outline. Using Cg with OpenGL Where does Cg fit in? Benefits of Programmable Graphics Hardware - PowerPoint PPT Presentation

Citation preview

Page 1: Ray Tracing using Programmable Graphics Hardware

Ray Tracing using Ray Tracing using Programmable Graphics Programmable Graphics

HardwareHardwareAndrew Wood, Brendan McCane Andrew Wood, Brendan McCane

& Scott A. King& Scott A. King

Graphics & Vision Research Group

Department of Computer Science

University of Otago

IVCNZ 2004

Page 2: Ray Tracing using Programmable Graphics Hardware

OutlineOutline

Using Cg with OpenGLUsing Cg with OpenGL Where does Cg fit in?Where does Cg fit in? Benefits of Programmable Graphics HardwareBenefits of Programmable Graphics Hardware

Mapping applications as Graphics Mapping applications as Graphics processesprocesses General purpose processing on the GPUGeneral purpose processing on the GPU Ray Casting modelRay Casting model ExtensionsExtensions

Page 3: Ray Tracing using Programmable Graphics Hardware

OpenGL Graphics PipelineOpenGL Graphics Pipeline3D Application

3D API: OpenGLOr DirectX

GPUFront End

PrimitiveAssembly

Rasterization& Interpolation

FramebufferTests

Framebuffer

ProgrammableVertex Processor

ProgrammableFragment Processor

Page 4: Ray Tracing using Programmable Graphics Hardware

Cg Application modelCg Application model

Cg - high level, c-like Cg - high level, c-like languagelanguage

Cg compiler to Cg compiler to generate assemblergenerate assembler

Cg RuntimeCg Runtime Communication with Communication with

HardwareHardware

Application

Cg API-specific runtime(OpenGL, DX8 or DX9)

Cg common runtime(includes compiler)

OpenGL or Direct3DGraphics Driver

Graphics Hardware

Mark et al. SIGGRAPH 2003

Page 5: Ray Tracing using Programmable Graphics Hardware

GPU PerformanceGPU Performance

0

100

200

300

400

500

2H97 1H98 2H98 1H99 2H99 1H00 2H00 1H01

GPU Performance

(32 bit AA Fill Rate)

0

1500

3000

4500

6000

7500

CPU Performance (Megahertz)

NVIDIA GPU'sIntel CPU's

Sourced from NVIDIA

Page 6: Ray Tracing using Programmable Graphics Hardware

Cg Processing modelCg Processing model

VertexProgram

Application Rasterization FragmentProgram

Display

InputRegisters

OutputRegisters

InputRegisters

OutputRegisters

RegisterInterpolation

Textures

Page 7: Ray Tracing using Programmable Graphics Hardware

Example: Image FilterExample: Image Filter

Draw screen-sized Draw screen-sized quadquad

Input image to be Input image to be processed as textureprocessed as texture

Edge-detection Edge-detection fragment program is fragment program is run once per pixelrun once per pixel

Output results to Output results to screen or save to screen or save to texturetexture

Laplacian FilterFragment Program

Images sourced from NVIDIA

Page 8: Ray Tracing using Programmable Graphics Hardware

Cg code exampleCg code example

Laplacian FilterFragment Program

half4 main(half2 coords: TEX0,

sampler2D texture) : COLOUR {

const half offset = 1.0 / 256;

half4 c = tex2D(texture, coords);

half4 bl = tex2D(texture, coords

+ half2(-offset, offset));

half4 l = tex2D(texture, coords

+ half2(offset, 0));

half4 b = tex2D(texture, coords

+ half2(0, offset));

return 8 * (c + -0.125 * (bl + l + … + b));

}

Page 9: Ray Tracing using Programmable Graphics Hardware

Ray Tracing modelRay Tracing model

Page 10: Ray Tracing using Programmable Graphics Hardware

Current Ray Casting methodCurrent Ray Casting method

Render to Texture Render to Texture used to store resultsused to store results

Updated intersection Updated intersection texture set as input texture set as input for next passfor next pass

Object Intersection Shaders

QuadricIntersection

Shader

TriangleIntersection

Shader

Eye Rays

CurrentObjectIntersections

Colour CalculationShader

CPU

Stream of Objects

Output Image

Lights

Object Materials

ClosestIntersections

ObjectIntersection

Shader

Current Object

New Intersection Texture

Eye ray texture

CurrentIntersection texture

Page 11: Ray Tracing using Programmable Graphics Hardware

ResultsResults

Sphereflake test scene

0

5

10

15

20

25

1 3 5 7 9 11 13 15 17 19

Number of Primitives

Frames per second (FPS)

HardwareSoftware

Page 12: Ray Tracing using Programmable Graphics Hardware

ExtensionsExtensions

Full recursive modelFull recursive model Different rays can be in Different rays can be in

different statesdifferent states State based processingState based processing Limiting processing to Limiting processing to

one type of rayone type of ray Application for method: Application for method:

Constructive Solid Constructive Solid GeometryGeometry

Page 13: Ray Tracing using Programmable Graphics Hardware

Summary & QuestionsSummary & Questions

OpenGL Graphics PipelineOpenGL Graphics Pipeline Cg Application & Processing modelsCg Application & Processing models Example: Image FilterExample: Image Filter Ray Tracing modelRay Tracing model Current Ray Casting methodCurrent Ray Casting method ResultsResults ExtensionsExtensions