For testing.

This commit is contained in:
Nissim Hadar 2017-10-03 09:54:44 -07:00
parent 93a2776cb5
commit 1cf7f5a732
7 changed files with 38 additions and 28 deletions

View file

@ -149,14 +149,16 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) {
}
}
if (_needHazeUpdate) {
if (HazeStage::isIndexInvalid(_hazeIndex)) {
_hazeIndex = _hazeStage->addHaze(_haze);
}
else {
{
if (_needHazeUpdate) {
if (HazeStage::isIndexInvalid(_hazeIndex)) {
_hazeIndex = _hazeStage->addHaze(_haze);
}
else {
}
_needHazeUpdate = false;
}
_needHazeUpdate = false;
}
if (_visible) {
@ -171,12 +173,12 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) {
// The background only if the mode is not inherit
if (_backgroundMode != BACKGROUND_MODE_INHERIT) {
_backgroundStage->_currentFrame.pushBackground(_backgroundIndex);
_backgroundStage->_currentBackgroundFrame.pushBackground(_backgroundIndex);
}
// The haze only if the mode is not inherit
if (_hazeMode != HAZE_MODE_INHERIT) {
_hazeStage->_currentFrame.pushHaze(_hazeIndex);
_hazeStage->_currentHazeFrame.pushHaze(_hazeIndex);
}
}
}
@ -466,6 +468,7 @@ void ZoneEntityRenderer::updateSkyboxMap() {
void ZoneEntityRenderer::setBackgroundMode(BackgroundMode mode) {
_backgroundMode = mode;
}
void ZoneEntityRenderer::setHazeMode(HazeMode mode) {
_hazeMode = mode;
}

View file

@ -65,8 +65,8 @@ void DrawBackgroundStage::run(const render::RenderContextPointer& renderContext,
model::SunSkyStagePointer background;
model::SkyboxPointer skybox;
if (backgroundStage->_currentFrame._backgrounds.size()) {
auto backgroundId = backgroundStage->_currentFrame._backgrounds.front();
if (backgroundStage->_currentBackgroundFrame._backgrounds.size()) {
auto backgroundId = backgroundStage->_currentBackgroundFrame._backgrounds.front();
auto background = backgroundStage->getBackground(backgroundId);
if (background) {
skybox = background->getSkybox();

View file

@ -55,9 +55,9 @@ public:
Backgrounds _backgrounds;
BackgroundMap _backgroundMap;
class Frame {
class BackgroundFrame {
public:
Frame() {}
BackgroundFrame() {}
void clear() { _backgrounds.clear(); }
@ -66,7 +66,7 @@ public:
BackgroundStage::BackgroundIndices _backgrounds;
};
Frame _currentFrame;
BackgroundFrame _currentBackgroundFrame;
};
using BackgroundStagePointer = std::shared_ptr<BackgroundStage>;

View file

@ -16,6 +16,7 @@
#include "StencilMaskPass.h"
#include "FramebufferCache.h"
#include "HazeStage.h"
#include "Haze_frag.h"
@ -140,6 +141,8 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu
auto depthBuffer = framebuffer->getLinearDepthTexture();
RenderArgs* args = renderContext->args;
if (_hazePipeline == nullptr) {
gpu::ShaderPointer ps = gpu::Shader::createPixel(std::string(Haze_frag));
gpu::ShaderPointer vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
@ -162,19 +165,23 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu
auto sourceFramebufferSize = glm::ivec2(inputBuffer->getDimensions());
gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) {
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
batch.enableStereo(false);
batch.setFramebuffer(outputBuffer);
batch.setViewportTransform(renderContext->args->_viewport);
batch.setViewportTransform(args->_viewport);
batch.setProjectionTransform(glm::mat4());
batch.resetViewTransform();
batch.setModelTransform(
gpu::Framebuffer::evalSubregionTexcoordTransform(sourceFramebufferSize, renderContext->args->_viewport));
batch.setModelTransform(gpu::Framebuffer::evalSubregionTexcoordTransform(sourceFramebufferSize, args->_viewport));
batch.setPipeline(_hazePipeline);
batch.setUniformBuffer(HazeEffect_ParamsSlot, haze->getHazeParametersBuffer());
auto hazeStage = args->_scene->getStage<HazeStage>();
if (hazeStage && hazeStage->_currentHazeFrame._hazes.size() > 0) {
model::HazePointer hazePointer = hazeStage->getHaze(hazeStage->_currentHazeFrame._hazes.front());
batch.setUniformBuffer(HazeEffect_ParamsSlot, hazePointer->getHazeParametersBuffer());
}
batch.setUniformBuffer(HazeEffect_TransformBufferSlot, transformBuffer->getFrameTransformBuffer());
batch.setResourceTexture(HazeEffect_LightingMapSlot, inputBuffer);

View file

@ -90,8 +90,8 @@ void FetchHazeStage::run(const render::RenderContextPointer& renderContext, mode
assert(hazeStage);
haze = nullptr;
if (hazeStage->_currentFrame._hazes.size() != 0) {
auto hazeId = hazeStage->_currentFrame._hazes.front();
if (hazeStage->_currentHazeFrame._hazes.size() != 0) {
auto hazeId = hazeStage->_currentHazeFrame._hazes.front();
haze = hazeStage->getHaze(hazeId);
}
}

View file

@ -55,9 +55,9 @@ public:
Hazes _hazes;
HazeMap _hazeMap;
class Frame {
class HazeFrame {
public:
Frame() {}
HazeFrame() {}
void clear() { _hazes.clear(); }
@ -66,7 +66,7 @@ public:
HazeStage::HazeIndices _hazes;
};
Frame _currentFrame;
HazeFrame _currentHazeFrame;
};
using HazeStagePointer = std::shared_ptr<HazeStage>;

View file

@ -54,7 +54,7 @@ void ZoneRendererTask::build(JobModel& task, const Varying& input, Varying& oupu
void SetupZones::run(const RenderContextPointer& context, const Inputs& inputs) {
auto backgroundStage = context->_scene->getStage<BackgroundStage>();
assert(backgroundStage);
backgroundStage->_currentFrame.clear();
backgroundStage->_currentBackgroundFrame.clear();
// call render in the correct order first...
render::renderItems(context, inputs);
@ -66,12 +66,12 @@ void SetupZones::run(const RenderContextPointer& context, const Inputs& inputs)
lightStage->_currentFrame.pushSunLight(0);
lightStage->_currentFrame.pushAmbientLight(0);
backgroundStage->_currentFrame.pushBackground(0);
backgroundStage->_currentBackgroundFrame.pushBackground(0);
// Haze
auto hazeStage = context->_scene->getStage<HazeStage>();
assert(hazeStage);
hazeStage->_currentFrame.clear();
hazeStage->_currentHazeFrame.clear();
}
const gpu::PipelinePointer& DebugZoneLighting::getKeyLightPipeline() {
@ -160,8 +160,8 @@ void DebugZoneLighting::run(const render::RenderContextPointer& context, const I
auto backgroundStage = context->_scene->getStage<BackgroundStage>(BackgroundStage::getName());
std::vector<model::SkyboxPointer> skyboxStack;
if (backgroundStage && backgroundStage->_currentFrame._backgrounds.size()) {
for (auto index : backgroundStage->_currentFrame._backgrounds) {
if (backgroundStage && backgroundStage->_currentBackgroundFrame._backgrounds.size()) {
for (auto index : backgroundStage->_currentBackgroundFrame._backgrounds) {
auto background = backgroundStage->getBackground(index);
if (background) {
skyboxStack.push_back(background->getSkybox());