mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-22 12:39:59 +00:00
Merge branch 'visiblepp' into 'master'
Discard culled lights specifically for post-processing light buffer (#8009) Closes #8009 See merge request OpenMW/openmw!4144
This commit is contained in:
commit
2369694460
@ -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…
x
Reference in New Issue
Block a user