forked from mirror/openmw-tes3mp
Properly calculate light activation range
This commit is contained in:
parent
a39c129954
commit
5e7e9fd26a
1 changed files with 8 additions and 2 deletions
|
@ -275,17 +275,23 @@ void Objects::insertLight (const MWWorld::Ptr& ptr, Ogre::Entity* skelBase, Ogre
|
|||
|
||||
bool quadratic = lightOutQuadInLin() ? !info.interior : lightQuadratic();
|
||||
|
||||
// with the standard 1 / (c + d*l + d*d*q) equation the attenuation factor never becomes zero,
|
||||
// so we ignore lights if their attenuation falls below this factor.
|
||||
const float threshold = 0.03;
|
||||
|
||||
if (!quadratic)
|
||||
{
|
||||
float r = radius * lightLinearRadiusMult();
|
||||
float attenuation = lightLinearValue() / r;
|
||||
light->setAttenuation(r*10, 0, attenuation, 0);
|
||||
float activationRange = 1 / (threshold * attenuation);
|
||||
light->setAttenuation(activationRange, 0, attenuation, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
float r = radius * lightQuadraticRadiusMult();
|
||||
float attenuation = lightQuadraticValue() / std::pow(r, 2);
|
||||
light->setAttenuation(r*10, 0, 0, attenuation);
|
||||
float activationRange = std::sqrt(1 / (threshold * attenuation));
|
||||
light->setAttenuation(activationRange, 0, 0, attenuation);
|
||||
}
|
||||
|
||||
// If there's an AttachLight bone, attach the light to that, otherwise attach it to the base scene node
|
||||
|
|
Loading…
Reference in a new issue