I need this on a iterative radiosity renderer, using gathering method, writed in C# using GPU (with XNA), to speed up the rendering.
For each polygon I have a lightmap and a list of lightmaps visible from it. That's work ok.
The idea is that when all lightmaps in "visible list" have an average energy less than a thresold I can skip the light gathering for the entire polygon's lightmap.
In a first time I've considered only the average energy, but I find that accounting for distance (or better the square of the distance, that is the physical decay of light) i can rescale the average energy and check against the threshold to do a better filtering:
public void GatherEnergy(float accuracy, ref Hemicube h, ref SceneRenderer scene)
{
bool skip = true;
for (int i = 0; i < VisibleLightMaps.Length; ++i)
{
if ((VisibleLightMaps[i].lightmap.AverageEnergy / VisibleLightMaps[i].distSquared) > energyThreshold)
{
skip = false;
break;
}
}
if (skip)
return;
if (ForDetailMesh)
GatherEnergyForDetailMesh(accuracy, ref h, ref scene);
else
GatherEnergyForPoly(accuracy, ref h, ref scene);
CalculateMaxAndAverageEnergy();
}
NOTE: the distance I need is the real minimun distance (or distance squared) between the polygons. The points that define the distance segment can be on a vertex, on edge, or inside the polygon.
I hope to be clear.
Thanks in advance for help.