History

Creating a separate shader for the locallighting pass

samcake committed 10 years ago

Commit 665a79f1 parent edb456a3 files · +115 −8Browse files

Showing the changes to libraries/render-utils/src/DeferredLightingEffect.cpp (1 of 3 files). Show all

Unified · Split

libraries/render-utils/src/DeferredLightingEffect.cpp+9−7
@@ -35,6 +35,7 @@ · 34 unmodified lines
3535 #include "directional_ambient_light_shadow_frag.h"
3636 #include "directional_skybox_light_shadow_frag.h"
3737
38+#include "local_lights_shading_frag.h"
3839 #include "point_light_frag.h"
3940 #include "spot_light_frag.h"
4041
@@ -96,6 +97,7 @@ void DeferredLightingEffect::init() { · 55 unmodified lines
9697 loadLightProgram(deferred_light_vert, directional_ambient_light_shadow_frag, false, _directionalAmbientSphereLightShadow, _directionalAmbientSphereLightShadowLocations);
9798 loadLightProgram(deferred_light_vert, directional_skybox_light_shadow_frag, false, _directionalSkyboxLightShadow, _directionalSkyboxLightShadowLocations);
9899
100+ loadLightProgram(deferred_light_vert, local_lights_shading_frag, false, _localLight, _localLightLocations);
99101 loadLightProgram(deferred_light_limited_vert, point_light_frag, true, _pointLight, _pointLightLocations);
100102 loadLightProgram(deferred_light_vert, spot_light_frag, false, _spotLight, _spotLightLocations);
101103
@@ -570,7 +572,7 @@ void RenderDeferredSetup::run(const render::SceneContextPointer& sceneContext, c · 468 unmodified lines
570572 }
571573
572574 RenderDeferredLocals::RenderDeferredLocals() :
573−_spotLightsBuffer(std::make_shared<gpu::Buffer>()) {
575+_localLightsBuffer(std::make_shared<gpu::Buffer>()) {
574576
575577 }
576578
@@ -628,16 +630,16 @@ void RenderDeferredLocals::run(const render::SceneContextPointer& sceneContext, · 51 unmodified lines
628630 }
629631
630632 if (lightIndices[0] > 0) {
631− _spotLightsBuffer._buffer->setData(lightIndices.size() * sizeof(int), (const gpu::Byte*) lightIndices.data());
632− _spotLightsBuffer._size = lightIndices.size() * sizeof(int);
633+ _localLightsBuffer._buffer->setData(lightIndices.size() * sizeof(int), (const gpu::Byte*) lightIndices.data());
634+ _localLightsBuffer._size = lightIndices.size() * sizeof(int);
633635
634636 // Spot light pipeline
635− batch.setPipeline(deferredLightingEffect->_spotLight);
636− batch._glUniform4fv(deferredLightingEffect->_spotLightLocations->texcoordFrameTransform, 1, reinterpret_cast<const float*>(&textureFrameTransform));
637+ batch.setPipeline(deferredLightingEffect->_localLight);
638+ batch._glUniform4fv(deferredLightingEffect->_localLightLocations->texcoordFrameTransform, 1, reinterpret_cast<const float*>(&textureFrameTransform));
637639
638640 // Bind the global list of lights and the visible lights this frame
639− batch.setUniformBuffer(deferredLightingEffect->_spotLightLocations->lightBufferUnit, deferredLightingEffect->getLightStage()._lightArrayBuffer);
640− batch.setUniformBuffer(deferredLightingEffect->_spotLightLocations->lightIndexBufferUnit, _spotLightsBuffer);
641+ batch.setUniformBuffer(deferredLightingEffect->_localLightLocations->lightBufferUnit, deferredLightingEffect->getLightStage()._lightArrayBuffer);
642+ batch.setUniformBuffer(deferredLightingEffect->_localLightLocations->lightIndexBufferUnit, _localLightsBuffer);
641643 batch.draw(gpu::TRIANGLE_STRIP, 4);
642644 }
643645 }