Merge pull request #13190 from Atlante45/new-master

RC67.2 stable mergeback to master
This commit is contained in:
John Conklin II 2018-05-17 13:10:00 -07:00 committed by GitHub
commit fb7b1d3550
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 163 additions and 75 deletions

View file

@ -49,6 +49,7 @@
#include "AmbientOcclusionEffect.h"
#include "RenderShadowTask.h"
#include "AntialiasingEffect.h"
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
#include "SpeechRecognizer.h"
@ -380,6 +381,25 @@ Menu::Menu() {
// Developer > Render >>>
MenuWrapper* renderOptionsMenu = developerMenu->addMenu("Render");
action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::AntiAliasing, 0, true);
connect(action, &QAction::triggered, [action] {
auto renderConfig = qApp->getRenderEngine()->getConfiguration();
if (renderConfig) {
auto mainViewJitterCamConfig = renderConfig->getConfig<JitterSample>("RenderMainView.JitterCam");
auto mainViewAntialiasingConfig = renderConfig->getConfig<Antialiasing>("RenderMainView.Antialiasing");
if (mainViewJitterCamConfig && mainViewAntialiasingConfig) {
if (action->isChecked()) {
mainViewJitterCamConfig->play();
mainViewAntialiasingConfig->setDebugFXAA(false);
} else {
mainViewJitterCamConfig->none();
mainViewAntialiasingConfig->setDebugFXAA(true);
}
}
}
});
action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Shadows, 0, true);
connect(action, &QAction::triggered, [action] {
auto renderConfig = qApp->getRenderEngine()->getConfiguration();

View file

@ -215,6 +215,7 @@ namespace MenuOption {
const QString DesktopTabletToToolbar = "Desktop Tablet Becomes Toolbar";
const QString HMDTabletToToolbar = "HMD Tablet Becomes Toolbar";
const QString Shadows = "Shadows";
const QString AntiAliasing = "Temporal Antialiasing (FXAA if disabled)";
const QString AmbientOcclusion = "Ambient Occlusion";
}

View file

@ -486,16 +486,14 @@ JitterSample::SampleSequence::SampleSequence(){
}
void JitterSample::configure(const Config& config) {
_freeze = config.freeze;
if (config.stop || _freeze) {
_freeze = config.stop || config.freeze;
if (config.freeze) {
auto pausedIndex = config.getIndex();
if (_sampleSequence.currentIndex != pausedIndex) {
_sampleSequence.currentIndex = pausedIndex;
}
} else {
if (_sampleSequence.currentIndex < 0) {
_sampleSequence.currentIndex = config.getIndex();
}
} else if (config.stop) {
_sampleSequence.currentIndex = -1;
}
_scale = config.scale;
}
@ -509,7 +507,12 @@ void JitterSample::run(const render::RenderContextPointer& renderContext, Output
current = -1;
}
}
jitter = _sampleSequence.offsets[(current < 0 ? SEQUENCE_LENGTH : current)];
jitter.x = 0.0f;
jitter.y = 0.0f;
if (current >= 0) {
jitter = _sampleSequence.offsets[current];
}
}

View file

@ -62,7 +62,7 @@ public:
};
using Config = JitterSampleConfig;
using Output = glm::vec2;
using Output = glm::vec2;
using JobModel = render::Job::ModelO<JitterSample, Output, Config>;
void configure(const Config& config);
@ -95,7 +95,7 @@ class AntialiasingConfig : public render::Job::Config {
Q_PROPERTY(bool debug MEMBER debug NOTIFY dirty)
Q_PROPERTY(float debugX MEMBER debugX NOTIFY dirty)
Q_PROPERTY(float debugFXAAX MEMBER debugFXAAX NOTIFY dirty)
Q_PROPERTY(bool fxaaOnOff READ debugFXAA WRITE setDebugFXAA NOTIFY dirty)
Q_PROPERTY(float debugShowVelocityThreshold MEMBER debugShowVelocityThreshold NOTIFY dirty)
Q_PROPERTY(bool showCursorPixel MEMBER showCursorPixel NOTIFY dirty)
Q_PROPERTY(glm::vec2 debugCursorTexcoord MEMBER debugCursorTexcoord NOTIFY dirty)
@ -106,6 +106,10 @@ class AntialiasingConfig : public render::Job::Config {
public:
AntialiasingConfig() : render::Job::Config(true) {}
void setDebugFXAA(bool debug) { debugFXAAX = (debug ? 0.0f : 1.0f); emit dirty();}
bool debugFXAA() const { return (debugFXAAX == 0.0f ? true : false); }
float blend{ 0.25f };
float sharpen{ 0.05f };

View file

@ -27,6 +27,7 @@ float evalOpaqueFinalAlpha(float alpha, float mapAlpha) {
}
<@include DefaultMaterials.slh@>
<@include LightingModel.slh@>
void packDeferredFragment(vec3 normal, float alpha, vec3 albedo, float roughness, float metallic, vec3 emissive, float occlusion, float scattering) {
if (alpha != 1.0) {
@ -36,7 +37,7 @@ void packDeferredFragment(vec3 normal, float alpha, vec3 albedo, float roughness
_fragColor1 = vec4(packNormal(normal), clamp(roughness, 0.0, 1.0));
_fragColor2 = vec4(((scattering > 0.0) ? vec3(scattering) : emissive), occlusion);
_fragColor3 = vec4(emissive, 1.0);
_fragColor3 = vec4(isEmissiveEnabled() * emissive, 1.0);
}
void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 albedo, float roughness, float metallic, vec3 fresnel, vec3 lightmap) {
@ -46,9 +47,9 @@ void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 albedo, float r
_fragColor0 = vec4(albedo, packLightmappedMetallic(metallic));
_fragColor1 = vec4(packNormal(normal), clamp(roughness, 0.0, 1.0));
_fragColor2 = vec4(lightmap, 1.0);
_fragColor2 = vec4(isLightmapEnabled() * lightmap, 1.0);
_fragColor3 = vec4(lightmap * albedo, 1.0);
_fragColor3 = vec4(isLightmapEnabled() * lightmap * albedo, 1.0);
}
void packDeferredFragmentUnlit(vec3 normal, float alpha, vec3 color) {

View file

@ -140,7 +140,7 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
color += directionalSpecular;
// Attenuate the light if haze effect selected
if ((hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) {
if ((isHazeEnabled() > 0) && (hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) {
color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS);
}
@ -234,7 +234,7 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze(
color += (ambientSpecular + directionalSpecular) / opacity;
// Haze
if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
if ((isHazeEnabled() > 0) && (hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
vec4 colorV4 = computeHazeColor(
vec4(color, 1.0), // fragment original color
positionES, // fragment position in eye coordinates
@ -272,7 +272,7 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze(
color += (ambientSpecular + directionalSpecular) / opacity;
// Haze
if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
if ((isHazeEnabled() > 0) && (hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
vec4 colorV4 = computeHazeColor(
vec4(color, 1.0), // fragment original color
positionES, // fragment position in eye coordinates

View file

@ -61,20 +61,22 @@ enum DeferredShader_MapSlot {
DEFERRED_BUFFER_EMISSIVE_UNIT = 2,
DEFERRED_BUFFER_DEPTH_UNIT = 3,
DEFERRED_BUFFER_OBSCURANCE_UNIT = 4,
SHADOW_MAP_UNIT = 5,
SKYBOX_MAP_UNIT = SHADOW_MAP_UNIT + SHADOW_CASCADE_MAX_COUNT,
DEFERRED_BUFFER_LINEAR_DEPTH_UNIT,
DEFERRED_BUFFER_CURVATURE_UNIT,
DEFERRED_BUFFER_DIFFUSED_CURVATURE_UNIT,
SCATTERING_LUT_UNIT,
SCATTERING_SPECULAR_UNIT,
DEFERRED_BUFFER_LINEAR_DEPTH_UNIT = 5,
DEFERRED_BUFFER_CURVATURE_UNIT = 6,
DEFERRED_BUFFER_DIFFUSED_CURVATURE_UNIT = 7,
SCATTERING_LUT_UNIT = 8,
SCATTERING_SPECULAR_UNIT = 9,
SKYBOX_MAP_UNIT = render::ShapePipeline::Slot::LIGHT_AMBIENT_MAP, // unit = 10
SHADOW_MAP_UNIT = 11,
nextAvailableUnit = SHADOW_MAP_UNIT + SHADOW_CASCADE_MAX_COUNT
};
enum DeferredShader_BufferSlot {
DEFERRED_FRAME_TRANSFORM_BUFFER_SLOT = 0,
CAMERA_CORRECTION_BUFFER_SLOT,
SCATTERING_PARAMETERS_BUFFER_SLOT,
LIGHTING_MODEL_BUFFER_SLOT = render::ShapePipeline::Slot::LIGHTING_MODEL,
LIGHT_GPU_SLOT = render::ShapePipeline::Slot::LIGHT,
KEY_LIGHT_SLOT = render::ShapePipeline::Slot::KEY_LIGHT,
LIGHT_ARRAY_SLOT = render::ShapePipeline::Slot::LIGHT_ARRAY_BUFFER,
LIGHT_AMBIENT_SLOT = render::ShapePipeline::Slot::LIGHT_AMBIENT_BUFFER,
HAZE_MODEL_BUFFER_SLOT = render::ShapePipeline::Slot::HAZE_MODEL,
LIGHT_INDEX_GPU_SLOT,
@ -149,17 +151,20 @@ void DeferredLightingEffect::unsetKeyLightBatch(gpu::Batch& batch, int lightBuff
}
void DeferredLightingEffect::setupLocalLightsBatch(gpu::Batch& batch,
int clusterGridBufferUnit, int clusterContentBufferUnit, int frustumGridBufferUnit,
int lightArrayBufferUnit, int clusterGridBufferUnit, int clusterContentBufferUnit, int frustumGridBufferUnit,
const LightClustersPointer& lightClusters) {
// Bind the global list of lights and the visible lights this frame
batch.setUniformBuffer(_localLightLocations->lightBufferUnit, lightClusters->_lightStage->getLightArrayBuffer());
batch.setUniformBuffer(lightArrayBufferUnit, lightClusters->_lightStage->getLightArrayBuffer());
batch.setUniformBuffer(frustumGridBufferUnit, lightClusters->_frustumGridBuffer);
batch.setUniformBuffer(clusterGridBufferUnit, lightClusters->_clusterGridBuffer);
batch.setUniformBuffer(clusterContentBufferUnit, lightClusters->_clusterContentBuffer);
}
void DeferredLightingEffect::unsetLocalLightsBatch(gpu::Batch& batch, int clusterGridBufferUnit, int clusterContentBufferUnit, int frustumGridBufferUnit) {
void DeferredLightingEffect::unsetLocalLightsBatch(gpu::Batch& batch, int lightArrayBufferUnit, int clusterGridBufferUnit, int clusterContentBufferUnit, int frustumGridBufferUnit) {
if (lightArrayBufferUnit >= 0) {
batch.setUniformBuffer(lightArrayBufferUnit, nullptr);
}
if (clusterGridBufferUnit >= 0) {
batch.setUniformBuffer(clusterGridBufferUnit, nullptr);
}
@ -194,7 +199,8 @@ static gpu::ShaderPointer makeLightProgram(const gpu::ShaderPointer& vertShader,
slotBindings.insert(gpu::Shader::Binding(std::string("lightingModelBuffer"), LIGHTING_MODEL_BUFFER_SLOT));
slotBindings.insert(gpu::Shader::Binding(std::string("hazeBuffer"), HAZE_MODEL_BUFFER_SLOT));
slotBindings.insert(gpu::Shader::Binding(std::string("subsurfaceScatteringParametersBuffer"), SCATTERING_PARAMETERS_BUFFER_SLOT));
slotBindings.insert(gpu::Shader::Binding(std::string("lightBuffer"), LIGHT_GPU_SLOT));
slotBindings.insert(gpu::Shader::Binding(std::string("keyLightBuffer"), KEY_LIGHT_SLOT));
slotBindings.insert(gpu::Shader::Binding(std::string("lightBuffer"), LIGHT_ARRAY_SLOT));
slotBindings.insert(gpu::Shader::Binding(std::string("lightAmbientBuffer"), LIGHT_AMBIENT_SLOT));
slotBindings.insert(gpu::Shader::Binding(std::string("lightIndexBuffer"), LIGHT_INDEX_GPU_SLOT));
@ -592,7 +598,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext,
batch._glUniform4fv(locations->texcoordFrameTransform, 1, reinterpret_cast< const float* >(&textureFrameTransform));
// Setup the global lighting
deferredLightingEffect->setupKeyLightBatch(args, batch, locations->keyLightBufferUnit, locations->ambientBufferUnit, SKYBOX_MAP_UNIT);
deferredLightingEffect->setupKeyLightBatch(args, batch, KEY_LIGHT_SLOT, LIGHT_AMBIENT_SLOT, SKYBOX_MAP_UNIT);
// Haze
if (haze) {
@ -601,7 +607,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext,
batch.draw(gpu::TRIANGLE_STRIP, 4);
deferredLightingEffect->unsetKeyLightBatch(batch, locations->keyLightBufferUnit, locations->ambientBufferUnit, SKYBOX_MAP_UNIT);
deferredLightingEffect->unsetKeyLightBatch(batch, KEY_LIGHT_SLOT, LIGHT_AMBIENT_SLOT, SKYBOX_MAP_UNIT);
for (auto i = 0; i < SHADOW_CASCADE_MAX_COUNT; i++) {
batch.setResourceTexture(SHADOW_MAP_UNIT+i, nullptr);
@ -656,8 +662,9 @@ void RenderDeferredLocals::run(const render::RenderContextPointer& renderContext
auto& lightIndices = lightClusters->_visibleLightIndices;
if (!lightIndices.empty() && lightIndices[0] > 0) {
deferredLightingEffect->setupLocalLightsBatch(batch, LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT, LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT, LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT,
lightClusters);
deferredLightingEffect->setupLocalLightsBatch(batch,
LIGHT_ARRAY_SLOT, LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT, LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT, LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT,
lightClusters);
// Local light pipeline
batch.setPipeline(deferredLightingEffect->_localLight);

View file

@ -51,8 +51,8 @@ public:
void setupKeyLightBatch(const RenderArgs* args, gpu::Batch& batch, int lightBufferUnit, int ambientBufferUnit, int skyboxCubemapUnit);
void unsetKeyLightBatch(gpu::Batch& batch, int lightBufferUnit, int ambientBufferUnit, int skyboxCubemapUnit);
void setupLocalLightsBatch(gpu::Batch& batch, int clusterGridBufferUnit, int clusterContentBufferUnit, int frustumGridBufferUnit, const LightClustersPointer& lightClusters);
void unsetLocalLightsBatch(gpu::Batch& batch, int clusterGridBufferUnit, int clusterContentBufferUnit, int frustumGridBufferUnit);
void setupLocalLightsBatch(gpu::Batch& batch, int lightArrayBufferUnit, int clusterGridBufferUnit, int clusterContentBufferUnit, int frustumGridBufferUnit, const LightClustersPointer& lightClusters);
void unsetLocalLightsBatch(gpu::Batch& batch, int lightArrayBufferUnit, int clusterGridBufferUnit, int clusterContentBufferUnit, int frustumGridBufferUnit);
void setShadowMapEnabled(bool enable) { _shadowMapEnabled = enable; };
void setAmbientOcclusionEnabled(bool enable) { _ambientOcclusionEnabled = enable; }

View file

@ -2264,7 +2264,7 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transp
slotBindings.insert(gpu::Shader::Binding(std::string("lightingModelBuffer"), render::ShapePipeline::Slot::LIGHTING_MODEL));
slotBindings.insert(gpu::Shader::Binding(std::string("keyLightBuffer"), render::ShapePipeline::Slot::KEY_LIGHT));
slotBindings.insert(gpu::Shader::Binding(std::string("lightAmbientBuffer"), render::ShapePipeline::Slot::LIGHT_AMBIENT_BUFFER));
slotBindings.insert(gpu::Shader::Binding(std::string("skyboxMap"), render::ShapePipeline::Slot::MAP::LIGHT_AMBIENT));
slotBindings.insert(gpu::Shader::Binding(std::string("skyboxMap"), render::ShapePipeline::Slot::MAP::LIGHT_AMBIENT_MAP));
gpu::Shader::makeProgram(*_simpleShader, slotBindings);
gpu::Shader::makeProgram(*_transparentShader, slotBindings);
gpu::Shader::makeProgram(*_unlitShader, slotBindings);
@ -2284,7 +2284,7 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transp
slotBindings.insert(gpu::Shader::Binding(std::string("lightingModelBuffer"), render::ShapePipeline::Slot::LIGHTING_MODEL));
slotBindings.insert(gpu::Shader::Binding(std::string("keyLightBuffer"), render::ShapePipeline::Slot::KEY_LIGHT));
slotBindings.insert(gpu::Shader::Binding(std::string("lightAmbientBuffer"), render::ShapePipeline::Slot::LIGHT_AMBIENT_BUFFER));
slotBindings.insert(gpu::Shader::Binding(std::string("skyboxMap"), render::ShapePipeline::Slot::MAP::LIGHT_AMBIENT));
slotBindings.insert(gpu::Shader::Binding(std::string("skyboxMap"), render::ShapePipeline::Slot::MAP::LIGHT_AMBIENT_MAP));
slotBindings.insert(gpu::Shader::Binding(std::string("fadeMaskMap"), render::ShapePipeline::Slot::MAP::FADE_MASK));
gpu::Shader::makeProgram(*_simpleFadeShader, slotBindings);
gpu::Shader::makeProgram(*_unlitFadeShader, slotBindings);

View file

@ -42,7 +42,7 @@ in vec2 varTexCoord0;
out vec4 outFragColor;
void main(void) {
if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) != HAZE_MODE_IS_ACTIVE) {
if ((isHazeEnabled() == 0) || (hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) != HAZE_MODE_IS_ACTIVE) {
discard;
}

View file

@ -169,6 +169,7 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c
glm::mat4 projMat;
Transform viewMat;
const auto jitter = inputs.get2();
args->getViewFrustum().evalProjectionMatrix(projMat);
args->getViewFrustum().evalViewTransform(viewMat);
@ -183,6 +184,7 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c
// Setup camera, projection and viewport for all items
batch.setViewportTransform(args->_viewport);
batch.setProjectionTransform(projMat);
batch.setProjectionJitter(jitter.x, jitter.y);
batch.setViewTransform(viewMat);
std::vector<ShapeKey> skinnedShapeKeys{};
@ -356,6 +358,7 @@ void DebugHighlight::run(const render::RenderContextPointer& renderContext, cons
assert(renderContext->args);
assert(renderContext->args->hasViewFrustum());
RenderArgs* args = renderContext->args;
const auto jitter = input.get2();
gpu::doInBatch("DebugHighlight::run", args->_context, [&](gpu::Batch& batch) {
batch.setViewportTransform(args->_viewport);
@ -368,6 +371,7 @@ void DebugHighlight::run(const render::RenderContextPointer& renderContext, cons
args->getViewFrustum().evalProjectionMatrix(projMat);
args->getViewFrustum().evalViewTransform(viewMat);
batch.setProjectionTransform(projMat);
batch.setProjectionJitter(jitter.x, jitter.y);
batch.setViewTransform(viewMat, true);
batch.setModelTransform(Transform());
@ -480,6 +484,7 @@ void DrawHighlightTask::build(JobModel& task, const render::Varying& inputs, ren
const auto sceneFrameBuffer = inputs.getN<Inputs>(1);
const auto primaryFramebuffer = inputs.getN<Inputs>(2);
const auto deferredFrameTransform = inputs.getN<Inputs>(3);
const auto jitter = inputs.getN<Inputs>(4);
// Prepare the ShapePipeline
auto shapePlumber = std::make_shared<ShapePlumber>();
@ -515,7 +520,7 @@ void DrawHighlightTask::build(JobModel& task, const render::Varying& inputs, ren
stream << "HighlightMask" << i;
name = stream.str();
}
const auto drawMaskInputs = DrawHighlightMask::Inputs(sortedBounds, highlightRessources).asVarying();
const auto drawMaskInputs = DrawHighlightMask::Inputs(sortedBounds, highlightRessources, jitter).asVarying();
const auto highlightedRect = task.addJob<DrawHighlightMask>(name, drawMaskInputs, i, shapePlumber, sharedParameters);
if (i == 0) {
highlight0Rect = highlightedRect;
@ -532,7 +537,7 @@ void DrawHighlightTask::build(JobModel& task, const render::Varying& inputs, ren
}
// Debug highlight
const auto debugInputs = DebugHighlight::Inputs(highlightRessources, const_cast<const render::Varying&>(highlight0Rect)).asVarying();
const auto debugInputs = DebugHighlight::Inputs(highlightRessources, const_cast<const render::Varying&>(highlight0Rect), jitter).asVarying();
task.addJob<DebugHighlight>("HighlightDebug", debugInputs);
}

View file

@ -113,7 +113,7 @@ private:
class DrawHighlightMask {
public:
using Inputs = render::VaryingSet2<render::ShapeBounds, HighlightRessourcesPointer>;
using Inputs = render::VaryingSet3<render::ShapeBounds, HighlightRessourcesPointer, glm::vec2>;
using Outputs = glm::ivec4;
using JobModel = render::Job::ModelIO<DrawHighlightMask, Inputs, Outputs>;
@ -182,7 +182,7 @@ signals:
class DebugHighlight {
public:
using Inputs = render::VaryingSet2<HighlightRessourcesPointer, glm::ivec4>;
using Inputs = render::VaryingSet3<HighlightRessourcesPointer, glm::ivec4, glm::vec2>;
using Config = DebugHighlightConfig;
using JobModel = render::Job::ModelI<DebugHighlight, Inputs, Config>;
@ -205,7 +205,7 @@ private:
class DrawHighlightTask {
public:
using Inputs = render::VaryingSet4<RenderFetchCullSortTask::BucketList, DeferredFramebufferPointer, gpu::FramebufferPointer, DeferredFrameTransformPointer>;
using Inputs = render::VaryingSet5<RenderFetchCullSortTask::BucketList, DeferredFramebufferPointer, gpu::FramebufferPointer, DeferredFrameTransformPointer, glm::vec2>;
using Config = render::Task::Config;
using JobModel = render::Task::ModelI<DrawHighlightTask, Inputs, Config>;

View file

@ -39,7 +39,7 @@ enum LightClusterGridShader_MapSlot {
enum LightClusterGridShader_BufferSlot {
DEFERRED_FRAME_TRANSFORM_BUFFER_SLOT = 0,
CAMERA_CORRECTION_BUFFER_SLOT = 1,
LIGHT_GPU_SLOT = render::ShapePipeline::Slot::LIGHT,
LIGHT_GPU_SLOT = render::ShapePipeline::Slot::LIGHT_ARRAY_BUFFER,
LIGHT_INDEX_GPU_SLOT = 7,
LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT = 8,
LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT = 9,

View file

@ -49,6 +49,14 @@ void LightingModel::setBackground(bool enable) {
bool LightingModel::isBackgroundEnabled() const {
return (bool)_parametersBuffer.get<Parameters>().enableBackground;
}
void LightingModel::setHaze(bool enable) {
if (enable != isHazeEnabled()) {
_parametersBuffer.edit<Parameters>().enableHaze = (float)enable;
}
}
bool LightingModel::isHazeEnabled() const {
return (bool)_parametersBuffer.get<Parameters>().enableHaze;
}
void LightingModel::setObscurance(bool enable) {
if (enable != isObscuranceEnabled()) {
_parametersBuffer.edit<Parameters>().enableObscurance = (float)enable;
@ -160,6 +168,7 @@ void MakeLightingModel::configure(const Config& config) {
_lightingModel->setEmissive(config.enableEmissive);
_lightingModel->setLightmap(config.enableLightmap);
_lightingModel->setBackground(config.enableBackground);
_lightingModel->setHaze(config.enableHaze);
_lightingModel->setObscurance(config.enableObscurance);

View file

@ -36,6 +36,9 @@ public:
void setBackground(bool enable);
bool isBackgroundEnabled() const;
void setHaze(bool enable);
bool isHazeEnabled() const;
void setObscurance(bool enable);
bool isObscuranceEnabled() const;
@ -86,7 +89,6 @@ protected:
float enableSpecular{ 1.0f };
float enableAlbedo{ 1.0f };
float enableAmbientLight{ 1.0f };
float enableDirectionalLight{ 1.0f };
float enablePointLight{ 1.0f };
@ -99,6 +101,11 @@ protected:
float enableMaterialTexturing { 1.0f };
float enableWireframe { 0.0f }; // false by default
float enableHaze{ 1.0f };
float spare1; // Needed for having the LightingModel class aligned on a 4 scalar boundary for gpu
float spare2;
float spare3;
Parameters() {}
};
UniformBufferView _parametersBuffer;
@ -116,6 +123,7 @@ class MakeLightingModelConfig : public render::Job::Config {
Q_PROPERTY(bool enableEmissive MEMBER enableEmissive NOTIFY dirty)
Q_PROPERTY(bool enableLightmap MEMBER enableLightmap NOTIFY dirty)
Q_PROPERTY(bool enableBackground MEMBER enableBackground NOTIFY dirty)
Q_PROPERTY(bool enableHaze MEMBER enableHaze NOTIFY dirty)
Q_PROPERTY(bool enableObscurance MEMBER enableObscurance NOTIFY dirty)
@ -158,6 +166,7 @@ public:
bool showLightContour { false }; // false by default
bool enableWireframe { false }; // false by default
bool enableHaze{ true };
signals:
void dirty();

View file

@ -18,6 +18,7 @@ struct LightingModel {
vec4 _ScatteringDiffuseSpecularAlbedo;
vec4 _AmbientDirectionalPointSpot;
vec4 _ShowContourObscuranceWireframe;
vec4 _Haze_spareyzw;
};
uniform lightingModelBuffer{
@ -74,6 +75,10 @@ float isWireframeEnabled() {
return lightingModel._ShowContourObscuranceWireframe.z;
}
float isHazeEnabled() {
return lightingModel._Haze_spareyzw.x;
}
<@endfunc@>
<$declareLightingModel()$>

View file

@ -178,7 +178,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
task.addJob<DrawHaze>("DrawHazeDeferred", drawHazeInputs);
// Render transparent objects forward in LightingBuffer
const auto transparentsInputs = DrawDeferred::Inputs(transparents, lightingModel, lightClusters).asVarying();
const auto transparentsInputs = DrawDeferred::Inputs(transparents, lightingModel, lightClusters, jitter).asVarying();
task.addJob<DrawDeferred>("DrawTransparentDeferred", transparentsInputs, shapePlumber);
// Light Cluster Grid Debuging job
@ -192,7 +192,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
const auto selectionBaseName = "contextOverlayHighlightList";
const auto selectedItems = addSelectItemJobs(task, selectionBaseName, metas, opaques, transparents);
const auto outlineInputs = DrawHighlightTask::Inputs(items.get0(), deferredFramebuffer, lightingFramebuffer, deferredFrameTransform).asVarying();
const auto outlineInputs = DrawHighlightTask::Inputs(items.get0(), deferredFramebuffer, lightingFramebuffer, deferredFrameTransform, jitter).asVarying();
task.addJob<DrawHighlightTask>("DrawHighlight", outlineInputs);
task.addJob<EndGPURangeTimer>("HighlightRangeTimer", outlineRangeTimer);
@ -277,7 +277,8 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
// Grab a texture map representing the different status icons and assign that to the drawStatsuJob
auto iconMapPath = PathUtils::resourcesPath() + "icons/statusIconAtlas.svg";
auto statusIconMap = DependencyManager::get<TextureCache>()->getImageTexture(iconMapPath, image::TextureUsage::STRICT_TEXTURE);
task.addJob<DrawStatus>("DrawStatus", opaques, DrawStatus(statusIconMap));
const auto drawStatusInputs = DrawStatus::Input(opaques, jitter).asVarying();
task.addJob<DrawStatus>("DrawStatus", drawStatusInputs, DrawStatus(statusIconMap));
}
task.addJob<DebugZoneLighting>("DrawZoneStack", deferredFrameTransform);
@ -315,6 +316,7 @@ void DrawDeferred::run(const RenderContextPointer& renderContext, const Inputs&
const auto& inItems = inputs.get0();
const auto& lightingModel = inputs.get1();
const auto& lightClusters = inputs.get2();
const auto jitter = inputs.get3();
auto deferredLightingEffect = DependencyManager::get<DeferredLightingEffect>();
RenderArgs* args = renderContext->args;
@ -332,16 +334,24 @@ void DrawDeferred::run(const RenderContextPointer& renderContext, const Inputs&
args->getViewFrustum().evalViewTransform(viewMat);
batch.setProjectionTransform(projMat);
batch.setProjectionJitter(jitter.x, jitter.y);
batch.setViewTransform(viewMat);
// Setup lighting model for all items;
batch.setUniformBuffer(render::ShapePipeline::Slot::LIGHTING_MODEL, lightingModel->getParametersBuffer());
deferredLightingEffect->setupLocalLightsBatch(batch,
render::ShapePipeline::Slot::LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT,
render::ShapePipeline::Slot::LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT,
render::ShapePipeline::Slot::LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT,
lightClusters);
// Set the light
deferredLightingEffect->setupKeyLightBatch(args, batch,
render::ShapePipeline::Slot::KEY_LIGHT,
render::ShapePipeline::Slot::LIGHT_AMBIENT_BUFFER,
render::ShapePipeline::Slot::LIGHT_AMBIENT_MAP);
deferredLightingEffect->setupLocalLightsBatch(batch,
render::ShapePipeline::Slot::LIGHT_ARRAY_BUFFER,
render::ShapePipeline::Slot::LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT,
render::ShapePipeline::Slot::LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT,
render::ShapePipeline::Slot::LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT,
lightClusters);
// Setup haze if current zone has haze
auto hazeStage = args->_scene->getStage<HazeStage>();
@ -367,9 +377,15 @@ void DrawDeferred::run(const RenderContextPointer& renderContext, const Inputs&
args->_globalShapeKey = 0;
deferredLightingEffect->unsetLocalLightsBatch(batch,
render::ShapePipeline::Slot::LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT,
render::ShapePipeline::Slot::LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT,
render::ShapePipeline::Slot::LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT);
render::ShapePipeline::Slot::LIGHT_ARRAY_BUFFER,
render::ShapePipeline::Slot::LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT,
render::ShapePipeline::Slot::LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT,
render::ShapePipeline::Slot::LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT);
deferredLightingEffect->unsetKeyLightBatch(batch,
render::ShapePipeline::Slot::KEY_LIGHT,
render::ShapePipeline::Slot::LIGHT_AMBIENT_BUFFER,
render::ShapePipeline::Slot::LIGHT_AMBIENT_MAP);
});
config->setNumDrawn((int)inItems.size());

View file

@ -41,7 +41,7 @@ protected:
class DrawDeferred {
public:
using Inputs = render::VaryingSet3 <render::ItemBounds, LightingModelPointer, LightClustersPointer>;
using Inputs = render::VaryingSet4<render::ItemBounds, LightingModelPointer, LightClustersPointer, glm::vec2>;
using Config = DrawDeferredConfig;
using JobModel = render::Job::ModelI<DrawDeferred, Inputs, Config>;

View file

@ -189,7 +189,7 @@ void PrepareForward::run(const RenderContextPointer& renderContext, const Inputs
batch.setUniformBuffer(render::ShapePipeline::Slot::LIGHT_AMBIENT_BUFFER, keyAmbiLight->getAmbientSchemaBuffer());
if (keyAmbiLight->getAmbientMap()) {
batch.setResourceTexture(render::ShapePipeline::Slot::LIGHT_AMBIENT, keyAmbiLight->getAmbientMap());
batch.setResourceTexture(render::ShapePipeline::Slot::LIGHT_AMBIENT_MAP, keyAmbiLight->getAmbientMap());
}
}
});

View file

@ -104,7 +104,7 @@ void DrawStatus::configure(const Config& config) {
_showNetwork = config.showNetwork;
}
void DrawStatus::run(const RenderContextPointer& renderContext, const ItemBounds& inItems) {
void DrawStatus::run(const RenderContextPointer& renderContext, const Input& input) {
assert(renderContext->args);
assert(renderContext->args->hasViewFrustum());
RenderArgs* args = renderContext->args;
@ -112,6 +112,9 @@ void DrawStatus::run(const RenderContextPointer& renderContext, const ItemBounds
const int NUM_STATUS_VEC4_PER_ITEM = 2;
const int VEC4_LENGTH = 4;
const auto& inItems = input.get0();
const auto jitter = input.get1();
// FIrst thing, we collect the bound and the status for all the items we want to render
int nbItems = 0;
{
@ -171,6 +174,7 @@ void DrawStatus::run(const RenderContextPointer& renderContext, const ItemBounds
batch.setViewportTransform(args->_viewport);
batch.setProjectionTransform(projMat);
batch.setProjectionJitter(jitter.x, jitter.y);
batch.setViewTransform(viewMat, true);
batch.setModelTransform(Transform());

View file

@ -39,13 +39,14 @@ namespace render {
class DrawStatus {
public:
using Config = DrawStatusConfig;
using JobModel = Job::ModelI<DrawStatus, ItemBounds, Config>;
using Input = VaryingSet2<ItemBounds, glm::vec2>;
using JobModel = Job::ModelI<DrawStatus, Input, Config>;
DrawStatus() {}
DrawStatus(const gpu::TexturePointer statusIconMap) { setStatusIconMap(statusIconMap); }
void configure(const Config& config);
void run(const RenderContextPointer& renderContext, const ItemBounds& inItems);
void run(const RenderContextPointer& renderContext, const Input& input);
const gpu::PipelinePointer getDrawItemBoundsPipeline();
const gpu::PipelinePointer getDrawItemStatusPipeline();

View file

@ -90,9 +90,9 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p
slotBindings.insert(gpu::Shader::Binding(std::string("occlusionMap"), Slot::MAP::OCCLUSION));
slotBindings.insert(gpu::Shader::Binding(std::string("scatteringMap"), Slot::MAP::SCATTERING));
slotBindings.insert(gpu::Shader::Binding(std::string("keyLightBuffer"), Slot::BUFFER::KEY_LIGHT));
slotBindings.insert(gpu::Shader::Binding(std::string("lightBuffer"), Slot::BUFFER::LIGHT));
slotBindings.insert(gpu::Shader::Binding(std::string("lightBuffer"), Slot::BUFFER::LIGHT_ARRAY_BUFFER));
slotBindings.insert(gpu::Shader::Binding(std::string("lightAmbientBuffer"), Slot::BUFFER::LIGHT_AMBIENT_BUFFER));
slotBindings.insert(gpu::Shader::Binding(std::string("skyboxMap"), Slot::MAP::LIGHT_AMBIENT));
slotBindings.insert(gpu::Shader::Binding(std::string("skyboxMap"), Slot::MAP::LIGHT_AMBIENT_MAP));
slotBindings.insert(gpu::Shader::Binding(std::string("fadeMaskMap"), Slot::MAP::FADE_MASK));
slotBindings.insert(gpu::Shader::Binding(std::string("fadeParametersBuffer"), Slot::BUFFER::FADE_PARAMETERS));
slotBindings.insert(gpu::Shader::Binding(std::string("hazeBuffer"), Slot::BUFFER::HAZE_MODEL));
@ -124,7 +124,7 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p
locations->lightAmbientMapUnit = program->getTextures().findLocation("skyboxMap");
locations->fadeMaskTextureUnit = program->getTextures().findLocation("fadeMaskMap");
locations->fadeParameterBufferUnit = program->getUniformBuffers().findLocation("fadeParametersBuffer");
locations->hazeParameterBufferUnit = program->getUniformBuffers().findLocation("hazeParametersBuffer");
locations->hazeParameterBufferUnit = program->getUniformBuffers().findLocation("hazeBuffer");
if (key.isTranslucent()) {
locations->lightClusterGridBufferUnit = program->getUniformBuffers().findLocation("clusterGridBuffer");
locations->lightClusterContentBufferUnit = program->getUniformBuffers().findLocation("clusterContentBuffer");

View file

@ -236,7 +236,7 @@ public:
TEXMAPARRAY,
LIGHTING_MODEL,
KEY_LIGHT,
LIGHT,
LIGHT_ARRAY_BUFFER,
LIGHT_AMBIENT_BUFFER,
HAZE_MODEL,
FADE_PARAMETERS,
@ -254,8 +254,9 @@ public:
ROUGHNESS,
OCCLUSION,
SCATTERING,
LIGHT_AMBIENT,
FADE_MASK,
LIGHT_AMBIENT_MAP = 10,
};
};

View file

@ -38,21 +38,22 @@ Rectangle {
id: fxaaOnOff
property bool debugFXAA: false
HifiControls.Button {
text: {
if (fxaaOnOff.debugFXAA) {
return "FXAA"
} else {
return "TAA"
}
function getTheText() {
if (Render.getConfig("RenderMainView.Antialiasing").fxaaOnOff) {
return "FXAA"
} else {
return "TAA"
}
}
text: getTheText()
onClicked: {
fxaaOnOff.debugFXAA = !fxaaOnOff.debugFXAA
if (fxaaOnOff.debugFXAA) {
var onOff = !Render.getConfig("RenderMainView.Antialiasing").fxaaOnOff;
if (onOff) {
Render.getConfig("RenderMainView.JitterCam").none();
Render.getConfig("RenderMainView.Antialiasing").debugFXAAX = 0;
Render.getConfig("RenderMainView.Antialiasing").fxaaOnOff = true;
} else {
Render.getConfig("RenderMainView.JitterCam").play();
Render.getConfig("RenderMainView.Antialiasing").debugFXAAX = 1.0;
Render.getConfig("RenderMainView.Antialiasing").fxaaOnOff = false;
}
}

View file

@ -45,7 +45,8 @@ Rectangle {
"Unlit:LightingModel:enableUnlit",
"Emissive:LightingModel:enableEmissive",
"Lightmap:LightingModel:enableLightmap",
"Background:LightingModel:enableBackground",
"Background:LightingModel:enableBackground",
"Haze:LightingModel:enableHaze",
"ssao:AmbientOcclusion:enabled",
"Textures:LightingModel:enableMaterialTexturing"
]