Showing the changes to libraries/render-utils/src/DeferredLightingEffect.cpp (1 of 22 files). Show all
Unified · Split
| @@ -87,6 +87,8 @@ void DeferredLightingEffect::init() { · 86 unmodified lines | |||
| 87 | _allocatedLights.push_back(std::make_shared<model::Light>()); | 87 | _allocatedLights.push_back(std::make_shared<model::Light>()); |
| 88 | 88 | ||
| 89 | model::LightPointer lp = _allocatedLights[0]; | 89 | model::LightPointer lp = _allocatedLights[0]; |
| 90 | lp->setType(model::Light::SUN); | ||
| 91 | |||
| 90 | // Add the global light to the light stage (for later shadow rendering) | 92 | // Add the global light to the light stage (for later shadow rendering) |
| 91 | _lightStage.addLight(lp); | 93 | _lightStage.addLight(lp); |
| 92 | 94 | ||
| @@ -318,18 +320,18 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo · 225 unmodified lines | |||
| 318 | // Setup the global directional pass pipeline | 320 | // Setup the global directional pass pipeline |
| 319 | { | 321 | { |
| 320 | if (_shadowMapEnabled) { | 322 | if (_shadowMapEnabled) { |
| 321 | if (_skyboxTexture) { | 323 | /* if (_skyboxTexture) { |
| 322 | program = _directionalSkyboxLightShadow; | 324 | program = _directionalSkyboxLightShadow; |
| 323 | locations = _directionalSkyboxLightShadowLocations; | 325 | locations = _directionalSkyboxLightShadowLocations; |
| 324 | } else { | 326 | } else {*/ |
| 325 | program = _directionalAmbientSphereLightShadow; | 327 | program = _directionalAmbientSphereLightShadow; |
| 326 | locations = _directionalAmbientSphereLightShadowLocations; | 328 | locations = _directionalAmbientSphereLightShadowLocations; |
| 327 | } | 329 | } |
| 328 | } else { | 330 | } else { |
| 329 | if (_skyboxTexture) { | 331 | /* if (_skyboxTexture) { |
| 330 | program = _directionalSkyboxLight; | 332 | program = _directionalSkyboxLight; |
| 331 | locations = _directionalSkyboxLightLocations; | 333 | locations = _directionalSkyboxLightLocations; |
| 332 | } else { | 334 | } else {*/ |
| 333 | program = _directionalAmbientSphereLight; | 335 | program = _directionalAmbientSphereLight; |
| 334 | locations = _directionalAmbientSphereLightLocations; | 336 | locations = _directionalAmbientSphereLightLocations; |
| 335 | } | 337 | } |
| @@ -560,16 +562,17 @@ static void loadLightProgram(const char* vertSource, const char* fragSource, boo · 224 unmodified lines | |||
| 560 | } | 562 | } |
| 561 | 563 | ||
| 562 | void DeferredLightingEffect::setGlobalLight(const model::LightPointer& light, const gpu::TexturePointer& skyboxTexture) { | 564 | void DeferredLightingEffect::setGlobalLight(const model::LightPointer& light, const gpu::TexturePointer& skyboxTexture) { |
| 563 | _allocatedLights.front() = light; | 565 | auto globalLight = _allocatedLights.front(); |
| 566 | globalLight->setDirection(light->getDirection()); | ||
| 567 | globalLight->setColor(light->getColor()); | ||
| 568 | globalLight->setIntensity(light->getIntensity()); | ||
| 569 | globalLight->setAmbientIntensity(light->getAmbientIntensity()); | ||
| 570 | globalLight->setAmbientSphere(light->getAmbientSphere()); | ||
| 571 | |||
| 564 | _skyboxTexture = skyboxTexture; | 572 | _skyboxTexture = skyboxTexture; |
| 565 | 573 | ||
| 566 | // Update the available mipmap levels | 574 | // Update the available mipmap levels |
| 567 | if (_skyboxTexture) { | 575 | globalLight->setAmbientMapNumMips((_skyboxTexture ? _skyboxTexture->evalNumMips() : 0)); |
| 568 | float dim = glm::max(_skyboxTexture->getHeight(), _skyboxTexture->getWidth(), _skyboxTexture->getDepth()); | ||
| 569 | auto skyboxMipmapLevels = 1 + glm::floor(glm::log2(dim)); | ||
| 570 | _deferredTransformBuffer[0].edit<DeferredTransform>().skyboxMipmapLevels = skyboxMipmapLevels; | ||
| 571 | _deferredTransformBuffer[1].edit<DeferredTransform>().skyboxMipmapLevels = skyboxMipmapLevels; | ||
| 572 | } | ||
| 573 | } | 576 | } |
| 574 | 577 | ||
| 575 | model::MeshPointer DeferredLightingEffect::getSpotLightMesh() { | 578 | model::MeshPointer DeferredLightingEffect::getSpotLightMesh() { |