Title: Ray%20Tracing%20using%20Programmable%20Graphics%20Hardware
1Ray 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
2Outline
- Using Cg with OpenGL
- Where does Cg fit in?
- Benefits of Programmable Graphics Hardware
- Mapping applications as Graphics processes
- General purpose processing on the GPU
- Ray Casting model
- Extensions
3OpenGL Graphics Pipeline
3D Application
3D API OpenGL Or DirectX
GPU Front End
Primitive Assembly
Rasterization Interpolation
Framebuffer Tests
Framebuffer
Programmable Vertex Processor
Programmable Fragment Processor
4Cg Application model
Application
- Cg - high level, c-like language
- Cg compiler to generate assembler
- Cg Runtime
- Communication with Hardware
Cg API-specific runtime (OpenGL, DX8 or DX9)
Cg common runtime (includes compiler)
OpenGL or Direct3D Graphics Driver Graphics
Hardware
Mark et al. SIGGRAPH 2003
5GPU Performance
Sourced from NVIDIA
6Cg Processing model
Input Registers
Output Registers
Input Registers
Output Registers
Register Interpolation
Vertex Program
Fragment Program
Application
Rasterization
Display
Textures
7Example Image Filter
- Draw screen-sized quad
- Input image to be processed as texture
- Edge-detection fragment program is run once per
pixel - Output results to screen or save to texture
Laplacian Filter Fragment Program
Images sourced from NVIDIA
8Cg code example
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))
Laplacian Filter Fragment Program
9Ray Tracing model
10Current Ray Casting method
CPU
Current Object
Eye ray texture
Stream of Objects
Object Intersection Shader
Object Intersection Shaders
Current Intersection texture
Eye Rays
Quadric Intersection Shader
Triangle Intersection Shader
Current Object Intersections
New Intersection Texture
Closest Intersections
- Render to Texture used to store results
- Updated intersection texture set as input for
next pass
Lights
Colour Calculation Shader
Object Materials
Output Image
11Results
Sphereflake test scene
12Extensions
- Full recursive model
- Different rays can be in different states
- State based processing
- Limiting processing to one type of ray
- Application for method Constructive Solid
Geometry
13Summary Questions
- OpenGL Graphics Pipeline
- Cg Application Processing models
- Example Image Filter
- Ray Tracing model
- Current Ray Casting method
- Results
- Extensions