1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-19 17:11:33 +00:00

Merge branch 'light_tweaks' into 'master'

[Postprocessing] Tweaks to light collection

See merge request OpenMW/openmw!1928
This commit is contained in:
psi29a 2022-05-25 07:51:17 +00:00
commit a14285bff5
3 changed files with 19 additions and 8 deletions

View file

@ -86,7 +86,7 @@ int omw_GetPointLightCount()
return omw_PointLightsCount; return omw_PointLightsCount;
} }
vec3 omw_GetPointLightViewPos(int index) vec3 omw_GetPointLightWorldPos(int index)
{ {
return omw_PointLights[(index * 3)].xyz; return omw_PointLights[(index * 3)].xyz;
} }

View file

@ -635,6 +635,9 @@ namespace SceneUtil
cv->pushStateSet(stateset); cv->pushStateSet(stateset);
traverse(node, cv); traverse(node, cv);
cv->popStateSet(); cv->popStateSet();
if (node->getPPLightsBuffer() && cv->getCurrentCamera()->getName() == Constants::SceneCamera)
node->getPPLightsBuffer()->updateCount(cv->getTraversalNumber());
} }
}; };
@ -1141,12 +1144,15 @@ namespace SceneUtil
if (mPPLightBuffer && it->first->getName() == Constants::SceneCamera) if (mPPLightBuffer && it->first->getName() == Constants::SceneCamera)
{ {
const auto* light = l.mLightSource->getLight(frameNum); const auto* light = l.mLightSource->getLight(frameNum);
mPPLightBuffer->setLight(frameNum, light->getPosition() * (*viewMatrix), if (light->getDiffuse().x() >= 0.f)
light->getDiffuse(), {
light->getConstantAttenuation(), mPPLightBuffer->setLight(frameNum, light->getPosition(),
light->getLinearAttenuation(), light->getDiffuse(),
light->getQuadraticAttenuation(), light->getConstantAttenuation(),
l.mLightSource->getRadius()); light->getLinearAttenuation(),
light->getQuadraticAttenuation(),
l.mLightSource->getRadius());
}
} }
} }
} }

View file

@ -29,7 +29,7 @@ namespace SceneUtil
class PPLightBuffer class PPLightBuffer
{ {
public: public:
inline static constexpr auto sMaxPPLights = 30; inline static constexpr auto sMaxPPLights = 40;
inline static constexpr auto sMaxPPLightsArraySize = sMaxPPLights * 3; inline static constexpr auto sMaxPPLightsArraySize = sMaxPPLights * 3;
PPLightBuffer() PPLightBuffer()
@ -75,6 +75,11 @@ namespace SceneUtil
mUniformBuffers[frameId]->setElement(i + 2, osg::Vec4f(ac, al, aq, radius)); mUniformBuffers[frameId]->setElement(i + 2, osg::Vec4f(ac, al, aq, radius));
mIndex[frameId]++; mIndex[frameId]++;
}
void updateCount(size_t frame)
{
size_t frameId = frame % 2;
mUniformCount[frameId]->set(static_cast<int>(mIndex[frameId])); mUniformCount[frameId]->set(static_cast<int>(mIndex[frameId]));
} }