Merge pull request #6 from zzmp/refactor/skybox-tex-orange

Use keyLight in DLE instead of _skyboxTexture
This commit is contained in:
samcake 2016-03-01 14:49:13 -08:00
commit f09f28096f
4 changed files with 14 additions and 18 deletions

View file

@ -3818,7 +3818,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
// Setup the current Zone Entity lighting
{
auto stage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
DependencyManager::get<DeferredLightingEffect>()->setGlobalLight(stage->getSunLight(), stage->getSkybox()->getCubemap());
DependencyManager::get<DeferredLightingEffect>()->setGlobalLight(stage->getSunLight());
}
{

View file

@ -273,6 +273,7 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
if (_hasPreviousZone) {
sceneKeyLight->resetAmbientSphere();
sceneKeyLight->setAmbientMap(nullptr);
sceneKeyLight->setColor(_previousKeyLightColor);
sceneKeyLight->setIntensity(_previousKeyLightIntensity);
sceneKeyLight->setAmbientIntensity(_previousKeyLightAmbientIntensity);
@ -383,6 +384,7 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
if (!isAmbientTextureSet) {
sceneKeyLight->resetAmbientSphere();
sceneKeyLight->setAmbientMap(nullptr);
}
}

View file

@ -316,12 +316,12 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo
{
auto& program = _shadowMapEnabled ? _directionalLightShadow : _directionalLight;
LightLocationsPtr locations = _shadowMapEnabled ? _directionalLightShadowLocations : _directionalLightLocations;
const auto& keyLight = _allocatedLights[_globalLights.front()];
// Setup the global directional pass pipeline
{
if (_shadowMapEnabled) {
//if (_skyboxTexture) {
if (_skyboxTexture) {
if (keyLight->getAmbientMap()) {
program = _directionalSkyboxLightShadow;
locations = _directionalSkyboxLightShadowLocations;
} else {
@ -329,7 +329,7 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo
locations = _directionalAmbientSphereLightShadowLocations;
}
} else {
if (_skyboxTexture) {
if (keyLight->getAmbientMap()) {
program = _directionalSkyboxLight;
locations = _directionalSkyboxLightLocations;
} else {
@ -357,7 +357,7 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo
geometryCache->renderQuad(batch, topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, color);
}
if (_skyboxTexture) {
if (keyLight->getAmbientMap()) {
batch.setResourceTexture(SKYBOX_MAP_UNIT, nullptr);
}
}
@ -496,14 +496,14 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo
void DeferredLightingEffect::setupKeyLightBatch(gpu::Batch& batch, int lightBufferUnit, int skyboxCubemapUnit) {
PerformanceTimer perfTimer("DLE->setupBatch()");
auto globalLight = _allocatedLights[_globalLights.front()];
auto keyLight = _allocatedLights[_globalLights.front()];
if (lightBufferUnit >= 0) {
batch.setUniformBuffer(lightBufferUnit, globalLight->getSchemaBuffer());
batch.setUniformBuffer(lightBufferUnit, keyLight->getSchemaBuffer());
}
if (globalLight->getAmbientMap() && (skyboxCubemapUnit >= 0)) {
batch.setResourceTexture(skyboxCubemapUnit, globalLight->getAmbientMap());
if (keyLight->getAmbientMap() && (skyboxCubemapUnit >= 0)) {
batch.setResourceTexture(skyboxCubemapUnit, keyLight->getAmbientMap());
}
}
@ -562,18 +562,14 @@ static void loadLightProgram(const char* vertSource, const char* fragSource, boo
}
void DeferredLightingEffect::setGlobalLight(const model::LightPointer& light, const gpu::TexturePointer& skyboxTexture) {
void DeferredLightingEffect::setGlobalLight(const model::LightPointer& 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 = (light->getAmbientMap() ? light->getAmbientMap() : _skyboxTexture);
// Update the available mipmap levels
globalLight->setAmbientMap(_skyboxTexture);
globalLight->setAmbientMap(light->getAmbientMap());
}
model::MeshPointer DeferredLightingEffect::getSpotLightMesh() {

View file

@ -49,7 +49,7 @@ public:
void setupKeyLightBatch(gpu::Batch& batch, int lightBufferUnit, int skyboxCubemapUnit);
// update global lighting
void setGlobalLight(const model::LightPointer& light, const gpu::TexturePointer& skyboxTexture);
void setGlobalLight(const model::LightPointer& light);
const LightStage& getLightStage() { return _lightStage; }
void setShadowMapEnabled(bool enable) { _shadowMapEnabled = enable; };
@ -96,8 +96,6 @@ private:
std::vector<int> _pointLights;
std::vector<int> _spotLights;
gpu::TexturePointer _skyboxTexture;
// Class describing the uniform buffer with all the parameters common to the deferred shaders
class DeferredTransform {
public: