Consider I have two point light’s of the same type which have their own atrributes i.e. intensity, colour, range etc…
At the moment I am using public float getArea(Light l){return l.intensity* l.range}
as the weights for the lights.
Therefore, a single light to approximate the two would look something like:
Light light1Comp = light1.GetComponent<Light>();
Light light2Comp = light2.GetComponent<Light>();
float light1Area =getArea(light1Comp );
float light2Area = getArea(light2Comp );
float totalArea= light1Area +light2Area;
GameObject lightGameObject = new GameObject();
lightGameObject.transform.position= (light1.transform.position *light1Area+light2.transform.position * light2Area)/totalArea;
Light lightComp = lightGameObject.AddComponent<Light>();
float combinedIntensity = light1Comp.intensity + light2Comp.intensity;
lightComp.colour = (((light1Comp.colour * light1Area) + (light2Comp.colour * light2Area)) / totalArea);
lightComp.intensity =combinedIntensity ;
lightComp.range = totalArea / combinedIntensity;
It seems like this approximation is not so good though, am I missing something? are intensities non-linear?
here are some images to show what is happening
This image uses unmerged lights
This image uses merged lights