Hi,
I'm building a Lightmapper for my small engine and I'm running into a bit of a problem using radiosity. I'm splitting my scene into small patches and propagating the light using a simplified version of the form factor.
private float FormFactor(Vector3 v, float d2, Vector3 receiverNormal, Vector3 emitterNormal,
float emitterArea)
{
emitterArea * (-Vector3.Dot(emitterNormal, v)
* Vector3.Dot(receiverNormal, v))
/(Pi*d2+emitterArea);
}
the problem I'm having is with the bounce light. They never converge and keep adding up energy. I could stop after some iteration but the code is probably incorrect since the energy never goes down.
if (Vector3.Dot(ne, lightdir)<0)
{
var form = FormFactor(lightdir, distance, nr, ne, emitter.Area);
emittedLight += emitter.Color *form* receiver.SurfaceColor;
}
this is the function where I had the bounce light.
Llightdir is the vector from the emitter patch to the receiver.
ne is the normalize normal of the emitter patch.
nr is the normalize normal of the receiver patch.
I try to scale my scene to see if maybe it was a energy or scaling problem but it didn't work.
the only thing that actually work was to divided by 4 the bounce light but that seems incorrect because in some scene the light ended up converging and on other there where just adding more energy.
So I'm wondering is there some kind of rule I'm missing. Should I add attenuation to the bounce light or the form factor is enough ? I spend the last week try to piece it together but most sources on internet didn't gave me clues on how to balance the bounce energy.
BTW I choose the form factor because it's easy to run on the cpu.