Showing the changes to libraries/render-utils/src/DeferredLightingEffect.cpp (1 of 3 files). Show all
Unified · Split
| @@ -35,6 +35,7 @@ · 34 unmodified lines | |||
| 35 | #include "directional_ambient_light_shadow_frag.h" | 35 | #include "directional_ambient_light_shadow_frag.h" |
| 36 | #include "directional_skybox_light_shadow_frag.h" | 36 | #include "directional_skybox_light_shadow_frag.h" |
| 37 | 37 | ||
| 38 | #include "local_lights_shading_frag.h" | ||
| 38 | #include "point_light_frag.h" | 39 | #include "point_light_frag.h" |
| 39 | #include "spot_light_frag.h" | 40 | #include "spot_light_frag.h" |
| 40 | 41 | ||
| @@ -96,6 +97,7 @@ void DeferredLightingEffect::init() { · 55 unmodified lines | |||
| 96 | loadLightProgram(deferred_light_vert, directional_ambient_light_shadow_frag, false, _directionalAmbientSphereLightShadow, _directionalAmbientSphereLightShadowLocations); | 97 | loadLightProgram(deferred_light_vert, directional_ambient_light_shadow_frag, false, _directionalAmbientSphereLightShadow, _directionalAmbientSphereLightShadowLocations); |
| 97 | loadLightProgram(deferred_light_vert, directional_skybox_light_shadow_frag, false, _directionalSkyboxLightShadow, _directionalSkyboxLightShadowLocations); | 98 | loadLightProgram(deferred_light_vert, directional_skybox_light_shadow_frag, false, _directionalSkyboxLightShadow, _directionalSkyboxLightShadowLocations); |
| 98 | 99 | ||
| 100 | loadLightProgram(deferred_light_vert, local_lights_shading_frag, false, _localLight, _localLightLocations); | ||
| 99 | loadLightProgram(deferred_light_limited_vert, point_light_frag, true, _pointLight, _pointLightLocations); | 101 | loadLightProgram(deferred_light_limited_vert, point_light_frag, true, _pointLight, _pointLightLocations); |
| 100 | loadLightProgram(deferred_light_vert, spot_light_frag, false, _spotLight, _spotLightLocations); | 102 | loadLightProgram(deferred_light_vert, spot_light_frag, false, _spotLight, _spotLightLocations); |
| 101 | 103 | ||
| @@ -570,7 +572,7 @@ void RenderDeferredSetup::run(const render::SceneContextPointer& sceneContext, c · 468 unmodified lines | |||
| 570 | } | 572 | } |
| 571 | 573 | ||
| 572 | RenderDeferredLocals::RenderDeferredLocals() : | 574 | RenderDeferredLocals::RenderDeferredLocals() : |
| 573 | _spotLightsBuffer(std::make_shared<gpu::Buffer>()) { | 575 | _localLightsBuffer(std::make_shared<gpu::Buffer>()) { |
| 574 | 576 | ||
| 575 | } | 577 | } |
| 576 | 578 | ||
| @@ -628,16 +630,16 @@ void RenderDeferredLocals::run(const render::SceneContextPointer& sceneContext, · 51 unmodified lines | |||
| 628 | } | 630 | } |
| 629 | 631 | ||
| 630 | if (lightIndices[0] > 0) { | 632 | if (lightIndices[0] > 0) { |
| 631 | _spotLightsBuffer._buffer->setData(lightIndices.size() * sizeof(int), (const gpu::Byte*) lightIndices.data()); | 633 | _localLightsBuffer._buffer->setData(lightIndices.size() * sizeof(int), (const gpu::Byte*) lightIndices.data()); |
| 632 | _spotLightsBuffer._size = lightIndices.size() * sizeof(int); | 634 | _localLightsBuffer._size = lightIndices.size() * sizeof(int); |
| 633 | 635 | ||
| 634 | // Spot light pipeline | 636 | // Spot light pipeline |
| 635 | batch.setPipeline(deferredLightingEffect->_spotLight); | 637 | batch.setPipeline(deferredLightingEffect->_localLight); |
| 636 | batch._glUniform4fv(deferredLightingEffect->_spotLightLocations->texcoordFrameTransform, 1, reinterpret_cast<const float*>(&textureFrameTransform)); | 638 | batch._glUniform4fv(deferredLightingEffect->_localLightLocations->texcoordFrameTransform, 1, reinterpret_cast<const float*>(&textureFrameTransform)); |
| 637 | 639 | ||
| 638 | // Bind the global list of lights and the visible lights this frame | 640 | // Bind the global list of lights and the visible lights this frame |
| 639 | batch.setUniformBuffer(deferredLightingEffect->_spotLightLocations->lightBufferUnit, deferredLightingEffect->getLightStage()._lightArrayBuffer); | 641 | batch.setUniformBuffer(deferredLightingEffect->_localLightLocations->lightBufferUnit, deferredLightingEffect->getLightStage()._lightArrayBuffer); |
| 640 | batch.setUniformBuffer(deferredLightingEffect->_spotLightLocations->lightIndexBufferUnit, _spotLightsBuffer); | 642 | batch.setUniformBuffer(deferredLightingEffect->_localLightLocations->lightIndexBufferUnit, _localLightsBuffer); |
| 641 | batch.draw(gpu::TRIANGLE_STRIP, 4); | 643 | batch.draw(gpu::TRIANGLE_STRIP, 4); |
| 642 | } | 644 | } |
| 643 | } | 645 | } |