mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-19 13:41:32 +00:00
move to world space, fix bug with uniform size updates
This commit is contained in:
parent
7edd28c1a4
commit
30a64ee82a
3 changed files with 19 additions and 8 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue