Thursday, August 13, 2009

Diffuse Lighting


Cornell Room, with 320000 points (0.6 seconds)


Took some major code refactoring, but I eventually managed to add diffuse lighting to the raytracer.
This includes some major additions like a new Material class, which is now used instead of per splat color values. The Material class has support for ambient, diffuse, specular materials, transparency, etc...

Of course, I also had to add a new light class (PointLight). This is more like a simple struct really.

Then there were a few other changes to incorporate shading. The Material class accepts a light, a position and a normal vector and returns the shaded value. The base class of the entire model, which I call SceneBase, contains a list of pointers to materials and lights. Pointers because then I can easily modify the materials and lights from outside, and things will dynamically change.

SceneBase derives every other scene class. The Octree class has been moved into a container which I call OctreeScene. This gives me an easier way of keeping track of the root node, than to create a global variable called root.

phew... thats a lot of messing around with code to get things working neatly...

No comments:

Post a Comment