Today I picked up some work about walkchurch.
My goal continues to be to calculate only indirect global lighting. Basically I want to calculate some fancy ambient lighting to be added to normal dynamic direct lighting + stencil-volume shadows.
As I wrote before, indirect lighting, light that comes reflected by a secondary surface (like the Moon), has a rather low spatial frequency. The shadows that it casts aren’t sharp. It’s mostly about distributing a tint. For example, in a room with a red wall and a white floor, a light hits the red wall, making it “bleed” into the floor that will become reddish (this is more important than it seems !).
To calculate indirect lighting, I’m still going to do some sort of radiosity. Tesselation doesn’t matter as much, but still a decent level of subdivision is needed. I currently subdivide large triangles recursively. I split in half the longest edge, then see if any of the resulting two triangles need to be split again about their new longest edge.
Tesselating like this is very simple and also consistent, meaning that it doesn’t create any new T junctions.
Normally when one tesselates, should take care of not creating too many vertices. Ideally one should cut an edge using only one new vertex for two triangles share that edge.
I did some research about this. Some structure called half-edge seems to make it easier to deal with edges.. however it seemed to be more trouble than what is worth. So, I decided to split triangles individually, creating many duplicated vertices and eventually remove the duplicate vertices in a second pass. It’s just simpler this way, at least for the time being !
In order to create a first radiosity hit, I’m going to render the scene from the light source point of view with triangle IDs.
Again with the red wall and white floor. The red wall gets the light energy, while the floor gets the energy that bounces from the wall (namely light frequency mostly in the red spectrum (that’s the meaning of something being red !)).
Along with the triangle ID rendering, I implemented the object ID rendering. Useful to detect which objects are visible by the light source (will be useful later when calculating shadow volumes). In the picture, the scene is seen from the light source, red objects are hidden:
I did a test with the triangle IDs. I find out which triangles are hit by the light. Color them gray (could be any color) and render again the scene form again from the same light source point of view. They have to be all gray and they are indeed (except a few pixels by some weird artifacts). As I expected, when I render the scene at an higher resolution, triangles that weren’t previously visible, suddenly become visible (marked in red):
The reason is that the triangle ID test is performed off-screen at 512×512, and some tiny triangles aren’t rendered at all. When I render at higher resolution, some of those will become large enough to be visible.
This would be ugly if I were trying to make direct lighting with that system. However, indirect lighting of diffuse surfaces is a low frequency issue, and I expect to be hardly noticeable if a few small triangles don’t bounce back their portion of light.
Lezze zzzzz on this !
Posted by Davide Pasca in 3D Graphics
