Raytraced spheres (again)

The image here shows a snapshot of an animation through a cloud of 40,000 raytraced spheres. I was able to get 2.6million raytraced spheres per second from an x1900, 2.2 Ghz core duo PC at 1024x768 resolution. In fact, the rate was limited by the host PC. The method used was to render a quad billboard for each sphere and send a single spheres details (centre, radius) to the raytracing shaders using a glColor4f call. Sounds odd, but it saved on extensions code. The billboarding is calculated by hand, as it were, on the host and each quad uses four glVertex calls. Switching to submitting a vertex buffer and calculating the billboarding in a vertex shader would probably speed things up but as my graphics card is already melting, I gave it a break.

There are no shadows or reflections so technically this is raycasting only. Nontheless seeing 40,000 perfectly shaped spheres (even close up) drifting by, is quite a joy. I also went to the trouble of uploading camera co-ordinates to the shader and created a free roaming camera - all my raytracing so far has been from a fixed point of view.

One last point, look at the picture and you can see spheres intersect. This is because the z value output in the shader is not the z-value of the billboard but the real z-value of the sphere. This shows that the image isnt constructed from a simple point sprite system or a particle system using texture mapping but uses real raycasting on each sphere.

The spheres are per-pixel lit and bump-mapped. Click on the image for a larger version.

No comments:

Post a Comment