ray tracing using programmable graphics hardware
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 PresentationTRANSCRIPT
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
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
OpenGL Graphics PipelineOpenGL Graphics Pipeline3D Application
3D API: OpenGLOr DirectX
GPUFront End
PrimitiveAssembly
Rasterization& Interpolation
FramebufferTests
Framebuffer
ProgrammableVertex Processor
ProgrammableFragment Processor
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
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
Cg Processing modelCg Processing model
VertexProgram
Application Rasterization FragmentProgram
Display
InputRegisters
OutputRegisters
InputRegisters
OutputRegisters
RegisterInterpolation
Textures
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
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));
}
Ray Tracing modelRay Tracing model
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
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
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
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