Adaptive Binary Tree – Cont’d

December 31st, 2009 by

Alright I took another look at the Adaptive Binary Tree because when I tested the octree implementation on a level over 250.000 polygons and about 30 different materials the octrees performance degraded. When I first implemented the ABT I also tested on this level but I did not fully implement materials because I did not expect that it would affect performance a lot. When I was implementing materials into the octree implementation though, the performance dropped very fast because sets of polygons with the same material are fragmented throughout the level. Due to the nature of the octree lots of small sets are created.

The ABT however is able to adapt much better to this. So I took another shot at it. This time I also created a much better compiler! I attached a screenshot of the ABT in maya. I must note that creating the ABT takes about 30(!) seconds. There is also the screenshot of the temple so you can compare the result of the octree. (Compiling the ABT for the temple scene takes less then a second.)

Light attenuation

December 9th, 2009 by

I modified light sources to have a range instead of a falloff. Previously I calculated the attenuation of light with the formula

I/d^2

Where d is the distance to the surface and I is the light intensity. This formula has a quadratic falloff of light just as in the real world however this formula never reaches zero so it is almost impossible to determine when an object is not lit by a light. The first thing I tried was to calculate a range based on the above formula and a predefined value that determines when the amount of light is no longer noticeable. The problem is that the light formula converges very slowly to zero

Light falloff

Light falloff

so either the range got very large or the light cuttoff value got larger. To combat this problem I devised another attenuation formula based on the range of the light itself instead of a falloff and came up with this:

(1 - d^2/R^2)^2

Where R is the light range. The HLSH code also makes sure it is saturated. It looks very good but could definitely be optimized more, for now however I will just use this code. Before I can really use this though I need to clean the octree code because there are some bugs with dynamic lights.