Friday, 22 August 2008


As mentioned in earlier posts I have been calculating u,v coordinates for every triangle intersection. I have avoided actually texturing my triangles as I wanted to get most of the other things working well first - I find textures tend to disguise shading / intersection glitches.

Last night I decided to implement some basic texturing and see how much longer the scene took to render. So I added the Lena image to my modified Cornell box - if you are going to be a cliche you may as well go all the way :)    Screenshot with texturing is below.

Interestingly the rendering time barely increased at all. There are a couple of reasons for this: In my scene only 14 triangles are actually intersected (the rest of the 100 are hidden behind).  Secondly, and more importantly I think,  the 8800GT / NVIDIA GPU's are designed to texture well. Texturing is used in all the standard rasterization techniques so it is good to see it translates well in the CUDA architecture to ray tracing.  Interestingly other implementations of ray tracers on different platforms tend to steer away from texturing as it is so expensive. As it is relatively quick on a CUDA device it can be used to hide the lack of object density it can support in real time.


[caption id="attachment_199" align="aligncenter" width="300" caption="Lena Texture on "Cornell Box" in cudart"]Lena Texture on "Cornell Box" in cudart[/caption]

You will notice from the image that the textures have not been applied correctly across the planes, but individually to the triangles. This is something that will be fixed later.

Careful observers will note there is an additional light source in the scene and the lights now have colours associated with them. In terms of timing this was a very important experiment for cudart's design. As there are still no reflections adding an additional light increases the ray count by 50% (for this scene anyway). Every ray intersect needs to trace two additional rays - one to each light source.

Now if all went well and the memory bottleneck had been improved sufficiently the scene timing would increase by 50%. Happily the timings seem to indicate this :)  This is not entirely unexpected as I calculate both shadow rays at once against the same object.  This is good news in terms of my memory optimization but rather bad news in terms of my goal frame rate as it has now dropped under 24fps for 100 objects and 2 light sources (still no reflection).   The next step is to add reflection and try and optimize as much as possible.  One big optimization that can be done is to convert from a scene full of triangles to one full of spheres.  It is much easier and quicker to compute a ray/sphere intersection that a ray/triangle intersection.

Hopefully by the end of the weekend I will have reflections and 2 scenes - one with triangles and one with spheres.

No comments:

Post a Comment