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 | 87 | _allocatedLights.push_back(std::make_shared<model::Light>()); |
| 88 | 88 | |
| 89 | 89 | model::LightPointer lp = _allocatedLights[0]; |
| 90 | + lp->setType(model::Light::SUN); | |
| 91 | + | |
| 90 | 92 | // Add the global light to the light stage (for later shadow rendering) |
| 91 | 93 | _lightStage.addLight(lp); |
| 92 | 94 | |
| @@ -318,18 +320,18 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo · 225 unmodified lines | ||
| 318 | 320 | // Setup the global directional pass pipeline |
| 319 | 321 | { |
| 320 | 322 | if (_shadowMapEnabled) { |
| 321 | − if (_skyboxTexture) { | |
| 323 | + /* if (_skyboxTexture) { | |
| 322 | 324 | program = _directionalSkyboxLightShadow; |
| 323 | 325 | locations = _directionalSkyboxLightShadowLocations; |
| 324 | − } else { | |
| 326 | + } else {*/ | |
| 325 | 327 | program = _directionalAmbientSphereLightShadow; |
| 326 | 328 | locations = _directionalAmbientSphereLightShadowLocations; |
| 327 | 329 | } |
| 328 | 330 | } else { |
| 329 | − if (_skyboxTexture) { | |
| 331 | + /* if (_skyboxTexture) { | |
| 330 | 332 | program = _directionalSkyboxLight; |
| 331 | 333 | locations = _directionalSkyboxLightLocations; |
| 332 | − } else { | |
| 334 | + } else {*/ | |
| 333 | 335 | program = _directionalAmbientSphereLight; |
| 334 | 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 | 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 | 572 | _skyboxTexture = skyboxTexture; |
| 565 | 573 | |
| 566 | 574 | // Update the available mipmap levels |
| 567 | − if (_skyboxTexture) { | |
| 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 | − } | |
| 575 | + globalLight->setAmbientMapNumMips((_skyboxTexture ? _skyboxTexture->evalNumMips() : 0)); | |
| 573 | 576 | } |
| 574 | 577 | |
| 575 | 578 | model::MeshPointer DeferredLightingEffect::getSpotLightMesh() { |