move to world space, fix bug with uniform size updates

fix/shrink_builds
cody glassman 3 years ago
parent 7edd28c1a4
commit 30a64ee82a

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

@ -635,6 +635,9 @@ namespace SceneUtil
cv->pushStateSet(stateset);
traverse(node, cv);
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)
{
const auto* light = l.mLightSource->getLight(frameNum);
mPPLightBuffer->setLight(frameNum, light->getPosition() * (*viewMatrix),
light->getDiffuse(),
light->getConstantAttenuation(),
light->getLinearAttenuation(),
light->getQuadraticAttenuation(),
l.mLightSource->getRadius());
if (light->getDiffuse().x() >= 0.f)
{
mPPLightBuffer->setLight(frameNum, light->getPosition(),
light->getDiffuse(),
light->getConstantAttenuation(),
light->getLinearAttenuation(),
light->getQuadraticAttenuation(),
l.mLightSource->getRadius());
}
}
}
}

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

Loading…
Cancel
Save