Blog

Portfolio CV

Saturday night hacking

Published:
2008-09-28 01:47:00
Posted from:
Home
Tags:
GLSL, Ray tracing,

Haven't done any 3D programming in a couple of months so I felt a bit rough around the edges when I this week took up my project in a course in procedural methods for imaging. However, it triggered some ideas.

After a long walk with the dog and some running I decided to sit down and see how far I could get on a GPU-only ray tracer. So far so good: Saturday night GPU ray tracer hacking

The implementation is far from general, it cannot render polygon meshes and the whole scene (except for light sources, for a change! :-D) is defined in the shader. The implementation uses distance fields for all bodies, so instead of explicitly solving for an intersection between the ray and objects, I use a method presented here.

The method in short:

  1. Sample the distance field at the current point
  2. If the distance is "close enough" to an object, we have an hit. Here you either stop tracing and we have a shadow in the last iteration, you do a reflection/refraction and continue along that ray, or you send one ray to each light source to see if this surface is lighted.
  3. If not (close enough), we walk along the ray the distance sampled before. We will end up somewhere in space, but we know it is not inside an object. This new position is our new current, and we go back to point 1

As you can see I only have three types of objects: floor, sphere and capsule. These are the only objects I've implemented distance fields for so far, but I'll extend this tomorrow, perhaps with some discrete (3D-texture) objects or some noise based procedural ones.

Might even use this as renderer for the previously mentioned course project.

Comments

No comments so far. You leave the first:

Name
Email
Website
Text

© 2008 Markus Johnsson