some clean up:

This commit is contained in:
samcake 2017-05-23 18:00:22 -07:00
parent 769655b354
commit c256893575
4 changed files with 80 additions and 66 deletions

View file

@ -373,12 +373,6 @@ void RenderableZoneEntityItem::updateKeyZoneItemFromEntity(RenderableZoneEntityI
if (!success) { if (!success) {
keyZonePayload.editBound() = render::Item::Bound(); keyZonePayload.editBound() = render::Item::Bound();
} }
updateKeySunFromEntity(keyZonePayload);
updateKeyAmbientFromEntity(keyZonePayload);
updateKeyBackgroundFromEntity(keyZonePayload);
} }
@ -387,8 +381,25 @@ void RenderableZoneEntityItem::sceneUpdateRenderItemFromEntity(render::Transacti
return; return;
} }
transaction.updateItem<RenderableZoneEntityItemMeta>(_myMetaItem, [&](RenderableZoneEntityItemMeta& data) { bool sunChanged = _keyLightPropertiesChanged;
bool backgroundChanged = _backgroundPropertiesChanged;
bool stageChanged = _stagePropertiesChanged;
bool skyboxChanged = _skyboxPropertiesChanged;
transaction.updateItem<RenderableZoneEntityItemMeta>(_myMetaItem, [=](RenderableZoneEntityItemMeta& data) {
updateKeyZoneItemFromEntity(data); updateKeyZoneItemFromEntity(data);
if (sunChanged) {
updateKeySunFromEntity(data);
}
if (sunChanged || skyboxChanged) {
updateKeyAmbientFromEntity(data);
}
if (backgroundChanged || skyboxChanged) {
updateKeyBackgroundFromEntity(data);
}
}); });
} }

View file

@ -123,7 +123,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
// Draw Lights just add the lights to the current list of lights to deal with. NOt really gpu job for now. // Draw Lights just add the lights to the current list of lights to deal with. NOt really gpu job for now.
task.addJob<DrawLight>("DrawLight", lights); task.addJob<DrawLight>("DrawLight", lights);
// Filter zones // Filter zones from the general metas bucket
const auto zones = task.addJob<ZoneRendererTask>("ZoneRenderer", metas); const auto zones = task.addJob<ZoneRendererTask>("ZoneRenderer", metas);
// Light Clustering // Light Clustering
@ -138,12 +138,9 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
task.addJob<RenderDeferred>("RenderDeferred", deferredLightingInputs); task.addJob<RenderDeferred>("RenderDeferred", deferredLightingInputs);
// Use Stencil and draw background in Lighting buffer to complete filling in the opaque // Similar to light stage, background stage has been filled by several potential render items and resolved for the frame in this job
//const auto backgroundInputs = DrawBackgroundDeferred::Inputs(background, lightingModel).hasVarying();
//task.addJob<DrawBackgroundDeferred>("DrawBackgroundDeferred", backgroundInputs);
task.addJob<DrawBackgroundStage>("DrawBackgroundDeferred", lightingModel); task.addJob<DrawBackgroundStage>("DrawBackgroundDeferred", lightingModel);
// Render transparent objects forward in LightingBuffer // Render transparent objects forward in LightingBuffer
const auto transparentsInputs = DrawDeferred::Inputs(transparents, lightingModel).hasVarying(); const auto transparentsInputs = DrawDeferred::Inputs(transparents, lightingModel).hasVarying();
task.addJob<DrawDeferred>("DrawTransparentDeferred", transparentsInputs, shapePlumber); task.addJob<DrawDeferred>("DrawTransparentDeferred", transparentsInputs, shapePlumber);
@ -207,7 +204,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
task.addJob<DrawStatus>("DrawStatus", opaques, DrawStatus(statusIconMap)); task.addJob<DrawStatus>("DrawStatus", opaques, DrawStatus(statusIconMap));
} }
task.addJob<DebugZoneLighting>("DebugZoneLighting", deferredFrameTransform); task.addJob<DebugZoneLighting>("DrawZoneStack", deferredFrameTransform);
} }

View file

@ -127,34 +127,34 @@ void DebugZoneLighting::run(const render::RenderContextPointer& context, const I
auto deferredTransform = inputs; auto deferredTransform = inputs;
auto lightStage = DependencyManager::get<DeferredLightingEffect>()->getLightStage(); auto lightStage = DependencyManager::get<DeferredLightingEffect>()->getLightStage();
std::vector<model::LightPointer> keyLightStack; std::vector<model::LightPointer> keyLightStack;
if (lightStage && lightStage->_currentFrame._sunLights.size()) { if (lightStage && lightStage->_currentFrame._sunLights.size()) {
for (auto index : lightStage->_currentFrame._sunLights) { for (auto index : lightStage->_currentFrame._sunLights) {
keyLightStack.push_back(lightStage->getLight(index)); keyLightStack.push_back(lightStage->getLight(index));
} }
} }
keyLightStack.push_back(DependencyManager::get<DeferredLightingEffect>()->getGlobalLight()); keyLightStack.push_back(DependencyManager::get<DeferredLightingEffect>()->getGlobalLight());
std::vector<model::LightPointer> ambientLightStack; std::vector<model::LightPointer> ambientLightStack;
if (lightStage && lightStage->_currentFrame._ambientLights.size()) { if (lightStage && lightStage->_currentFrame._ambientLights.size()) {
for (auto index : lightStage->_currentFrame._ambientLights) { for (auto index : lightStage->_currentFrame._ambientLights) {
ambientLightStack.push_back(lightStage->getLight(index)); ambientLightStack.push_back(lightStage->getLight(index));
} }
} }
ambientLightStack.push_back(DependencyManager::get<DeferredLightingEffect>()->getGlobalLight()); ambientLightStack.push_back(DependencyManager::get<DeferredLightingEffect>()->getGlobalLight());
auto backgroundStage = DependencyManager::get<DeferredLightingEffect>()->getBackgroundStage(); auto backgroundStage = DependencyManager::get<DeferredLightingEffect>()->getBackgroundStage();
std::vector<model::SkyboxPointer> skyboxStack; std::vector<model::SkyboxPointer> skyboxStack;
if (backgroundStage && backgroundStage->_currentFrame._backgrounds.size()) { if (backgroundStage && backgroundStage->_currentFrame._backgrounds.size()) {
for (auto index : backgroundStage->_currentFrame._backgrounds) { for (auto index : backgroundStage->_currentFrame._backgrounds) {
auto background = backgroundStage->getBackground(index); auto background = backgroundStage->getBackground(index);
if (background) { if (background) {
skyboxStack.push_back(background->getSkybox()); skyboxStack.push_back(background->getSkybox());
} }
} }
} }
skyboxStack.push_back(DependencyManager::get<DeferredLightingEffect>()->getDefaultSkybox()); skyboxStack.push_back(DependencyManager::get<DeferredLightingEffect>()->getDefaultSkybox());
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
@ -169,40 +169,40 @@ void DebugZoneLighting::run(const render::RenderContextPointer& context, const I
batch.setUniformBuffer(ZONE_DEFERRED_TRANSFORM_BUFFER, deferredTransform->getFrameTransformBuffer()); batch.setUniformBuffer(ZONE_DEFERRED_TRANSFORM_BUFFER, deferredTransform->getFrameTransformBuffer());
batch.setPipeline(getKeyLightPipeline()); batch.setPipeline(getKeyLightPipeline());
auto numKeys = keyLightStack.size(); auto numKeys = keyLightStack.size();
for (int i = numKeys - 1; i >= 0; i--) { for (int i = numKeys - 1; i >= 0; i--) {
model.setTranslation(glm::vec3(-4.0, -3.0 + (i * 1.0), -10.0 - (i * 3.0))); model.setTranslation(glm::vec3(-4.0, -3.0 + (i * 1.0), -10.0 - (i * 3.0)));
batch.setModelTransform(model); batch.setModelTransform(model);
if (keyLightStack[i]) { if (keyLightStack[i]) {
batch.setUniformBuffer(ZONE_KEYLIGHT_BUFFER, keyLightStack[i]->getLightSchemaBuffer()); batch.setUniformBuffer(ZONE_KEYLIGHT_BUFFER, keyLightStack[i]->getLightSchemaBuffer());
batch.draw(gpu::TRIANGLE_STRIP, 4); batch.draw(gpu::TRIANGLE_STRIP, 4);
} }
} }
batch.setPipeline(getAmbientPipeline()); batch.setPipeline(getAmbientPipeline());
auto numAmbients = ambientLightStack.size(); auto numAmbients = ambientLightStack.size();
for (int i = numAmbients - 1; i >= 0; i--) { for (int i = numAmbients - 1; i >= 0; i--) {
model.setTranslation(glm::vec3(0.0, -3.0 + (i * 1.0), -10.0 - (i * 3.0))); model.setTranslation(glm::vec3(0.0, -3.0 + (i * 1.0), -10.0 - (i * 3.0)));
batch.setModelTransform(model); batch.setModelTransform(model);
if (ambientLightStack[i]) { if (ambientLightStack[i]) {
batch.setUniformBuffer(ZONE_AMBIENT_BUFFER, ambientLightStack[i]->getAmbientSchemaBuffer()); batch.setUniformBuffer(ZONE_AMBIENT_BUFFER, ambientLightStack[i]->getAmbientSchemaBuffer());
if (ambientLightStack[i]->getAmbientMap()) { if (ambientLightStack[i]->getAmbientMap()) {
batch.setResourceTexture(ZONE_AMBIENT_MAP, ambientLightStack[i]->getAmbientMap()); batch.setResourceTexture(ZONE_AMBIENT_MAP, ambientLightStack[i]->getAmbientMap());
} }
batch.draw(gpu::TRIANGLE_STRIP, 4); batch.draw(gpu::TRIANGLE_STRIP, 4);
} }
} }
batch.setPipeline(getBackgroundPipeline()); batch.setPipeline(getBackgroundPipeline());
auto numBackgrounds = skyboxStack.size(); auto numBackgrounds = skyboxStack.size();
for (int i = numBackgrounds - 1; i >= 0; i--) { for (int i = numBackgrounds - 1; i >= 0; i--) {
model.setTranslation(glm::vec3(4.0, -3.0 + (i * 1.0), -10.0 - (i * 3.0))); model.setTranslation(glm::vec3(4.0, -3.0 + (i * 1.0), -10.0 - (i * 3.0)));
batch.setModelTransform(model); batch.setModelTransform(model);
if (skyboxStack[i]) { if (skyboxStack[i]) {
batch.setResourceTexture(ZONE_SKYBOX_MAP, skyboxStack[i]->getCubemap()); batch.setResourceTexture(ZONE_SKYBOX_MAP, skyboxStack[i]->getCubemap());
batch.setUniformBuffer(ZONE_SKYBOX_BUFFER, skyboxStack[i]->getSchemaBuffer()); batch.setUniformBuffer(ZONE_SKYBOX_BUFFER, skyboxStack[i]->getSchemaBuffer());
batch.draw(gpu::TRIANGLE_STRIP, 4); batch.draw(gpu::TRIANGLE_STRIP, 4);
} }
} }
}); });
} }

View file

@ -54,11 +54,17 @@ protected:
class DebugZoneLighting { class DebugZoneLighting {
public: public:
class Config : public render::JobConfig {
public:
Config(bool enabled = false) : JobConfig(enabled) {}
};
using Inputs = DeferredFrameTransformPointer; using Inputs = DeferredFrameTransformPointer;
using JobModel = render::Job::ModelI<DebugZoneLighting, Inputs>; using JobModel = render::Job::ModelI<DebugZoneLighting, Inputs, Config>;
DebugZoneLighting() {} DebugZoneLighting() {}
void configure(const Config& configuration) {}
void run(const render::RenderContextPointer& context, const Inputs& inputs); void run(const render::RenderContextPointer& context, const Inputs& inputs);
protected: protected: