mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-31 07:06:45 +00:00
Discard culled lights specifically for post-processing light buffer
This commit is contained in:
parent
05815b3952
commit
71c1b536b4
2 changed files with 16 additions and 5 deletions
|
@ -1122,8 +1122,10 @@ namespace SceneUtil
|
|||
}
|
||||
|
||||
const std::vector<LightManager::LightSourceViewBound>& LightManager::getLightsInViewSpace(
|
||||
osg::Camera* camera, const osg::RefMatrix* viewMatrix, size_t frameNum)
|
||||
osgUtil::CullVisitor* cv, const osg::RefMatrix* viewMatrix, size_t frameNum)
|
||||
{
|
||||
osg::Camera* camera = cv->getCurrentCamera();
|
||||
|
||||
osg::observer_ptr<osg::Camera> camPtr(camera);
|
||||
auto it = mLightsInViewSpace.find(camPtr);
|
||||
|
||||
|
@ -1175,13 +1177,22 @@ namespace SceneUtil
|
|||
|
||||
if (fillPPLights)
|
||||
{
|
||||
osg::CullingSet& cullingSet = cv->getModelViewCullingStack().front();
|
||||
for (const auto& bound : it->second)
|
||||
{
|
||||
if (bound.mLightSource->getEmpty())
|
||||
continue;
|
||||
const auto* light = bound.mLightSource->getLight(frameNum);
|
||||
if (light->getDiffuse().x() >= 0.f)
|
||||
mPPLightBuffer->setLight(frameNum, light, bound.mLightSource->getRadius());
|
||||
// Ignore negative lights
|
||||
if (light->getDiffuse().x() < 0.f)
|
||||
continue;
|
||||
const float radius = bound.mLightSource->getRadius();
|
||||
osg::BoundingSphere frustumBound = bound.mViewBound;
|
||||
frustumBound.radius() = radius * 2.f;
|
||||
// Ignore culled lights
|
||||
if (cullingSet.isCulled(frustumBound))
|
||||
continue;
|
||||
mPPLightBuffer->setLight(frameNum, light, radius);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1291,7 +1302,7 @@ namespace SceneUtil
|
|||
transformBoundingSphere(*cv->getModelViewMatrix(), nodeBound);
|
||||
|
||||
const std::vector<LightManager::LightSourceViewBound>& lights
|
||||
= mLightManager->getLightsInViewSpace(cv->getCurrentCamera(), viewMatrix, mLastFrameNumber);
|
||||
= mLightManager->getLightsInViewSpace(cv, viewMatrix, mLastFrameNumber);
|
||||
|
||||
mLightList.clear();
|
||||
for (const LightManager::LightSourceViewBound& light : lights)
|
||||
|
|
|
@ -238,7 +238,7 @@ namespace SceneUtil
|
|||
void addLight(LightSource* lightSource, const osg::Matrixf& worldMat, size_t frameNum);
|
||||
|
||||
const std::vector<LightSourceViewBound>& getLightsInViewSpace(
|
||||
osg::Camera* camera, const osg::RefMatrix* viewMatrix, size_t frameNum);
|
||||
osgUtil::CullVisitor* cv, const osg::RefMatrix* viewMatrix, size_t frameNum);
|
||||
|
||||
osg::ref_ptr<osg::StateSet> getLightListStateSet(
|
||||
const LightList& lightList, size_t frameNum, const osg::RefMatrix* viewMatrix);
|
||||
|
|
Loading…
Reference in a new issue