Enforce maximum radius for lights

Light attenuation is based on the intensity,
in that intensity is used to calculate a light's surface area.
Lights of sufficiently low intensities generated either
incredibly large or negative surface areas, causing them to
appear much brighter than similar lights of greater intensity.
This enforces an already present maximum.
This commit is contained in:
Zach Pomerantz 2016-02-10 15:56:58 -08:00
parent 5120076add
commit 19e318c3f0

View file

@ -79,9 +79,12 @@ void Light::setMaximumRadius(float radius) {
}
void Light::updateLightRadius() {
float CutOffIntensityRatio = 0.05f;
float surfaceRadius = getMaximumRadius() / (sqrtf((getIntensity() * std::max(std::max(getColor().x, getColor().y), getColor().z)) / CutOffIntensityRatio) - 1.0f);
editSchema()._attenuation = Vec4(surfaceRadius, 1.0f/surfaceRadius, CutOffIntensityRatio, getMaximumRadius());
const float CUTOFF_INTENSITY_RATIO = 0.05f;
float intensity = getIntensity() * std::max(std::max(getColor().x, getColor().y), getColor().z);
float denom = sqrtf(intensity / CUTOFF_INTENSITY_RATIO) - 1.0f;
float surfaceRadius = getMaximumRadius() / std::max(denom, 1.0f);
editSchema()._attenuation = Vec4(surfaceRadius, 1.0f/surfaceRadius, CUTOFF_INTENSITY_RATIO, getMaximumRadius());
}
#include <math.h>