As part of my work, I generate 3D objects, and it’s nice to be able to see what these look like. Sounds like an easy task right? Just dump the data into a program like matlab and off you go. But the trouble is, the best I could get matlab to do was this
Which is not tooo bad. But it ain’t pretty. One of my supervisors uses a proper ray-tracing renderer which is free, POVray. So I write a script that writes a POVray script and we get this
Huh, where’s my object? Oh, lights, totally forgot about those. Lets add some in so we can see what we’re doing
Well, that’s better, certainly better than matlab, but still less than ideal. At this point I went looking for lighting tutorials and not finding much help. The Internet is full of “this is how to put a light in your 3D scene” but not very helpful when it comes to where to put those lights. But in the end I realised that I was looking in the wrong spot. I needed a photographer’s skills! So I found this, which suggests using 2 lights on either side and one above. Unfortunately I never got good results from that, kept on getting sharp shadows like in the above picture.
But then it struck me, what does a photograph have that I don’t? Ambient light! Light coming from windows and bouncing around the room and coming in from every angle. Ambient light just makes things look flat in 3d, like the first POVray picture above. The last image in the linked article shows a furry toy, you can tell it’s fur because it has texture which is conveyed by all the tiny shadows from all the tiny threads. We need light that’s ambient, but that does cast shadows. For this I used a cloud of lights in a sphere around the object. They provide light from every which way so we get soft shadows but they still provide shadows in the corners and crevices.
Much prettier! It took the render time from the order of minutes to 8 hours (for 16 or so) but it’s not like I had to actually sit there and watch it.
If anyone stumbles upon this and decides to follow , there are some technical details. I actually used a quarter sphere, cutting off the bottom half because light from below seems strange and cutting out the back half because it’s not really seen. Also, I plotted the lights out parameterising with the azimuthal and elevation angles and . As you get to the top of the sphere you get more lights than around the equator however, to correct for this you need the Jacobian of the parameterisation in the intensity, in this case .