mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 05:20:00 +02:00
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:
parent
5120076add
commit
19e318c3f0
1 changed files with 6 additions and 3 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue