back to Ray Tracing GPU homepage

Implementation Journal - GPU Based Ray Tracer

This is a very brief overview how the GPU Ray Tracer was implemented. Without going in detail, some steps are presented here with screenshots of the development process.

 


 

Week 1: C++/CPU Based Ray Tracer

Image: Drawing Primitives, Generating floating point Textures

Framework

Implementation of a Direct3D based framework for advanced shader programming. The framework should be easy portable to a future OpenGL version. The Direct3D version of this framework is based on the Microsoft "sample framework" included with the Direct3D SDK.

The focus was on shader management and data transfer with textures.

Image: Importing .3ds files

Importing .3ds Files

Importing .3ds Files to the internal "TriangleList" class. 3ds isn't the best format but it is easy to implement and materials can be directly edited in 3D Studio.

Programming a Simple Ray Tracer with Primary Rays only ("Ray Caster")

The Ray Tracer uses "brute force" triangle intersection checks. Each ray is tested with each triangle.

Implementing:
1. Camera-class
2. Minimal ray tracer (Phong shading)
3. Draw Direct3D based wireframe over ray tracing output to test camera-class



Shadow

Shadow is added: At every ray intersection point a ray is casted to the light source and checked if an occluder is in the way: if there is no occluder, there is no shadow.

Secondary Rays

Secondary, reflecting rays were added

 


Week 2: Accellerating the Ray Tracer

 

 

Implementing an Acceleration Structure

Calculating bounding box and bounding cube of a scene.
A scene can be converted to a cube based uniform grid.

 

The API was enhanced: drawing rays for visualization:
Several iterations (reflections) were implemented in the uniform grid traversal:
A preliminary material class was added:
Procedural textures are also possible now. (example image uses Perlin Noise)

Screenshots of the OpenGL based (CPU) Ray Tracer:

Adding OpenGL support

The current work is being ported to OpenGL. The framework and the ray tracer.



Week 3: Improving Accelleration and first GPU tests

 

 


To visualize the uniform grid, only the cells containing triangles are drawn.

 

Until now, the uniform grid structure was based on the bounding cube. Now the uniform grid was modified and is built based on the bounding box.

With the improved API of the framework it is possible to visualize rays hitting the grid.
This makes it possible to animate the traversal.

The ray tracer was updated to support the new grid.
The whole grid class was updated to be much more efficent.
At the same time I upgraded the grid, I started some GPU tests. Camera Data is sent to the GPU: primary rays are generated and one triangle is intersected based on the camera setting.
Primary rays are tested with the bounding box: (100% GPU)

 


Weeks 4-5: Implementing Ray Tracing 100% on GPU


 

Implementing Ray Tracer to GPU (using Direct3D/HLSL)

The Ray Caster is being ported to the GPU. Scene data is stored in textures.

After 2 weeks of HLSL coding, a first screenshot of the GPU based ray caster was available:

Most problems encountered at this stage were driver related and could be fixed by installing latest NVidia drivers.
First few implementations only worked in Direct3D REF mode, but starting with NVidia 67.93 driver, it worked on the GeForce 6 GPU.
However there are still problems with some hardware configurations (on AGP based machines) when rendering big scenes.

 



Week 6: Improving the GPU Ray Tracer


Early Z-Culling

Implementation of early Z-culling, first with some simple tests.

Early Z-Culling and Secondary Rays were added to the GPU ray tracer!


Week 7

 

 

Scene correctly rendered with a "Debug Shader"

Porting current Ray Tracer to the OpenGL Shading Language (GLSL)

The GLSL ray tracer works, the triangles are visualized with a "debug shader".

 

...but, unfortunately, the GLSL version currently only works when enabling emulation with the "NVEmulate" Tool:

 

Without using the software emulation the result looks this way when rendering with hardware. This is certainly a driver related bug.
So for now, only the Direct3D (HLSL) version works, hopefully a future driver update will fix the GLSL problem!
   

 


Weeks 8-10: Creating a Demo Application


Improving the Application: Adding GUI, Material Editor etc.

(Later versions use tabbed interface)

Please note: benchmarks are not really fair! Both the CPU version and the GPU version are not fully optimized.

 



back to Ray Tracing GPU homepage