Just another notice to anyone who is still subscribed to this blog, I have migrated it off of Google's services. Although it was originally moved to Posterous, I chose to move it to Tumblr afterwords. This was due to Twitter purchasing Posterous, but they only purchased Posterous for their coding talents, meaning it is not certain whether or not Posterous will be kept running.
You can find my new blog at http://zauberparacelsus.tumblr.com/
Wednesday, August 31, 2011
Thursday, July 21, 2011
With the Second Life viewer, dynamic lighting is done by using "vertex lighting". If you enable wireframe mode (CTRL-SHIFT-R), you'll see the vertex points which make up an object, as spots where the wireframe lines intersect.
Now, vertex lighting has some problems in the area of accuracy. It is done by calculating the brightness of a light based on the lights parameters (intensity, radius, falloff), and then applying a gradient to the prim surface. With smaller objects, this isn't a problem. Larger objects, such as megaprims, will have a problem.
With megaprims, the vertex points are spread much further apart. If a light with a smaller radius is too far from one of these points, it will produce little or no light. Meanwhile, if it is close to a vertex point, it'll produce too much light. The white light in the snapshot below has a radius of just one meter. But because it is right on top of a vertex point, its lighting radius is far greater than one meter!
Now, take a look at the two snapshots below. In the before snapshot, you can see that 1) the torch on the left is casting a lot of light onto the floor, while the one on the right is casting none. The four torches in the background are casting little or no light against the floor. So, what's going on?
The lefthand torch is right near a vertex point, over-representing its light. The torch on the righthand side is centered between two different vertex points, under-representing its light. On the After image, the lights are all emitting light at the desired levels. What is difference between the two versions?
The lefthand image has a megaprim cube for the floor. In the second image, the floor is represented by a sculpty in the shape of a flat square. The cube prim has a vertex resolution of 4x4 per face. The flat square sculpty, however, has a resolution of 32x32 vertices. Because of this, the vertex points are much closer together, allowing for a more even level of lighting.
The disadvantage of this method, however, is that the floor has 64x as many vertex points (16 points vs 1024). So, this method will incur a higher rendering cost. This isn't much of a problem if you use this method sparingly, but using it all over the place will result in more lag.
Below is a copy of the sculpt map that I used to create the floor with. I'm releasing it into the public domain, so feel free to use it however you wish :-)