Differentiate global sun and skyStage sun

This commit is contained in:
Zach Pomerantz 2016-02-26 11:06:02 -08:00
parent 3c53078178
commit 712cf911b1
2 changed files with 11 additions and 6 deletions

View file

@ -142,6 +142,8 @@ SunSkyStage::SunSkyStage() :
_skybox(std::make_shared<Skybox>())
{
_sunLight->setType(Light::SUN);
// Default ambient sphere (for lack of skybox)
_sunLight->setAmbientSpherePreset(gpu::SphericalHarmonics::Preset::OLD_TOWN_SQUARE);
setSunIntensity(1.0f);
setSunAmbientIntensity(0.5f);

View file

@ -87,14 +87,11 @@ void DeferredLightingEffect::init() {
_allocatedLights.push_back(std::make_shared<model::Light>());
model::LightPointer lp = _allocatedLights[0];
lp->setType(model::Light::SUN);
// Add the global light to the light stage (for later shadow rendering)
_lightStage.addLight(lp);
lp->setDirection(-glm::vec3(1.0f, 1.0f, 1.0f));
lp->setColor(glm::vec3(1.0f));
lp->setIntensity(1.0f);
lp->setType(model::Light::SUN);
lp->setAmbientSpherePreset(gpu::SphericalHarmonics::Preset(_ambientLightMode % gpu::SphericalHarmonics::NUM_PRESET));
}
void DeferredLightingEffect::addPointLight(const glm::vec3& position, float radius, const glm::vec3& color,
@ -560,7 +557,13 @@ static void loadLightProgram(const char* vertSource, const char* fragSource, boo
}
void DeferredLightingEffect::setGlobalLight(const model::LightPointer& light, const gpu::TexturePointer& skyboxTexture) {
_allocatedLights.front() = light;
auto globalLight = _allocatedLights.front();
globalLight->setDirection(light->getDirection());
globalLight->setColor(light->getColor());
globalLight->setIntensity(light->getIntensity());
globalLight->setAmbientIntensity(light->getAmbientIntensity());
globalLight->setAmbientSphere(light->getAmbientSphere());
_skyboxTexture = skyboxTexture;
}