void LightClusteringPass::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& output) { auto args = renderContext->args; auto deferredTransform = inputs.get0(); auto lightingModel = inputs.get1(); auto surfaceGeometryFramebuffer = inputs.get2(); if (!_lightClusters) { _lightClusters = std::make_shared<LightClusters>(); } // first update the Grid with the new frustum if (!_freeze) { _lightClusters->updateFrustum(args->getViewFrustum()); } // From the LightStage and the current frame, update the light cluster Grid auto deferredLightingEffect = DependencyManager::get<DeferredLightingEffect>(); auto lightStage = deferredLightingEffect->getLightStage(); _lightClusters->updateLightStage(lightStage); _lightClusters->updateLightFrame(lightStage->_currentFrame, lightingModel->isPointLightEnabled(), lightingModel->isSpotLightEnabled()); auto clusteringStats = _lightClusters->updateClusters(); output = _lightClusters; auto config = std::static_pointer_cast<Config>(renderContext->jobConfig); config->numSceneLights = lightStage->getNumLights(); config->numFreeSceneLights = lightStage->getNumFreeLights(); config->numAllocatedSceneLights = lightStage->getNumAllocatedLights(); config->setNumInputLights(clusteringStats.x); config->setNumClusteredLights(clusteringStats.y); config->setNumClusteredLightReferences(clusteringStats.z); }
/** * Pushes a new light onto the global light configuration vector * @return void **/ void Engine::addLight( Light *newLight ) { _lights->push_back( newLight ); getNumLights(); }