Archive for the ‘RayTracing’ Category

RayTracing – Day 3

Tuesday, August 19th, 2008

Reflections!

Reflections have now been added to the raytracing algorithm. In the image above I set both spheres to have reflective properties, and you can see the results for yourself. It may not be the best scene layout for demonstrating the feature but it’ll do.

Other things I’ve added is more GUI controls so that the user can see the progress of the rendering and choose different options. A popup window appears once the rendering has completed to display the rendering time. Note in the image that it’s over 4 seconds to render as it’s running in Debug mode, the published version renders the image in 1.8 seconds on the same computer.

To improve the user interface the PictureBox (where the rendering is displayed) can now display portions of the image as it is being rendered instead of needing to wait for the entire image to be calculated for any results. The last thing I added was a second rendering mode called QuickRender, this mode effectively renders at half the resolution by skipping every other pixel.

I also rewrote the program a bit. I rewrote the raytracing function to be more recursive, which was necessary to implement the reflections.

I will try to upload a build of this to my Projects page soon.

-Thomas

RayTracing – Day 2

Sunday, August 17th, 2008

The fun stuff has started now!

Here’s my first RayTracing attempt, this was to see if I could pick out the primitives with the rays I’m casting. It came out as a outline of them all. There is a plane running along the ground in the bottom half, two spheres popping out, and a light in the sky (there’s another light somewhere else too, but it can’t be seen from this angle).

Next I updated this so that instead of using “white” it uses the primitives’ material colour.

Alright, getting somewhere now! But, they’re still just outlines at the moment, this needs some diffuse lighting.

Something didn’t quite go right there. It should have been a smooth gradient transition, instead there are two extreme colours here, white and black. I tried scaling the colour values down a bit.

YES! Now this is more like it! This is looking a bit boring though, all grey? Let’s add a little bit more colour.

Awesome.

I’m happy with my progress with this, but I think I need to go back and modify the diffuse lighting calculations as I’m not entirely sure the lighting is exactly as it should be. That’s for another day though.

If anyone is interested in doing a similar project, my current source of information for this project is an article on DevMaster.Net by Jacco Bikker. I’m personally trying to use as little source code from his examples as possible and focus on just the theory, but it is there for anyone who does want to examine it. I did more or less copy the scene that he is using though so I could compare my results.

-Thomas

RayTracing – Day 1

Saturday, August 16th, 2008

Behold, the progress I’ve made in a day!

Well, not a lot to show yet admittedly. Visually I’ve just got a Form with a blank 800×600 PictureBox on it, which the raytracer will eventually render onto.

However in the background I’ve been laying out some of the framework functionality needed including some annoying mathy bits like the actual raytracing algorithms, I’ve done some of this before with my dissertation so it hasn’t been too difficult yet. I’ve also programmed in a few other trivial math things like 3D vectors and planes (no, not the flying kind). There is also a basic scene manager which can have three types of objects added to it: spheres, lights and flat planes, each with their own material colour and diffuse/reflection variables.

But as mentioned, there’s currently no actual rendering functionality yet, these are just the boring beginning steps of it. Hopefully I will have something a bit more interesting to show soon.

Sidenote: C# is a great language, I’m pretty sure its going to become my language of choice.

-Thomas