Merged with samcake's 'black' branch

This commit is contained in:
Olivier Prat 2017-12-07 08:59:38 +01:00
commit 1ce1aca79f
81 changed files with 4386 additions and 117 deletions

3
.gitignore vendored
View file

@ -74,3 +74,6 @@ TAGS
# ignore node files for the console
node_modules
npm-debug.log
# ignore qmlc files generated from qml as cache
*.qmlc

View file

@ -448,7 +448,7 @@ public:
// Don't actually crash in debug builds, in case this apparent deadlock is simply from
// the developer actively debugging code
#ifdef NDEBUG
deadlockDetectionCrash();
// deadlockDetectionCrash();
#endif
}
}

View file

@ -356,7 +356,7 @@ void OpenGLDisplayPlugin::customizeContext() {
auto presentThread = DependencyManager::get<PresentThread>();
Q_ASSERT(thread() == presentThread->thread());
getGLBackend()->setCameraCorrection(mat4());
getGLBackend()->setCameraCorrection(mat4(), true);
for (auto& cursorValue : _cursorsData) {
auto& cursorData = cursorValue.second;

View file

@ -30,7 +30,7 @@ void main(void) {
varTexcoord = inTexCoord0.st;
// pass along the diffuse color
varColor = colorToLinearRGBA(inColor);
varColor = color_sRGBAToLinear(inColor);
// standard transform

View file

@ -31,7 +31,7 @@ void main(void) {
varTexcoord = inTexCoord0.st;
// pass along the diffuse color
varColor = colorToLinearRGBA(inColor);
varColor = color_sRGBAToLinear(inColor);
// standard transform

View file

@ -779,9 +779,12 @@ void GLBackend::recycle() const {
}
void GLBackend::setCameraCorrection(const Mat4& correction) {
void GLBackend::setCameraCorrection(const Mat4& correction, bool reset) {
auto invCorrection = glm::inverse(correction);
_transform._correction.prevCorrection = (reset ? correction : _transform._correction.correction);
_transform._correction.prevCorrectionInverse = (reset ? invCorrection : _transform._correction.correctionInverse);
_transform._correction.correction = correction;
_transform._correction.correctionInverse = glm::inverse(correction);
_transform._correction.correctionInverse = invCorrection;
_pipeline._cameraCorrectionBuffer._buffer->setSubData(0, _transform._correction);
_pipeline._cameraCorrectionBuffer._buffer->flush();
}

View file

@ -68,7 +68,7 @@ public:
virtual ~GLBackend();
void setCameraCorrection(const Mat4& correction);
void setCameraCorrection(const Mat4& correction, bool reset = false);
void render(const Batch& batch) final override;
// This call synchronize the Full Backend cache with the current GLState
@ -302,9 +302,12 @@ protected:
// Allows for correction of the camera pose to account for changes
// between the time when a was recorded and the time(s) when it is
// executed
// Prev is the previous correction used at previous frame
struct CameraCorrection {
Mat4 correction;
Mat4 correctionInverse;
mat4 correction;
mat4 correctionInverse;
mat4 prevCorrection;
mat4 prevCorrectionInverse;
};
struct TransformStageState {

View file

@ -146,7 +146,49 @@ GLenum GLTexelFormat::evalGLTexelFormatInternal(const gpu::Element& dstFormat) {
case gpu::RGB:
case gpu::RGBA:
case gpu::XY:
result = GL_RG8;
switch (dstFormat.getType()) {
case gpu::UINT32:
result = GL_RG32UI;
break;
case gpu::INT32:
result = GL_RG32I;
break;
case gpu::FLOAT:
result = GL_RG32F;
break;
case gpu::UINT16:
result = GL_RG16UI;
break;
case gpu::INT16:
result = GL_RG16I;
break;
case gpu::NUINT16:
result = GL_RG16;
break;
case gpu::NINT16:
result = GL_RG16_SNORM;
break;
case gpu::HALF:
result = GL_RG16F;
break;
case gpu::UINT8:
result = GL_RG8UI;
break;
case gpu::INT8:
result = GL_RG8I;
break;
case gpu::NUINT8:
result = GL_RG8;
break;
case gpu::NINT8:
result = GL_RG8_SNORM;
break;
case gpu::NUINT32:
case gpu::NINT32:
case gpu::COMPRESSED:
case gpu::NUM_TYPES: // quiet compiler
Q_UNREACHABLE();
}
break;
default:
qCWarning(gpugllogging) << "Unknown combination of texel format";
@ -578,7 +620,50 @@ GLTexelFormat GLTexelFormat::evalGLTexelFormat(const Element& dstFormat, const E
case gpu::RGB:
case gpu::RGBA:
case gpu::XY:
texel.internalFormat = GL_RG8;
switch (dstFormat.getType()) {
case gpu::UINT32:
texel.internalFormat = GL_RG32UI;
break;
case gpu::INT32:
texel.internalFormat = GL_RG32I;
break;
case gpu::FLOAT:
texel.internalFormat = GL_RG32F;
break;
case gpu::UINT16:
texel.internalFormat = GL_RG16UI;
break;
case gpu::INT16:
texel.internalFormat = GL_RG16I;
break;
case gpu::NUINT16:
texel.internalFormat = GL_RG16;
break;
case gpu::NINT16:
texel.internalFormat = GL_RG16_SNORM;
break;
case gpu::HALF:
texel.type = GL_FLOAT;
texel.internalFormat = GL_RG16F;
break;
case gpu::UINT8:
texel.internalFormat = GL_RG8UI;
break;
case gpu::INT8:
texel.internalFormat = GL_RG8I;
break;
case gpu::NUINT8:
texel.internalFormat = GL_RG8;
break;
case gpu::NINT8:
texel.internalFormat = GL_RG8_SNORM;
break;
case gpu::NUINT32:
case gpu::NINT32:
case gpu::COMPRESSED:
case gpu::NUM_TYPES: // quiet compiler
Q_UNREACHABLE();
}
break;
default:
qCWarning(gpugllogging) << "Unknown combination of texel format";

View file

@ -11,18 +11,45 @@
<@if not GPU_COLOR_SLH@>
<@def GPU_COLOR_SLH@>
float sRGBFloatToLinear(float value) {
// Linear ====> linear RGB
// sRGB ======> standard RGB with gamma of 2.2
// YCoCg =====> Luma (Y) chrominance green (Cg) and chrominance orange (Co)
// https://software.intel.com/en-us/node/503873
float color_scalar_sRGBToLinear(float value) {
const float SRGB_ELBOW = 0.04045;
return (value <= SRGB_ELBOW) ? value / 12.92 : pow((value + 0.055) / 1.055, 2.4);
}
vec3 colorToLinearRGB(vec3 srgb) {
return vec3(sRGBFloatToLinear(srgb.r), sRGBFloatToLinear(srgb.g), sRGBFloatToLinear(srgb.b));
vec3 color_sRGBToLinear(vec3 srgb) {
return vec3(color_scalar_sRGBToLinear(srgb.r), color_scalar_sRGBToLinear(srgb.g), color_scalar_sRGBToLinear(srgb.b));
}
vec4 colorToLinearRGBA(vec4 srgba) {
return vec4(colorToLinearRGB(srgba.xyz), srgba.w);
vec4 color_sRGBAToLinear(vec4 srgba) {
return vec4(color_sRGBToLinear(srgba.xyz), srgba.w);
}
vec3 color_LinearToYCoCg(vec3 rgb) {
// Y = R/4 + G/2 + B/4
// Co = R/2 - B/2
// Cg = -R/4 + G/2 - B/4
return vec3(
rgb.x/4.0 + rgb.y/2.0 + rgb.z/4.0,
rgb.x/2.0 - rgb.z/2.0,
-rgb.x/4.0 + rgb.y/2.0 - rgb.z/4.0
);
}
vec3 color_YCoCgToLinear(vec3 ycocg) {
// R = Y + Co - Cg
// G = Y + Cg
// B = Y - Co - Cg
return clamp(vec3(
ycocg.x + ycocg.y - ycocg.z,
ycocg.x + ycocg.z,
ycocg.x - ycocg.y - ycocg.z
), vec3(0.0), vec3(1.0));
}
<@func declareColorWheel()@>

View file

@ -15,6 +15,7 @@
#include <PathUtils.h>
#include <SharedUtil.h>
#include <gpu/Context.h>
#include <gpu/StandardShaderLib.h>
#include "AntialiasingEffect.h"
#include "StencilMaskPass.h"
@ -22,7 +23,8 @@
#include "DependencyManager.h"
#include "ViewFrustum.h"
#include "GeometryCache.h"
#include "FramebufferCache.h"
/*
#include "fxaa_vert.h"
#include "fxaa_frag.h"
#include "fxaa_blend_frag.h"
@ -165,3 +167,387 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const
DependencyManager::get<GeometryCache>()->renderQuad(batch, bottomLeft, topRight, texCoordTopLeft, texCoordBottomRight, color, _geometryId);
});
}
*/
#include "taa_frag.h"
#include "fxaa_blend_frag.h"
#include "taa_blend_frag.h"
const int AntialiasingPass_ParamsSlot = 0;
const int AntialiasingPass_FrameTransformSlot = 1;
const int AntialiasingPass_JitterBufferSlot = 2;
const int AntialiasingPass_HistoryMapSlot = 0;
const int AntialiasingPass_SourceMapSlot = 1;
const int AntialiasingPass_VelocityMapSlot = 2;
const int AntialiasingPass_DepthMapSlot = 3;
const int AntialiasingPass_NextMapSlot = 4;
Antialiasing::Antialiasing() {
}
Antialiasing::~Antialiasing() {
_antialiasingBuffer[0].reset();
_antialiasingBuffer[1].reset();
_antialiasingTexture[0].reset();
_antialiasingTexture[1].reset();
}
const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline() {
if (!_antialiasingPipeline) {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(taa_frag));
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
slotBindings.insert(gpu::Shader::Binding(std::string("taaParamsBuffer"), AntialiasingPass_ParamsSlot));
slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), AntialiasingPass_FrameTransformSlot));
slotBindings.insert(gpu::Shader::Binding(std::string("taaJitterBuffer"), AntialiasingPass_JitterBufferSlot));
slotBindings.insert(gpu::Shader::Binding(std::string("historyMap"), AntialiasingPass_HistoryMapSlot));
slotBindings.insert(gpu::Shader::Binding(std::string("sourceMap"), AntialiasingPass_SourceMapSlot));
slotBindings.insert(gpu::Shader::Binding(std::string("velocityMap"), AntialiasingPass_VelocityMapSlot));
slotBindings.insert(gpu::Shader::Binding(std::string("depthMap"), AntialiasingPass_DepthMapSlot));
gpu::Shader::makeProgram(*program, slotBindings);
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
PrepareStencil::testMask(*state);
// Good to go add the brand new pipeline
_antialiasingPipeline = gpu::Pipeline::create(program, state);
}
return _antialiasingPipeline;
}
const gpu::PipelinePointer& Antialiasing::getBlendPipeline() {
if (!_blendPipeline) {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(fxaa_blend_frag));
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
slotBindings.insert(gpu::Shader::Binding(std::string("colorTexture"), AntialiasingPass_NextMapSlot));
gpu::Shader::makeProgram(*program, slotBindings);
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
PrepareStencil::testMask(*state);
// Good to go add the brand new pipeline
_blendPipeline = gpu::Pipeline::create(program, state);
}
return _blendPipeline;
}
const gpu::PipelinePointer& Antialiasing::getDebugBlendPipeline() {
if (!_debugBlendPipeline) {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(taa_blend_frag));
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
slotBindings.insert(gpu::Shader::Binding(std::string("taaParamsBuffer"), AntialiasingPass_ParamsSlot));
slotBindings.insert(gpu::Shader::Binding(std::string("taaJitterBuffer"), AntialiasingPass_JitterBufferSlot));
slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), AntialiasingPass_FrameTransformSlot));
slotBindings.insert(gpu::Shader::Binding(std::string("nextMap"), AntialiasingPass_NextMapSlot));
slotBindings.insert(gpu::Shader::Binding(std::string("historyMap"), AntialiasingPass_HistoryMapSlot));
slotBindings.insert(gpu::Shader::Binding(std::string("sourceMap"), AntialiasingPass_SourceMapSlot));
slotBindings.insert(gpu::Shader::Binding(std::string("velocityMap"), AntialiasingPass_VelocityMapSlot));
slotBindings.insert(gpu::Shader::Binding(std::string("depthMap"), AntialiasingPass_DepthMapSlot));
gpu::Shader::makeProgram(*program, slotBindings);
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
PrepareStencil::testMask(*state);
// Good to go add the brand new pipeline
_debugBlendPipeline = gpu::Pipeline::create(program, state);
}
return _debugBlendPipeline;
}
void Antialiasing::configure(const Config& config) {
_params.edit().blend = config.blend;
_params.edit().covarianceGamma = config.covarianceGamma;
_params.edit().setUnjitter(config.unjitter);
_params.edit().setConstrainColor(config.constrainColor);
_params.edit().setCovarianceClipColor(config.covarianceClipColor);
_params.edit().setClipExactColor(config.clipExactColor);
_params.edit().setFeedbackColor(config.feedbackColor);
_params.edit().debugShowVelocityThreshold = config.debugShowVelocityThreshold;
_params.edit().regionInfo.x = config.debugX;
_params.edit().regionInfo.z = config.debugFXAAX;
_params.edit().setDebug(config.debug);
_params.edit().setShowDebugCursor(config.showCursorPixel);
_params.edit().setDebugCursor(config.debugCursorTexcoord);
_params.edit().setDebugOrbZoom(config.debugOrbZoom);
_params.edit().setShowJitterSequence(config.showJitterSequence);
_params.edit().setShowClosestFragment(config.showClosestFragment);
}
void Antialiasing::run(const render::RenderContextPointer& renderContext, const Inputs& inputs) {
assert(renderContext->args);
assert(renderContext->args->hasViewFrustum());
RenderArgs* args = renderContext->args;
auto& deferredFrameTransform = inputs.get0();
auto& jitterBuffer = inputs.get1();
auto& sourceBuffer = inputs.get2();
auto& linearDepthBuffer = inputs.get3();
auto& velocityBuffer = inputs.get4();
int width = sourceBuffer->getWidth();
int height = sourceBuffer->getHeight();
if (_antialiasingBuffer[0]) {
if (_antialiasingBuffer[0]->getSize() != uvec2(width, height)) {// || (sourceBuffer && (_antialiasingBuffer->getRenderBuffer(1) != sourceBuffer->getRenderBuffer(0)))) {
_antialiasingBuffer[0].reset();
_antialiasingBuffer[1].reset();
_antialiasingTexture[0].reset();
_antialiasingTexture[1].reset();
}
}
if (!_antialiasingBuffer[0]) {
// Link the antialiasing FBO to texture
for (int i = 0; i < 2; i++) {
_antialiasingBuffer[i] = gpu::FramebufferPointer(gpu::Framebuffer::create("antialiasing"));
auto format = gpu::Element::COLOR_SRGBA_32; // DependencyManager::get<FramebufferCache>()->getLightingTexture()->getTexelFormat();
auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR);
_antialiasingTexture[i] = gpu::Texture::createRenderBuffer(format, width, height, gpu::Texture::SINGLE_MIP, defaultSampler);
_antialiasingBuffer[i]->setRenderBuffer(0, _antialiasingTexture[i]);
}
}
int nextFrame = (_currentFrame++) % 2;
int prevFrame = (nextFrame + 1) % 2;
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
batch.enableStereo(false);
batch.setViewportTransform(args->_viewport);
// TAA step
getAntialiasingPipeline();
batch.setResourceTexture(AntialiasingPass_HistoryMapSlot, _antialiasingTexture[prevFrame]);
batch.setResourceTexture(AntialiasingPass_SourceMapSlot, sourceBuffer->getRenderBuffer(0));
batch.setResourceTexture(AntialiasingPass_VelocityMapSlot, velocityBuffer->getVelocityTexture());
batch.setResourceTexture(AntialiasingPass_DepthMapSlot, linearDepthBuffer->getLinearDepthTexture());
batch.setUniformBuffer(AntialiasingPass_ParamsSlot, _params);
batch.setUniformBuffer(AntialiasingPass_FrameTransformSlot, deferredFrameTransform->getFrameTransformBuffer());
batch.setUniformBuffer(AntialiasingPass_JitterBufferSlot, jitterBuffer);
batch.setFramebuffer(_antialiasingBuffer[nextFrame]);
batch.setPipeline(getAntialiasingPipeline());
batch.draw(gpu::TRIANGLE_STRIP, 4);
// Blend step
batch.setResourceTexture(AntialiasingPass_SourceMapSlot, nullptr);
batch.setFramebuffer(sourceBuffer);
if (_params->isDebug()) {
batch.setPipeline(getDebugBlendPipeline());
} else {
batch.setPipeline(getBlendPipeline());
}
batch.setResourceTexture(AntialiasingPass_NextMapSlot, _antialiasingTexture[nextFrame]);
batch.draw(gpu::TRIANGLE_STRIP, 4);
batch.setUniformBuffer(AntialiasingPass_ParamsSlot, nullptr);
batch.setUniformBuffer(AntialiasingPass_FrameTransformSlot, nullptr);
batch.setUniformBuffer(AntialiasingPass_JitterBufferSlot, nullptr);
batch.setResourceTexture(AntialiasingPass_DepthMapSlot, nullptr);
batch.setResourceTexture(AntialiasingPass_HistoryMapSlot, nullptr);
batch.setResourceTexture(AntialiasingPass_VelocityMapSlot, nullptr);
batch.setResourceTexture(AntialiasingPass_NextMapSlot, nullptr);
});
}
void JitterSampleConfig::setIndex(int current) {
_index = (current) % JitterSample::SampleSequence::SEQUENCE_LENGTH;
emit dirty();
}
int JitterSampleConfig::cycleStopPauseRun() {
_state = (_state + 1) % 3;
switch (_state) {
case 0: {
return none();
break;
}
case 1: {
return pause();
break;
}
case 2:
default: {
return play();
break;
}
}
return _state;
}
int JitterSampleConfig::prev() {
setIndex(_index - 1);
return _index;
}
int JitterSampleConfig::next() {
setIndex(_index + 1);
return _index;
}
int JitterSampleConfig::none() {
_state = 0;
stop = true;
freeze = false;
setIndex(-1);
return _state;
}
int JitterSampleConfig::pause() {
_state = 1;
stop = false;
freeze = true;
setIndex(0);
return _state;
}
int JitterSampleConfig::play() {
_state = 2;
stop = false;
freeze = false;
setIndex(0);
return _state;
}
template <int B> class Halton {
public:
float eval(int index) {
float f = 1.0f;
float r = 0.0f;
float invB = 1.0f / (float)B;
index++; // Indices start at 1, not 0
while (index > 0) {
f = f * invB;
r = r + f * (float) (index % B);
index = index / B;
}
return r;
}
};
JitterSample::SampleSequence::SampleSequence(){
// Halton sequence (2,3)
Halton<2> genX;
Halton<3> genY;
for (int i = 0; i < SEQUENCE_LENGTH; i++) {
offsets[i] = glm::vec2(genX.eval(i), genY.eval(i));
}
for (int i = 0; i < SEQUENCE_LENGTH; i++) {
offsets[i] -= vec2(0.5f);
}
offsets[SEQUENCE_LENGTH] = glm::vec2(0.0f);
}
void JitterSample::configure(const Config& config) {
_freeze = config.freeze;
if (config.stop || _freeze) {
auto pausedIndex = config.getIndex();
if (_jitterBuffer->currentIndex != pausedIndex) {
_jitterBuffer.edit().currentIndex = pausedIndex;
}
} else {
if (_jitterBuffer->currentIndex < 0) {
_jitterBuffer.edit().currentIndex = config.getIndex();
}
}
_scale = config.scale;
}
void JitterSample::run(const render::RenderContextPointer& renderContext, JitterBuffer& jitterBuffer) {
auto& current = _jitterBuffer.edit().currentIndex;
if (!_freeze) {
if (current >= 0) {
current = (current + 1) % SampleSequence::SEQUENCE_LENGTH;
}
else {
current = -1;
}
}
auto viewFrustum = renderContext->args->getViewFrustum();
auto projMat = viewFrustum.getProjection();
auto theNear = viewFrustum.getNearClip();
auto jit = jitterBuffer.get().offsets[(current < 0 ? SampleSequence::SEQUENCE_LENGTH : current)];
auto width = (float)renderContext->args->_viewport.z;
auto height = (float)renderContext->args->_viewport.w;
auto jx = 2.0 * jit.x / width;
auto jy = 2.0 * jit.y / height;
bool isStereo = renderContext->args->isStereo();
if (!isStereo) {
projMat[2][0] += jx;
projMat[2][1] += jy;
viewFrustum.setProjection(projMat);
renderContext->args->pushViewFrustum(viewFrustum);
}
else {
mat4 projMats[2];
renderContext->args->_context->getStereoProjections(projMats);
auto sjx = jx * 2.0f;
for (int i = 0; i < 2; i++) {
projMats[i][2][0] += sjx;
projMats[i][2][1] += jy;
}
renderContext->args->_context->setStereoProjections(projMats);
}
jitterBuffer = _jitterBuffer;
}

View file

@ -15,7 +15,204 @@
#include <DependencyManager.h>
#include "render/DrawTask.h"
#include "DeferredFrameTransform.h"
#include "VelocityBufferPass.h"
class JitterSampleConfig : public render::Job::Config {
Q_OBJECT
Q_PROPERTY(float scale MEMBER scale NOTIFY dirty)
Q_PROPERTY(bool freeze MEMBER freeze NOTIFY dirty)
Q_PROPERTY(bool stop MEMBER stop NOTIFY dirty)
Q_PROPERTY(int index READ getIndex NOTIFY dirty)
public:
JitterSampleConfig() : render::Job::Config(true) {}
float scale{ 0.5f };
bool stop{ false };
bool freeze{ false };
void setIndex(int current);
public slots:
int cycleStopPauseRun();
int prev();
int next();
int none();
int pause();
int play();
int getIndex() const { return _index; }
int getState() const { return _state; }
signals:
void dirty();
private:
int _state{ 0 };
int _index{ 0 };
};
class JitterSample {
public:
struct SampleSequence {
SampleSequence();
static const int SEQUENCE_LENGTH{ 16 };
glm::vec2 offsets[SEQUENCE_LENGTH + 1];
int sequenceLength{ SEQUENCE_LENGTH };
int currentIndex{ 0 };
};
using JitterBuffer = gpu::StructBuffer<SampleSequence>;
using Config = JitterSampleConfig;
using JobModel = render::Job::ModelO<JitterSample, JitterBuffer, Config>;
void configure(const Config& config);
void run(const render::RenderContextPointer& renderContext, JitterBuffer& jitterBuffer);
private:
JitterBuffer _jitterBuffer;
float _scale{ 1.0 };
bool _freeze{ false };
};
class AntialiasingConfig : public render::Job::Config {
Q_OBJECT
Q_PROPERTY(float blend MEMBER blend NOTIFY dirty)
Q_PROPERTY(float covarianceGamma MEMBER covarianceGamma NOTIFY dirty)
Q_PROPERTY(bool unjitter MEMBER unjitter NOTIFY dirty)
Q_PROPERTY(bool constrainColor MEMBER constrainColor NOTIFY dirty)
Q_PROPERTY(bool covarianceClipColor MEMBER covarianceClipColor NOTIFY dirty)
Q_PROPERTY(bool clipExactColor MEMBER clipExactColor NOTIFY dirty)
Q_PROPERTY(bool feedbackColor MEMBER feedbackColor NOTIFY dirty)
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(float debugShowVelocityThreshold MEMBER debugShowVelocityThreshold NOTIFY dirty)
Q_PROPERTY(bool showCursorPixel MEMBER showCursorPixel NOTIFY dirty)
Q_PROPERTY(glm::vec2 debugCursorTexcoord MEMBER debugCursorTexcoord NOTIFY dirty)
Q_PROPERTY(float debugOrbZoom MEMBER debugOrbZoom NOTIFY dirty)
Q_PROPERTY(bool showJitterSequence MEMBER showJitterSequence NOTIFY dirty)
Q_PROPERTY(bool showClosestFragment MEMBER showClosestFragment NOTIFY dirty)
public:
AntialiasingConfig() : render::Job::Config(true) {}
float blend{ 0.1f };
bool unjitter{ false };
bool constrainColor{ true };
bool covarianceClipColor{ true };
float covarianceGamma{ 1.0f };
bool clipExactColor{ false };
bool feedbackColor{ false };
float debugX{ 0.0f };
float debugFXAAX{ 1.0f };
float debugShowVelocityThreshold{ 1.0f };
glm::vec2 debugCursorTexcoord{ 0.5f, 0.5f };
float debugOrbZoom{ 2.0f };
bool debug { false };
bool showCursorPixel { false };
bool showJitterSequence{ false };
bool showClosestFragment{ false };
signals:
void dirty();
};
#define SET_BIT(bitfield, bitIndex, value) bitfield = ((bitfield) & ~(1 << (bitIndex))) | ((value) << (bitIndex))
#define GET_BIT(bitfield, bitIndex) ((bitfield) & (1 << (bitIndex)))
struct TAAParams {
float nope{ 0.0f };
float blend{ 0.1f };
float covarianceGamma{ 1.0f };
float debugShowVelocityThreshold{ 1.0f };
glm::ivec4 flags{ 0 };
glm::vec4 pixelInfo{ 0.5f, 0.5f, 2.0f, 0.0f };
glm::vec4 regionInfo{ 0.0f, 0.0f, 1.0f, 0.0f };
void setUnjitter(bool enabled) { SET_BIT(flags.y, 0, enabled); }
bool isUnjitter() const { return (bool)GET_BIT(flags.y, 0); }
void setConstrainColor(bool enabled) { SET_BIT(flags.y, 1, enabled); }
bool isConstrainColor() const { return (bool)GET_BIT(flags.y, 1); }
void setCovarianceClipColor(bool enabled) { SET_BIT(flags.y, 2, enabled); }
bool isCovarianceClipColor() const { return (bool)GET_BIT(flags.y, 2); }
void setClipExactColor(bool enabled) { SET_BIT(flags.y, 3, enabled); }
bool isClipExactColor() const { return (bool)GET_BIT(flags.y, 3); }
void setFeedbackColor(bool enabled) { SET_BIT(flags.y, 4, enabled); }
bool isFeedbackColor() const { return (bool)GET_BIT(flags.y, 4); }
void setDebug(bool enabled) { SET_BIT(flags.x, 0, enabled); }
bool isDebug() const { return (bool) GET_BIT(flags.x, 0); }
void setShowDebugCursor(bool enabled) { SET_BIT(flags.x, 1, enabled); }
bool showDebugCursor() const { return (bool)GET_BIT(flags.x, 1); }
void setDebugCursor(glm::vec2 debugCursor) { pixelInfo.x = debugCursor.x; pixelInfo.y = debugCursor.y; }
glm::vec2 getDebugCursor() const { return glm::vec2(pixelInfo.x, pixelInfo.y); }
void setDebugOrbZoom(float orbZoom) { pixelInfo.z = orbZoom; }
float getDebugOrbZoom() const { return pixelInfo.z; }
void setShowJitterSequence(bool enabled) { SET_BIT(flags.x, 2, enabled); }
void setShowClosestFragment(bool enabled) { SET_BIT(flags.x, 3, enabled); }
};
using TAAParamsBuffer = gpu::StructBuffer<TAAParams>;
class Antialiasing {
public:
using Inputs = render::VaryingSet5 < DeferredFrameTransformPointer, JitterSample::JitterBuffer, gpu::FramebufferPointer, LinearDepthFramebufferPointer, VelocityFramebufferPointer > ;
using Config = AntialiasingConfig;
using JobModel = render::Job::ModelI<Antialiasing, Inputs, Config>;
Antialiasing();
~Antialiasing();
void configure(const Config& config);
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs);
const gpu::PipelinePointer& getAntialiasingPipeline();
const gpu::PipelinePointer& getBlendPipeline();
const gpu::PipelinePointer& getDebugBlendPipeline();
private:
// Uniforms for AA
gpu::int32 _texcoordOffsetLoc;
gpu::FramebufferPointer _antialiasingBuffer[2];
gpu::TexturePointer _antialiasingTexture[2];
gpu::PipelinePointer _antialiasingPipeline;
gpu::PipelinePointer _blendPipeline;
gpu::PipelinePointer _debugBlendPipeline;
TAAParamsBuffer _params;
int _currentFrame{ 0 };
};
/*
class AntiAliasingConfig : public render::Job::Config {
Q_OBJECT
Q_PROPERTY(bool enabled MEMBER enabled)
@ -27,27 +224,28 @@ class Antialiasing {
public:
using Config = AntiAliasingConfig;
using JobModel = render::Job::ModelI<Antialiasing, gpu::FramebufferPointer, Config>;
Antialiasing();
~Antialiasing();
void configure(const Config& config) {}
void run(const render::RenderContextPointer& renderContext, const gpu::FramebufferPointer& sourceBuffer);
const gpu::PipelinePointer& getAntialiasingPipeline(RenderArgs* args);
const gpu::PipelinePointer& getAntialiasingPipeline();
const gpu::PipelinePointer& getBlendPipeline();
private:
// Uniforms for AA
gpu::int32 _texcoordOffsetLoc;
gpu::FramebufferPointer _antialiasingBuffer;
gpu::TexturePointer _antialiasingTexture;
gpu::PipelinePointer _antialiasingPipeline;
gpu::PipelinePointer _blendPipeline;
int _geometryId { 0 };
};
*/
#endif // hifi_AntialiasingEffect_h

View file

@ -53,7 +53,8 @@ enum Slot {
DiffusedCurvature,
Scattering,
AmbientOcclusion,
AmbientOcclusionBlurred
AmbientOcclusionBlurred,
Velocity,
};
@ -227,6 +228,12 @@ static const std::string DEFAULT_AMBIENT_OCCLUSION_BLURRED_SHADER{
" }"
};
static const std::string DEFAULT_VELOCITY_SHADER{
"vec4 getFragmentColor() {"
" return vec4(vec2(texture(velocityMap, uv).xy), 0.0, 1.0);"
" }"
};
static const std::string DEFAULT_CUSTOM_SHADER {
"vec4 getFragmentColor() {"
" return vec4(1.0, 0.0, 0.0, 1.0);"
@ -309,6 +316,8 @@ std::string DebugDeferredBuffer::getShaderSourceCode(Mode mode, std::string cust
return DEFAULT_AMBIENT_OCCLUSION_SHADER;
case AmbientOcclusionBlurredMode:
return DEFAULT_AMBIENT_OCCLUSION_BLURRED_SHADER;
case VelocityMode:
return DEFAULT_VELOCITY_SHADER;
case CustomMode:
return getFileContent(customFile, DEFAULT_CUSTOM_SHADER);
default:
@ -367,6 +376,7 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str
slotBindings.insert(gpu::Shader::Binding("diffusedCurvatureMap", DiffusedCurvature));
slotBindings.insert(gpu::Shader::Binding("scatteringMap", Scattering));
slotBindings.insert(gpu::Shader::Binding("occlusionBlurredMap", AmbientOcclusionBlurred));
slotBindings.insert(gpu::Shader::Binding("velocityMap", Velocity));
gpu::Shader::makeProgram(*program, slotBindings);
auto pipeline = gpu::Pipeline::create(program, std::make_shared<gpu::State>());
@ -404,6 +414,7 @@ void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const I
auto& linearDepthTarget = inputs.get1();
auto& surfaceGeometryFramebuffer = inputs.get2();
auto& ambientOcclusionFramebuffer = inputs.get3();
auto& velocityFramebuffer = inputs.get4();
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
batch.enableStereo(false);
@ -432,6 +443,9 @@ void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const I
batch.setResourceTexture(Depth, deferredFramebuffer->getPrimaryDepthTexture());
batch.setResourceTexture(Lighting, deferredFramebuffer->getLightingTexture());
}
if (velocityFramebuffer) {
batch.setResourceTexture(Velocity, velocityFramebuffer->getVelocityTexture());
}
auto lightStage = renderContext->_scene->getStage<LightStage>();
assert(lightStage);
@ -477,5 +491,7 @@ void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const I
batch.setResourceTexture(AmbientOcclusion, nullptr);
batch.setResourceTexture(AmbientOcclusionBlurred, nullptr);
batch.setResourceTexture(Velocity, nullptr);
});
}

View file

@ -18,6 +18,7 @@
#include "DeferredFramebuffer.h"
#include "SurfaceGeometryPass.h"
#include "AmbientOcclusionEffect.h"
#include "VelocityBufferPass.h"
class DebugDeferredBufferConfig : public render::Job::Config {
Q_OBJECT
@ -37,7 +38,7 @@ signals:
class DebugDeferredBuffer {
public:
using Inputs = render::VaryingSet4<DeferredFramebufferPointer, LinearDepthFramebufferPointer, SurfaceGeometryFramebufferPointer, AmbientOcclusionFramebufferPointer>;
using Inputs = render::VaryingSet5<DeferredFramebufferPointer, LinearDepthFramebufferPointer, SurfaceGeometryFramebufferPointer, AmbientOcclusionFramebufferPointer, VelocityFramebufferPointer>;
using Config = DebugDeferredBufferConfig;
using JobModel = render::Job::ModelI<DebugDeferredBuffer, Inputs, Config>;
@ -76,6 +77,7 @@ protected:
ScatteringDebugMode,
AmbientOcclusionMode,
AmbientOcclusionBlurredMode,
VelocityMode,
CustomMode, // Needs to stay last
NumModes,

View file

@ -31,6 +31,10 @@ void DeferredFrameTransform::update(RenderArgs* args) {
//_parametersBuffer.edit<Parameters>()._ditheringInfo.y += 0.25f;
// Move the current view transform to prev
frameTransformBuffer.prevInvView = frameTransformBuffer.invView;
frameTransformBuffer.prevView = frameTransformBuffer.view;
Transform cameraTransform;
args->getViewFrustum().evalViewTransform(cameraTransform);
cameraTransform.getMatrix(frameTransformBuffer.invView);

View file

@ -52,6 +52,11 @@ protected:
// View matrix from world space to eye space (mono)
glm::mat4 view;
// Previous Frame Inv View matrix from eye space (mono) to world space
glm::mat4 prevInvView;
// Previous Frame View matrix from world space to eye space (mono)
glm::mat4 prevView;
FrameTransform() {}
};
UniformBufferView _frameTransformBuffer;

View file

@ -16,6 +16,9 @@
struct CameraCorrection {
mat4 _correction;
mat4 _correctionInverse;
mat4 _prevCorrection;
mat4 _prevCorrectionInverse;
};
uniform cameraCorrectionBuffer {
@ -31,6 +34,8 @@ struct DeferredFrameTransform {
mat4 _projectionMono;
mat4 _viewInverse;
mat4 _view;
mat4 _prevViewInverse;
mat4 _prevView;
};
uniform deferredFrameTransformBuffer {

View file

@ -31,6 +31,7 @@
#include "DeferredFramebuffer.h"
#include "DeferredLightingEffect.h"
#include "SurfaceGeometryPass.h"
#include "VelocityBufferPass.h"
#include "FramebufferCache.h"
#include "TextureCache.h"
#include "ZoneRenderer.h"
@ -91,9 +92,12 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
fadeEffect->build(task, opaques);
const auto jitterBuffer = task.addJob<JitterSample>("JitterCam");
// Prepare deferred, generate the shared Deferred Frame Transform
const auto deferredFrameTransform = task.addJob<GenerateDeferredFrameTransform>("DeferredFrameTransform");
const auto lightingModel = task.addJob<MakeLightingModel>("LightingModel");
// GPU jobs: Start preparing the primary, deferred and lighting buffer
const auto primaryFramebuffer = task.addJob<PreparePrimaryFramebuffer>("PreparePrimaryBuffer");
@ -139,7 +143,11 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
const auto ambientOcclusionFramebuffer = ambientOcclusionOutputs.getN<AmbientOcclusionEffect::Outputs>(0);
const auto ambientOcclusionUniforms = ambientOcclusionOutputs.getN<AmbientOcclusionEffect::Outputs>(1);
// Velocity
const auto velocityBufferInputs = VelocityBufferPass::Inputs(deferredFrameTransform, deferredFramebuffer).asVarying();
const auto velocityBufferOutputs = task.addJob<VelocityBufferPass>("VelocityBuffer", velocityBufferInputs);
const auto velocityBuffer = velocityBufferOutputs.getN<VelocityBufferPass::Outputs>(0);
// 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);
@ -160,6 +168,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
task.addJob<RenderDeferred>("RenderDeferred", deferredLightingInputs);
// Similar to light stage, background stage has been filled by several potential render items and resolved for the frame in this job
task.addJob<DrawBackgroundStage>("DrawBackgroundDeferred", lightingModel);
@ -232,7 +241,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
// Debugging stages
{
// Debugging Deferred buffer job
const auto debugFramebuffers = render::Varying(DebugDeferredBuffer::Inputs(deferredFramebuffer, linearDepthTarget, surfaceGeometryFramebuffer, ambientOcclusionFramebuffer));
const auto debugFramebuffers = render::Varying(DebugDeferredBuffer::Inputs(deferredFramebuffer, linearDepthTarget, surfaceGeometryFramebuffer, ambientOcclusionFramebuffer, velocityBuffer));
task.addJob<DebugDeferredBuffer>("DebugDeferredBuffer", debugFramebuffers);
const auto debugSubsurfaceScatteringInputs = DebugSubsurfaceScattering::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel,
@ -260,7 +269,9 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
}
// AA job to be revisited
task.addJob<Antialiasing>("Antialiasing", primaryFramebuffer);
const auto antialiasingInputs = Antialiasing::Inputs(deferredFrameTransform, jitterBuffer, primaryFramebuffer, linearDepthTarget, velocityBuffer).asVarying();
task.addJob<Antialiasing>("Antialiasing", antialiasingInputs);
// Composite the HUD and HUD overlays
task.addJob<CompositeHUD>("HUD");

View file

@ -0,0 +1,174 @@
//
// VelocityBufferPass.cpp
// libraries/render-utils/src/
//
// Created by Sam Gateau 8/15/2017.
// Copyright 2017 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "VelocityBufferPass.h"
#include <limits>
#include <gpu/Context.h>
#include <gpu/StandardShaderLib.h>
#include "StencilMaskPass.h"
const int VelocityBufferPass_FrameTransformSlot = 0;
const int VelocityBufferPass_DepthMapSlot = 0;
const int VelocityBufferPass_NormalMapSlot = 1;
#include "velocityBuffer_cameraMotion_frag.h"
VelocityFramebuffer::VelocityFramebuffer() {
}
void VelocityFramebuffer::updatePrimaryDepth(const gpu::TexturePointer& depthBuffer) {
//If the depth buffer or size changed, we need to delete our FBOs
bool reset = false;
if ((_primaryDepthTexture != depthBuffer)) {
_primaryDepthTexture = depthBuffer;
reset = true;
}
if (_primaryDepthTexture) {
auto newFrameSize = glm::ivec2(_primaryDepthTexture->getDimensions());
if (_frameSize != newFrameSize) {
_frameSize = newFrameSize;
_halfFrameSize = newFrameSize >> 1;
reset = true;
}
}
if (reset) {
clear();
}
}
void VelocityFramebuffer::clear() {
_velocityFramebuffer.reset();
_velocityTexture.reset();
}
void VelocityFramebuffer::allocate() {
auto width = _frameSize.x;
auto height = _frameSize.y;
// For Velocity Buffer:
_velocityTexture = gpu::Texture::createRenderBuffer(gpu::Element(gpu::VEC2, gpu::HALF, gpu::RGB), width, height, gpu::Texture::SINGLE_MIP,
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR));
_velocityFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("velocity"));
_velocityFramebuffer->setRenderBuffer(0, _velocityTexture);
_velocityFramebuffer->setDepthStencilBuffer(_primaryDepthTexture, _primaryDepthTexture->getTexelFormat());
}
gpu::FramebufferPointer VelocityFramebuffer::getVelocityFramebuffer() {
if (!_velocityFramebuffer) {
allocate();
}
return _velocityFramebuffer;
}
gpu::TexturePointer VelocityFramebuffer::getVelocityTexture() {
if (!_velocityTexture) {
allocate();
}
return _velocityTexture;
}
VelocityBufferPass::VelocityBufferPass() {
}
void VelocityBufferPass::configure(const Config& config) {
}
void VelocityBufferPass::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) {
assert(renderContext->args);
assert(renderContext->args->hasViewFrustum());
RenderArgs* args = renderContext->args;
const auto& frameTransform = inputs.get0();
const auto& deferredFramebuffer = inputs.get1();
if (!_gpuTimer) {
_gpuTimer = std::make_shared < gpu::RangeTimer>(__FUNCTION__);
}
if (!_velocityFramebuffer) {
_velocityFramebuffer = std::make_shared<VelocityFramebuffer>();
}
_velocityFramebuffer->updatePrimaryDepth(deferredFramebuffer->getPrimaryDepthTexture());
auto depthBuffer = deferredFramebuffer->getPrimaryDepthTexture();
auto velocityFBO = _velocityFramebuffer->getVelocityFramebuffer();
auto velocityTexture = _velocityFramebuffer->getVelocityTexture();
outputs.edit0() = _velocityFramebuffer;
outputs.edit1() = velocityFBO;
outputs.edit2() = velocityTexture;
auto cameraMotionPipeline = getCameraMotionPipeline();
auto fullViewport = args->_viewport;
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
_gpuTimer->begin(batch);
batch.enableStereo(false);
batch.setViewportTransform(fullViewport);
batch.setProjectionTransform(glm::mat4());
batch.resetViewTransform();
batch.setModelTransform(gpu::Framebuffer::evalSubregionTexcoordTransform(_velocityFramebuffer->getDepthFrameSize(), fullViewport));
batch.setUniformBuffer(VelocityBufferPass_FrameTransformSlot, frameTransform->getFrameTransformBuffer());
// Velocity buffer camera motion
batch.setFramebuffer(velocityFBO);
batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f));
batch.setPipeline(cameraMotionPipeline);
batch.setResourceTexture(VelocityBufferPass_DepthMapSlot, depthBuffer);
batch.draw(gpu::TRIANGLE_STRIP, 4);
_gpuTimer->end(batch);
});
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
config->setGPUBatchRunTime(_gpuTimer->getGPUAverage(), _gpuTimer->getBatchAverage());
}
const gpu::PipelinePointer& VelocityBufferPass::getCameraMotionPipeline() {
if (!_cameraMotionPipeline) {
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(velocityBuffer_cameraMotion_frag));
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), VelocityBufferPass_FrameTransformSlot));
slotBindings.insert(gpu::Shader::Binding(std::string("depthMap"), VelocityBufferPass_DepthMapSlot));
gpu::Shader::makeProgram(*program, slotBindings);
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
// Stencil test the curvature pass for objects pixels only, not the background
// PrepareStencil::testShape(*state);
state->setColorWriteMask(true, true, false, false);
// Good to go add the brand new pipeline
_cameraMotionPipeline = gpu::Pipeline::create(program, state);
}
return _cameraMotionPipeline;
}

View file

@ -0,0 +1,89 @@
//
// VelocityBufferPass.h
// libraries/render-utils/src/
//
// Created by Sam Gateau 8/15/2017.
// Copyright 2017 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_VelocityBufferPass_h
#define hifi_VelocityBufferPass_h
#include "SurfaceGeometryPass.h"
// VelocityFramebuffer is a helper class gathering in one place theframebuffers and targets describing the surface geometry linear depth
// from a z buffer
class VelocityFramebuffer {
public:
VelocityFramebuffer();
gpu::FramebufferPointer getVelocityFramebuffer();
gpu::TexturePointer getVelocityTexture();
// Update the depth buffer which will drive the allocation of all the other resources according to its size.
void updatePrimaryDepth(const gpu::TexturePointer& depthBuffer);
gpu::TexturePointer getPrimaryDepthTexture();
const glm::ivec2& getDepthFrameSize() const { return _frameSize; }
void setResolutionLevel(int level);
int getResolutionLevel() const { return _resolutionLevel; }
protected:
void clear();
void allocate();
gpu::TexturePointer _primaryDepthTexture;
gpu::FramebufferPointer _velocityFramebuffer;
gpu::TexturePointer _velocityTexture;
glm::ivec2 _frameSize;
glm::ivec2 _halfFrameSize;
int _resolutionLevel{ 0 };
};
using VelocityFramebufferPointer = std::shared_ptr<VelocityFramebuffer>;
class VelocityBufferPassConfig : public render::GPUJobConfig {
Q_OBJECT
Q_PROPERTY(float depthThreshold MEMBER depthThreshold NOTIFY dirty)
public:
VelocityBufferPassConfig() : render::GPUJobConfig(true) {}
float depthThreshold{ 5.0f };
signals:
void dirty();
};
class VelocityBufferPass {
public:
using Inputs = render::VaryingSet2<DeferredFrameTransformPointer, DeferredFramebufferPointer>;
using Outputs = render::VaryingSet3<VelocityFramebufferPointer, gpu::FramebufferPointer, gpu::TexturePointer>;
using Config = VelocityBufferPassConfig;
using JobModel = render::Job::ModelIO<VelocityBufferPass, Inputs, Outputs, Config>;
VelocityBufferPass();
void configure(const Config& config);
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs);
private:
typedef gpu::BufferView UniformBufferView;
VelocityFramebufferPointer _velocityFramebuffer;
const gpu::PipelinePointer& getCameraMotionPipeline();
gpu::PipelinePointer _cameraMotionPipeline;
gpu::RangeTimerPointer _gpuTimer;
};
#endif // hifi_VelocityBufferPass_h

View file

@ -17,7 +17,7 @@ out vec4 _color;
void main(void) {
// pass along the color
_color = colorToLinearRGBA(inColor.rgba);
_color = color_sRGBAToLinear(inColor.rgba);
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();

View file

@ -23,6 +23,7 @@ uniform sampler2D halfNormalMap;
uniform sampler2D occlusionMap;
uniform sampler2D occlusionBlurredMap;
uniform sampler2D scatteringMap;
uniform sampler2D velocityMap;
<$declareDeferredCurvature()$>

View file

@ -23,72 +23,112 @@ precision mediump int;
#endif
uniform sampler2D colorTexture;
//uniform sampler2D historyTexture;
uniform vec2 texcoordOffset;
in vec2 varTexcoord;
out vec4 outFragColor;
in vec2 varTexCoord0;
layout(location = 0) out vec4 outFragColor;
//layout(location = 0) out vec4 outFragHistory;
void main() {
// filter width limit for dependent "two-tap" texture samples
float FXAA_SPAN_MAX = 8.0;
outFragColor = vec4(texture(colorTexture, varTexCoord0).xyz, 1.0/8.0);
// local contrast multiplier for performing AA
// higher = sharper, but setting this value too high will cause near-vertical and near-horizontal edges to fail
// see "fxaaQualityEdgeThreshold"
float FXAA_REDUCE_MUL = 1.0 / 8.0;
// v2
/* float ModulationFactor = 1.0 / 8.0;
// luminance threshold for processing dark colors
// see "fxaaQualityEdgeThresholdMin"
float FXAA_REDUCE_MIN = 1.0 / 128.0;
vec3 History = textureLod(historyTexture, varTexCoord0, 0.0).rgb;
vec3 CurrentSubpixel = textureLod(colorTexture, varTexCoord0, 0.0).rgb;
/*
vec3 NearColor0 = textureLodOffset(colorTexture, varTexCoord0, 0.0, ivec2(1, 0)).xyz;
vec3 NearColor1 = textureLodOffset(colorTexture, varTexCoord0, 0.0, ivec2(0, 1)).xyz;
vec3 NearColor2 = textureLodOffset(colorTexture, varTexCoord0, 0.0, ivec2(-1, 0)).xyz;
vec3 NearColor3 = textureLodOffset(colorTexture, varTexCoord0, 0.0, ivec2(0, -1)).xyz;
// fetch raw RGB values for nearby locations
// sampling pattern is "five on a die" (each diagonal direction and the center)
// computing the coordinates for these texture reads could be moved to the vertex shader for speed if needed
vec3 rgbNW = texture(colorTexture, varTexcoord + (vec2(-1.0, -1.0) * texcoordOffset)).xyz;
vec3 rgbNE = texture(colorTexture, varTexcoord + (vec2(+1.0, -1.0) * texcoordOffset)).xyz;
vec3 rgbSW = texture(colorTexture, varTexcoord + (vec2(-1.0, +1.0) * texcoordOffset)).xyz;
vec3 rgbSE = texture(colorTexture, varTexcoord + (vec2(+1.0, +1.0) * texcoordOffset)).xyz;
vec3 rgbM = texture(colorTexture, varTexcoord).xyz;
// convert RGB values to luminance
vec3 luma = vec3(0.299, 0.587, 0.114);
float lumaNW = dot(rgbNW, luma);
float lumaNE = dot(rgbNE, luma);
float lumaSW = dot(rgbSW, luma);
float lumaSE = dot(rgbSE, luma);
float lumaM = dot( rgbM, luma);
// luma range of local neighborhood
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
// direction perpendicular to local luma gradient
vec2 dir;
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
vec3 BoxMin = min(CurrentSubpixel, min(NearColor0, min(NearColor1, min(NearColor2, NearColor3))));
vec3 BoxMax = max(CurrentSubpixel, max(NearColor0, max(NearColor1, max(NearColor2, NearColor3))));;
// compute clamped direction offset for additional "two-tap" samples
// longer vector = blurry, shorter vector = sharp
float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * texcoordOffset;
// perform additional texture sampling perpendicular to gradient
vec3 rgbA = (1.0 / 2.0) * (
texture(colorTexture, varTexcoord + dir * (1.0 / 3.0 - 0.5)).xyz +
texture(colorTexture, varTexcoord + dir * (2.0 / 3.0 - 0.5)).xyz);
vec3 rgbB = rgbA * (1.0 / 2.0) + (1.0 / 4.0) * (
texture(colorTexture, varTexcoord + dir * (0.0 / 3.0 - 0.5)).xyz +
texture(colorTexture, varTexcoord + dir * (3.0 / 3.0 - 0.5)).xyz);
float lumaB = dot(rgbB, luma);
if (gl_FragCoord.x > 800) {
History = clamp(History, BoxMin, BoxMax);
}
// compare luma of new samples to the luma range of the original neighborhood
// if the new samples exceed this range, just use the first two samples instead of all four
if (lumaB < lumaMin || lumaB > lumaMax) {
outFragColor.xyz=rgbA;
} else {
outFragColor.xyz=rgbB;
History = mix(CurrentSubpixel, History, ModulationFactor);
/* outFragHistory.xyz = History;
outFragHistory.w = ModulationFactor
outFragColor.xyz = History;
outFragColor.w = 1.0;*/
/* } else {
outFragColor.xyz = CurrentSubpixel;
outFragColor.w = 1.0;
}*/
if (gl_FragCoord.x > 800) {
/* // filter width limit for dependent "two-tap" texture samples
float FXAA_SPAN_MAX = 8.0;
// local contrast multiplier for performing AA
// higher = sharper, but setting this value too high will cause near-vertical and near-horizontal edges to fail
// see "fxaaQualityEdgeThreshold"
float FXAA_REDUCE_MUL = 1.0 / 8.0;
// luminance threshold for processing dark colors
// see "fxaaQualityEdgeThresholdMin"
float FXAA_REDUCE_MIN = 1.0 / 128.0;
// fetch raw RGB values for nearby locations
// sampling pattern is "five on a die" (each diagonal direction and the center)
// computing the coordinates for these texture reads could be moved to the vertex shader for speed if needed
vec3 rgbNW = texture(colorTexture, varTexCoord0 + (vec2(-1.0, -1.0) * texcoordOffset)).xyz;
vec3 rgbNE = texture(colorTexture, varTexCoord0 + (vec2(+1.0, -1.0) * texcoordOffset)).xyz;
vec3 rgbSW = texture(colorTexture, varTexCoord0 + (vec2(-1.0, +1.0) * texcoordOffset)).xyz;
vec3 rgbSE = texture(colorTexture, varTexCoord0 + (vec2(+1.0, +1.0) * texcoordOffset)).xyz;
vec3 rgbM = texture(colorTexture, varTexCoord0).xyz;
// convert RGB values to luminance
vec3 luma = vec3(0.299, 0.587, 0.114);
float lumaNW = dot(rgbNW, luma);
float lumaNE = dot(rgbNE, luma);
float lumaSW = dot(rgbSW, luma);
float lumaSE = dot(rgbSE, luma);
float lumaM = dot(rgbM, luma);
// luma range of local neighborhood
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
// direction perpendicular to local luma gradient
vec2 dir;
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
// compute clamped direction offset for additional "two-tap" samples
// longer vector = blurry, shorter vector = sharp
float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * texcoordOffset;
// perform additional texture sampling perpendicular to gradient
vec3 rgbA = (1.0 / 2.0) * (
texture(colorTexture, varTexCoord0 + dir * (1.0 / 3.0 - 0.5)).xyz +
texture(colorTexture, varTexCoord0 + dir * (2.0 / 3.0 - 0.5)).xyz);
vec3 rgbB = rgbA * (1.0 / 2.0) + (1.0 / 4.0) * (
texture(colorTexture, varTexCoord0 + dir * (0.0 / 3.0 - 0.5)).xyz +
texture(colorTexture, varTexCoord0 + dir * (3.0 / 3.0 - 0.5)).xyz);
float lumaB = dot(rgbB, luma);
// compare luma of new samples to the luma range of the original neighborhood
// if the new samples exceed this range, just use the first two samples instead of all four
if (lumaB < lumaMin || lumaB > lumaMax) {
outFragColor.xyz = rgbA;
}
else {
outFragColor.xyz = rgbB;
}*/
outFragColor.a = 1.0;
}
outFragColor.a = 1.0;
}

View file

@ -14,11 +14,11 @@
<@include DeferredBufferWrite.slh@>
in vec2 varTexcoord;
in vec2 varTexCoord0;
out vec4 outFragColor;
uniform sampler2D colorTexture;
void main(void) {
outFragColor = texture(colorTexture, varTexcoord);
outFragColor = texture(colorTexture, varTexCoord0);
}

View file

@ -27,7 +27,7 @@ out vec4 _position;
out vec3 _normal;
void main(void) {
_color = colorToLinearRGB(inColor.xyz);
_color = color_sRGBToLinear(inColor.xyz);
_alpha = inColor.w;
TexMapArray texMapArray = getTexMapArray();

View file

@ -28,7 +28,7 @@ out vec3 _normal;
out vec3 _color;
void main(void) {
_color = colorToLinearRGB(inColor.xyz);
_color = color_sRGBToLinear(inColor.xyz);
_alpha = inColor.w;
TexMapArray texMapArray = getTexMapArray();

View file

@ -28,7 +28,7 @@ out vec3 _color;
void main(void) {
// pass along the color in linear space
_color = colorToLinearRGB(inColor.xyz);
_color = color_sRGBToLinear(inColor.xyz);
// and the texture coordinates
TexMapArray texMapArray = getTexMapArray();

View file

@ -29,7 +29,7 @@ out vec4 _worldPosition;
void main(void) {
// pass along the color in linear space
_color = colorToLinearRGB(inColor.xyz);
_color = color_sRGBToLinear(inColor.xyz);
// and the texture coordinates
TexMapArray texMapArray = getTexMapArray();

View file

@ -29,7 +29,7 @@ out vec3 _color;
void main(void) {
// pass along the color in linear space
_color = colorToLinearRGB(inColor.xyz);
_color = color_sRGBToLinear(inColor.xyz);
TexMapArray texMapArray = getTexMapArray();
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$>

View file

@ -30,7 +30,7 @@ out vec4 _worldPosition;
void main(void) {
// pass along the color in linear space
_color = colorToLinearRGB(inColor.xyz);
_color = color_sRGBToLinear(inColor.xyz);
TexMapArray texMapArray = getTexMapArray();
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$>

View file

@ -30,7 +30,7 @@ out float _alpha;
void main(void) {
// pass along the color
_color = colorToLinearRGB(inColor.rgb);
_color = color_sRGBToLinear(inColor.rgb);
_alpha = inColor.a;
TexMapArray texMapArray = getTexMapArray();

View file

@ -31,7 +31,7 @@ out float _alpha;
void main(void) {
// pass along the color
_color = colorToLinearRGB(inColor.rgb);
_color = color_sRGBToLinear(inColor.rgb);
_alpha = inColor.a;
TexMapArray texMapArray = getTexMapArray();

View file

@ -23,7 +23,7 @@ out vec4 _position;
out vec3 _normal;
void main(void) {
_color = colorToLinearRGB(inColor.xyz);
_color = color_sRGBToLinear(inColor.xyz);
_alpha = inColor.w;
_texCoord0 = inTexCoord0.st;

View file

@ -25,7 +25,7 @@ out vec2 _texCoord0;
out vec4 _position;
void main(void) {
_color = colorToLinearRGBA(inColor);
_color = color_sRGBAToLinear(inColor);
_texCoord0 = inTexCoord0.st;
_position = inPosition;
_modelNormal = inNormal.xyz;

View file

@ -29,7 +29,7 @@ out vec4 _position;
out vec4 _worldPosition;
void main(void) {
_color = colorToLinearRGBA(inColor);
_color = color_sRGBAToLinear(inColor);
_texCoord0 = inTexCoord0.st;
_position = inPosition;
_modelNormal = inNormal.xyz;

View file

@ -25,6 +25,6 @@ in vec2 _texCoord0;
void main(void) {
vec4 texel = texture(originalTexture, _texCoord0.st);
texel = colorToLinearRGBA(texel);
texel = color_sRGBAToLinear(texel);
packDeferredFragmentUnlit(normalize(_normal), 1.0, _color.rgb * texel.rgb);
}

View file

@ -28,7 +28,7 @@ void main(void) {
vec4 texel = texture(originalTexture, _texCoord0);
float colorAlpha = _color.a;
if (_color.a <= 0.0) {
texel = colorToLinearRGBA(texel);
texel = color_sRGBAToLinear(texel);
colorAlpha = -_color.a;
}

View file

@ -40,7 +40,7 @@ void main(void) {
vec4 texel = texture(originalTexture, _texCoord0);
float colorAlpha = _color.a;
if (_color.a <= 0.0) {
texel = colorToLinearRGBA(texel);
texel = color_sRGBAToLinear(texel);
colorAlpha = -_color.a;
}

View file

@ -27,7 +27,7 @@ void main(void) {
vec4 texel = texture(originalTexture, _texCoord0.st);
float colorAlpha = _color.a;
if (_color.a <= 0.0) {
texel = colorToLinearRGBA(texel);
texel = color_sRGBAToLinear(texel);
colorAlpha = -_color.a;
}

View file

@ -39,7 +39,7 @@ void main(void) {
vec4 texel = texture(originalTexture, _texCoord0.st);
float colorAlpha = _color.a;
if (_color.a <= 0.0) {
texel = colorToLinearRGBA(texel);
texel = color_sRGBAToLinear(texel);
colorAlpha = -_color.a;
}

View file

@ -34,7 +34,7 @@ void main(void) {
vec4 texel = texture(originalTexture, _texCoord0.st);
float opacity = _color.a;
if (_color.a <= 0.0) {
texel = colorToLinearRGBA(texel);
texel = color_sRGBAToLinear(texel);
opacity = -_color.a;
}
opacity *= texel.a;

View file

@ -46,7 +46,7 @@ void main(void) {
vec4 texel = texture(originalTexture, _texCoord0.st);
float opacity = _color.a;
if (_color.a <= 0.0) {
texel = colorToLinearRGBA(texel);
texel = color_sRGBAToLinear(texel);
opacity = -_color.a;
}
opacity *= texel.a;

View file

@ -29,7 +29,7 @@ void main(void) {
vec4 texel = texture(originalTexture, _texCoord0.st);
float colorAlpha = _color.a;
if (_color.a <= 0.0) {
texel = colorToLinearRGBA(texel);
texel = color_sRGBAToLinear(texel);
colorAlpha = -_color.a;
}
_fragColor0 = vec4(_color.rgb * texel.rgb, colorAlpha * texel.a);

View file

@ -40,7 +40,7 @@ void main(void) {
vec4 texel = texture(originalTexture, _texCoord0.st);
float colorAlpha = _color.a;
if (_color.a <= 0.0) {
texel = colorToLinearRGBA(texel);
texel = color_sRGBAToLinear(texel);
colorAlpha = -_color.a;
}
_fragColor0 = vec4(_color.rgb * texel.rgb+fadeEmissive, colorAlpha * texel.a);

View file

@ -25,7 +25,7 @@ in vec2 _texCoord0;
void main(void) {
vec4 texel = texture(originalTexture, _texCoord0.st);
texel = colorToLinearRGBA(texel);
texel = color_sRGBAToLinear(texel);
packDeferredFragmentTranslucent(
normalize(_normal),
_color.a,

View file

@ -36,7 +36,7 @@ void main(void) {
skinPositionNormal(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, position, interpolatedNormal);
// pass along the color
_color = colorToLinearRGB(inColor.rgb);
_color = color_sRGBToLinear(inColor.rgb);
_alpha = inColor.a;
TexMapArray texMapArray = getTexMapArray();

View file

@ -37,7 +37,7 @@ void main(void) {
skinPositionNormal(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, position, interpolatedNormal);
// pass along the color
_color = colorToLinearRGB(inColor.rgb);
_color = color_sRGBToLinear(inColor.rgb);
_alpha = inColor.a;
TexMapArray texMapArray = getTexMapArray();

View file

@ -38,7 +38,7 @@ void main(void) {
skinPositionNormalTangent(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, inTangent.xyz, position, interpolatedNormal.xyz, interpolatedTangent.xyz);
// pass along the color
_color = colorToLinearRGB(inColor.rgb);
_color = color_sRGBToLinear(inColor.rgb);
_alpha = inColor.a;
TexMapArray texMapArray = getTexMapArray();

View file

@ -39,7 +39,7 @@ void main(void) {
skinPositionNormalTangent(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, inTangent.xyz, position, interpolatedNormal.xyz, interpolatedTangent.xyz);
// pass along the color
_color = colorToLinearRGB(inColor.rgb);
_color = color_sRGBToLinear(inColor.rgb);
_alpha = inColor.a;
TexMapArray texMapArray = getTexMapArray();

View file

@ -24,7 +24,7 @@ out vec4 varColor;
void main(void) {
varTexCoord0 = inTexCoord0.st;
varColor = colorToLinearRGBA(inColor);
varColor = color_sRGBAToLinear(inColor);
// standard transform
TransformCamera cam = getTransformCamera();

View file

@ -0,0 +1,65 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// taa.frag
// fragment shader
//
// Created by Sam Gateau on 8/14/2017
// Copyright 2017 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include taa.slh@>
in vec2 varTexCoord0;
layout(location = 0) out vec4 outFragColor;
void main() {
vec2 fragUV = varTexCoord0;
vec2 texelSize = taa_getTexelSize();
vec2 fragJitterPix = taa_getCurrentJitterSample();
if (taa_unjitter()) {
fragUV -= fragJitterPix * texelSize;
}
// Debug region before debug or fxaa region X
float distToRegionFXAA = fragUV.x - taa_getRegionFXAA().x;
if (distToRegionFXAA > 0.0) {
outFragColor = vec4(taa_evalFXAA(fragUV), 1.0);
return;
}
// vec3 nearFragUV = taa_findClosestFragment3x3(fragUV);
// vec2 fragVel = taa_fetchVelocityMap(nearFragUV.xy);
vec3 fragVelAndZ = taa_fetchVelocityMapBest(fragUV);
vec2 fragVel = fragVelAndZ.xy;
float fragDepth = fragVelAndZ.z;
vec3 sourceColor;
vec3 historyColor;
vec2 prevFragUV = taa_fetchSourceAndHistory(fragUV, fragVel, fragJitterPix, sourceColor, historyColor);
vec3 nextColor = sourceColor;
if (taa_constrainColor()) {
// clamp history to neighbourhood of current sample
historyColor = taa_evalConstrainColor(sourceColor, fragUV, fragVel, fragDepth, fragJitterPix, historyColor);
}
if (taa_feedbackColor()) {
nextColor = taa_evalFeedbackColor(sourceColor, historyColor, params.blend);
} else {
nextColor = mix(historyColor, sourceColor, params.blend);
}
outFragColor = vec4(taa_resolveColor(nextColor), 1.0);
}

View file

@ -0,0 +1,578 @@
// Generated on <$_SCRIBE_DATE$>
//
// TAA.slh
// Common component needed by TemporalAntialiasing fragment shader
//
// Created by Sam Gateau on 8/17/2017
// Copyright 2017 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include DeferredTransform.slh@>
<$declareDeferredFrameTransform()$>
const int SEQUENCE_LENGTH = 16;
const int INFO_INDEX = SEQUENCE_LENGTH / 2;
struct JitterSequence {
vec4 offsets[INFO_INDEX + 1];
};
layout(std140) uniform taaJitterBuffer {
JitterSequence sequence;
};
vec2 taa_getJitterSample(int index) {
return vec2((bool(index & 0x01) ? sequence.offsets[index >> 1].zw : sequence.offsets[index >> 1].xy));
}
int taa_getJitterSequenceLength() {
return floatBitsToInt(sequence.offsets[INFO_INDEX].z);
}
int taa_getCurrentJitterIndex() {
return floatBitsToInt(sequence.offsets[INFO_INDEX].w);
}
vec2 taa_getCurrentJitterSample() {
return taa_getJitterSample(taa_getCurrentJitterIndex());
}
<@include gpu/Color.slh@>
uniform sampler2D depthMap;
uniform sampler2D sourceMap;
uniform sampler2D historyMap;
uniform sampler2D velocityMap;
uniform sampler2D nextMap;
struct TAAParams
{
float none;
float blend;
float covarianceGamma;
float debugShowVelocityThreshold;
ivec4 flags;
vec4 pixelInfo_orbZoom;
vec4 regionInfo;
};
layout(std140) uniform taaParamsBuffer {
TAAParams params;
};
#define GET_BIT(bitfield, bitIndex) bool((bitfield) & (1 << (bitIndex)))
bool taa_showDebugCursor() {
return GET_BIT(params.flags.x, 1);
}
bool taa_showJitterSequence() {
return GET_BIT(params.flags.x, 2);
}
bool taa_showClosestFragment() {
return GET_BIT(params.flags.x, 3);
}
bool taa_unjitter() {
return GET_BIT(params.flags.y, 0);
}
bool taa_constrainColor() {
return GET_BIT(params.flags.y, 1);
}
bool taa_covarianceClipColor() {
return GET_BIT(params.flags.y, 2);
}
bool taa_clipExactColor() {
return GET_BIT(params.flags.y, 3);
}
bool taa_feedbackColor() {
return GET_BIT(params.flags.y, 4);
}
vec2 taa_getDebugCursorTexcoord() {
return params.pixelInfo_orbZoom.xy;
}
float taa_getDebugOrbZoom() {
return params.pixelInfo_orbZoom.z;
}
vec2 taa_getRegionDebug() {
return params.regionInfo.xy;
}
vec2 taa_getRegionFXAA() {
return params.regionInfo.zw;
}
#define USE_YCOCG 1
vec4 taa_fetchColor(sampler2D map, vec2 uv) {
#if USE_YCOCG
vec4 c = texture(map, uv);
return vec4(color_LinearToYCoCg(c.rgb), c.a);
#else
return texture(map, uv);
#endif
}
vec3 taa_resolveColor(vec3 color) {
#if USE_YCOCG
return color_YCoCgToLinear(color);
#else
return color;
#endif
}
vec4 taa_fetchSourceMap(vec2 uv) {
#if USE_YCOCG
vec4 c = texture(sourceMap, uv);
return vec4(color_LinearToYCoCg(c.rgb), c.a);
#else
return texture(sourceMap, uv);
#endif
}
vec4 taa_fetchHistoryMap(vec2 uv) {
#if USE_YCOCG
vec4 c = texture(historyMap, uv);
return vec4(color_LinearToYCoCg(c.rgb), c.a);
#else
return texture(historyMap, uv);
#endif
}
vec4 taa_fetchNextMap(vec2 uv) {
#if USE_YCOCG
vec4 c = texture(nextMap, uv);
return vec4(color_LinearToYCoCg(c.rgb), c.a);
#else
return texture(nextMap, uv);
#endif
}
vec2 taa_fetchVelocityMap(vec2 uv) {
return texture(velocityMap, uv).xy;
}
float taa_fetchDepth(vec2 uv) {
return -texture(depthMap, vec2(uv), 0).x;
}
#define ZCMP_GT(a, b) (a > b)
vec2 taa_getImageSize() {
vec2 imageSize = getWidthHeight(0);
if (isStereo()) {
imageSize.x *= 2.0;
}
return imageSize;
}
vec2 taa_getTexelSize() {
vec2 texelSize = getInvWidthHeight();
if (isStereo()) {
texelSize.x *= 0.5;
}
return texelSize;
}
vec3 taa_findClosestFragment3x3(vec2 uv)
{
vec2 dd = abs(taa_getTexelSize());
vec2 du = vec2(dd.x, 0.0);
vec2 dv = vec2(0.0, dd.y);
vec3 dtl = vec3(-1, -1, taa_fetchDepth(uv - dv - du));
vec3 dtc = vec3( 0, -1, taa_fetchDepth(uv - dv));
vec3 dtr = vec3( 1, -1, taa_fetchDepth(uv - dv + du));
vec3 dml = vec3(-1, 0, taa_fetchDepth(uv - du));
vec3 dmc = vec3( 0, 0, taa_fetchDepth(uv));
vec3 dmr = vec3( 1, 0, taa_fetchDepth(uv + du));
vec3 dbl = vec3(-1, 1, taa_fetchDepth(uv + dv - du));
vec3 dbc = vec3( 0, 1, taa_fetchDepth(uv + dv));
vec3 dbr = vec3( 1, 1, taa_fetchDepth(uv + dv + du));
vec3 dmin = dtl;
if (ZCMP_GT(dmin.z, dtc.z)) dmin = dtc;
if (ZCMP_GT(dmin.z, dtr.z)) dmin = dtr;
if (ZCMP_GT(dmin.z, dml.z)) dmin = dml;
if (ZCMP_GT(dmin.z, dmc.z)) dmin = dmc;
if (ZCMP_GT(dmin.z, dmr.z)) dmin = dmr;
if (ZCMP_GT(dmin.z, dbl.z)) dmin = dbl;
if (ZCMP_GT(dmin.z, dbc.z)) dmin = dbc;
if (ZCMP_GT(dmin.z, dbr.z)) dmin = dbr;
return vec3(uv + dd.xy * dmin.xy, dmin.z);
}
vec3 taa_fetchVelocityMapBest(vec2 uv) {
vec2 dd = abs(taa_getTexelSize());
vec2 du = vec2(dd.x, 0.0);
vec2 dv = vec2(0.0, dd.y);
vec2 dtl = taa_fetchVelocityMap(uv - dv - du);
vec2 dtc = taa_fetchVelocityMap(uv - dv);
vec2 dtr = taa_fetchVelocityMap(uv - dv + du);
vec2 dml = taa_fetchVelocityMap(uv - du);
vec2 dmc = taa_fetchVelocityMap(uv);
vec2 dmr = taa_fetchVelocityMap(uv + du);
vec2 dbl = taa_fetchVelocityMap(uv + dv - du);
vec2 dbc = taa_fetchVelocityMap(uv + dv);
vec2 dbr = taa_fetchVelocityMap(uv + dv + du);
vec3 best = vec3(dtl, dot(dtl,dtl));
float testSpeed = dot(dtc,dtc);
if (testSpeed > best.z) { best = vec3(dtc, testSpeed); }
testSpeed = dot(dtr,dtr);
if (testSpeed > best.z) { best = vec3(dtr, testSpeed); }
testSpeed = dot(dml,dml);
if (testSpeed > best.z) { best = vec3(dml, testSpeed); }
testSpeed = dot(dmc,dmc);
if (testSpeed > best.z) { best = vec3(dmc, testSpeed); }
testSpeed = dot(dmr,dmr);
if (testSpeed > best.z) { best = vec3(dmr, testSpeed); }
testSpeed = dot(dbl,dbl);
if (testSpeed > best.z) { best = vec3(dbl, testSpeed); }
testSpeed = dot(dbc,dbc);
if (testSpeed > best.z) { best = vec3(dbc, testSpeed); }
testSpeed = dot(dbr,dbr);
if (testSpeed > best.z) { best = vec3(dbr, testSpeed); }
return vec3(best.xy, taa_fetchDepth(uv));
}
vec2 taa_fetchSourceAndHistory(vec2 fragUV, vec2 fragVelocity, vec2 fragJitterPix, out vec3 sourceColor, out vec3 historyColor) {
sourceColor = taa_fetchSourceMap(fragUV).xyz;
vec2 prevFragUV = fragUV - fragVelocity;
historyColor = sourceColor;
if (!(any(lessThan(prevFragUV, vec2(0.0))) || any(greaterThan(prevFragUV, vec2(1.0))))) {
historyColor = taa_fetchHistoryMap(prevFragUV).xyz;
}
return prevFragUV;
}
float Luminance(vec3 rgb) {
return rgb.x/4.0 + rgb.y/2.0 + rgb.z/4.0;
}
#define MINMAX_3X3_ROUNDED 1
mat3 taa_evalNeighbourColorVariance(vec3 sourceColor, vec2 fragUV, vec2 fragVelocity, float fragZe, vec2 fragJitterPix) {
vec2 texelSize = taa_getTexelSize();
vec2 du = vec2(texelSize.x, 0.0);
vec2 dv = vec2(0.0, texelSize.y);
vec3 sampleColor = taa_fetchSourceMap(fragUV - dv - du).rgb;
vec3 sumSamples = sampleColor;
vec3 sumSamples2 = sampleColor * sampleColor;
sampleColor = taa_fetchSourceMap(fragUV - dv).rgb;
sumSamples += sampleColor;
sumSamples2 += sampleColor * sampleColor;
sampleColor = taa_fetchSourceMap(fragUV - dv + du).rgb;
sumSamples += sampleColor;
sumSamples2 += sampleColor * sampleColor;
sampleColor = taa_fetchSourceMap(fragUV - du).rgb;
sumSamples += sampleColor;
sumSamples2 += sampleColor * sampleColor;
sampleColor = sourceColor; //taa_fetchSourceMap(fragUV).rgb; // could resuse the same osurce sampleColor isn't it ?
sumSamples += sampleColor;
sumSamples2 += sampleColor * sampleColor;
sampleColor = taa_fetchSourceMap(fragUV + du).rgb;
sumSamples += sampleColor;
sumSamples2 += sampleColor * sampleColor;
sampleColor = taa_fetchSourceMap(fragUV + dv - du).rgb;
sumSamples += sampleColor;
sumSamples2 += sampleColor * sampleColor;
sampleColor = taa_fetchSourceMap(fragUV + dv).rgb;
sumSamples += sampleColor;
sumSamples2 += sampleColor * sampleColor;
sampleColor = taa_fetchSourceMap(fragUV + dv + du).rgb;
sumSamples += sampleColor;
sumSamples2 += sampleColor * sampleColor;
vec3 mu = sumSamples / vec3(9.0);
vec3 sigma = sqrt(sumSamples2 / vec3(9.0) - mu * mu);
float gamma = params.covarianceGamma;
vec3 cmin = mu - gamma * sigma;
vec3 cmax = mu + gamma * sigma;
return mat3(cmin, cmax, mu);
}
mat3 taa_evalNeighbourColorRegion(vec3 sourceColor, vec2 fragUV, vec2 fragVelocity, float fragZe, vec2 fragJitterPix) {
vec2 imageSize = taa_getImageSize();
vec2 texelSize = taa_getTexelSize();
vec3 cmin, cmax, cavg;
#if MINMAX_3X3_ROUNDED
vec2 du = vec2(texelSize.x, 0.0);
vec2 dv = vec2(0.0, texelSize.y);
vec3 ctl = taa_fetchSourceMap(fragUV - dv - du).rgb;
vec3 ctc = taa_fetchSourceMap(fragUV - dv).rgb;
vec3 ctr = taa_fetchSourceMap(fragUV - dv + du).rgb;
vec3 cml = taa_fetchSourceMap(fragUV - du).rgb;
vec3 cmc = sourceColor; //taa_fetchSourceMap(fragUV).rgb; // could resuse the same osurce sample isn't it ?
vec3 cmr = taa_fetchSourceMap(fragUV + du).rgb;
vec3 cbl = taa_fetchSourceMap(fragUV + dv - du).rgb;
vec3 cbc = taa_fetchSourceMap(fragUV + dv).rgb;
vec3 cbr = taa_fetchSourceMap(fragUV + dv + du).rgb;
cmin = min(ctl, min(ctc, min(ctr, min(cml, min(cmc, min(cmr, min(cbl, min(cbc, cbr))))))));
cmax = max(ctl, max(ctc, max(ctr, max(cml, max(cmc, max(cmr, max(cbl, max(cbc, cbr))))))));
#if MINMAX_3X3_ROUNDED || USE_YCOCG || USE_CLIPPING
cavg = (ctl + ctc + ctr + cml + cmc + cmr + cbl + cbc + cbr) / 9.0;
#elif
cavg = (cmin + cmax ) * 0.5;
#endif
#if MINMAX_3X3_ROUNDED
vec3 cmin5 = min(ctc, min(cml, min(cmc, min(cmr, cbc))));
vec3 cmax5 = max(ctc, max(cml, max(cmc, max(cmr, cbc))));
vec3 cavg5 = (ctc + cml + cmc + cmr + cbc) / 5.0;
cmin = 0.5 * (cmin + cmin5);
cmax = 0.5 * (cmax + cmax5);
cavg = 0.5 * (cavg + cavg5);
#endif
#else
const float _SubpixelThreshold = 0.5;
const float _GatherBase = 0.5;
const float _GatherSubpixelMotion = 0.1666;
vec2 texel_vel = fragVelocity * imageSize;
float texel_vel_mag = length(texel_vel) * -fragZe;
float k_subpixel_motion = clamp(_SubpixelThreshold / (0.0001 + texel_vel_mag), 0.0, 1.0);
float k_min_max_support = _GatherBase + _GatherSubpixelMotion * k_subpixel_motion;
vec2 ss_offset01 = k_min_max_support * vec2(-texelSize.x, texelSize.y);
vec2 ss_offset11 = k_min_max_support * vec2(texelSize.x, texelSize.y);
vec3 c00 = taa_fetchSourceMap(fragUV - ss_offset11).rgb;
vec3 c10 = taa_fetchSourceMap(fragUV - ss_offset01).rgb;
vec3 c01 = taa_fetchSourceMap(fragUV + ss_offset01).rgb;
vec3 c11 = taa_fetchSourceMap(fragUV + ss_offset11).rgb;
cmin = min(c00, min(c10, min(c01, c11)));
cmax = max(c00, max(c10, max(c01, c11)));
cavg = (cmin + cmax ) * 0.5;
#if USE_YCOCG || USE_CLIPPING
cavg = (c00 + c10 + c01 + c11) / 4.0;
#elif
cavg = (cmin + cmax ) * 0.5;
#endif
#endif
// shrink chroma min-max
#if USE_YCOCG
vec2 chroma_extent = vec2(0.25 * 0.5 * (cmax.r - cmin.r));
vec2 chroma_center = sourceColor.gb;
cmin.yz = chroma_center - chroma_extent;
cmax.yz = chroma_center + chroma_extent;
cavg.yz = chroma_center;
#endif
return mat3(cmin, cmax, cavg);
}
//#define USE_OPTIMIZATIONS 0
vec3 taa_clampColor(vec3 colorMin, vec3 colorMax, vec3 colorSource, vec3 color) {
const float eps = 0.00001;
vec3 p = colorSource;
vec3 q = color;
if (taa_clipExactColor()) {
vec3 r = q - p;
vec3 rmax = colorMax - p.xyz;
vec3 rmin = colorMin - p.xyz;
/* bvec3 over = (greaterThan(r, rmax + vec3(eps)));
bvec3 under = (lessThan(r, rmin - vec3(eps)));
float minScale = 1.0;
if (over.x || under.x)
minScale = (float(over.x) * rmax.x + float(under.x) * rmin.x) / r.x;
if (over.y || under.y)
minScale = min(minScale, (float(over.y) * rmax.y + float(under.y) * rmin.y) / r.y);
if (over.z || under.z)
minScale = min(minScale, (float(over.z) * rmax.z + float(under.z) * rmin.z) / r.z);
r *= minScale;
*/
if (r.x > rmax.x + eps)
r *= (rmax.x / r.x);
if (r.y > rmax.y + eps)
r *= (rmax.y / r.y);
if (r.z > rmax.z + eps)
r *= (rmax.z / r.z);
if (r.x < rmin.x - eps)
r *= (rmin.x / r.x);
if (r.y < rmin.y - eps)
r *= (rmin.y / r.y);
if (r.z < rmin.z - eps)
r *= (rmin.z / r.z);
return clamp(p + r, vec3(0.0), vec3(1.0));
} else {
// note: only clips towards aabb center (but fast!)
vec3 p_clip = 0.5 * (colorMax + colorMin);
vec3 e_clip = 0.5 * (colorMax - colorMin) + vec3(eps);
vec3 v_clip = q - p_clip;
vec3 v_unit = v_clip.xyz / e_clip;
vec3 a_unit = abs(v_unit);
float ma_unit = max(a_unit.x, max(a_unit.y, a_unit.z));
if (ma_unit > 1.0)
return p_clip + v_clip / ma_unit;
else
return q;// point inside aabb
}
// Not using clamp at all
// else {
// return clamp(color, colorMin, colorMax);
//}
}
vec3 taa_evalConstrainColor(vec3 sourceColor, vec2 sourceUV, vec2 sourceVel, float sourceZe, vec2 sourceJitterPix, vec3 candidateColor) {
mat3 colorMinMaxAvg;
if (taa_covarianceClipColor()) {
colorMinMaxAvg = taa_evalNeighbourColorVariance(sourceColor, sourceUV, sourceVel, sourceZe, sourceJitterPix);
} else {
colorMinMaxAvg = taa_evalNeighbourColorRegion(sourceColor, sourceUV, sourceVel, sourceZe, sourceJitterPix);
}
// clamp history to neighbourhood of current sample
return taa_clampColor(colorMinMaxAvg[0], colorMinMaxAvg[1], sourceColor, candidateColor);
}
vec3 taa_evalFeedbackColor(vec3 sourceColor, vec3 historyColor, float blendFactor) {
const float _FeedbackMin = 0.1;
const float _FeedbackMax = 0.9;
// feedback weight from unbiased luminance diff (t.lottes)
#if USE_YCOCG
float lum0 = sourceColor.r;
float lum1 = historyColor.r;
#else
float lum0 = Luminance(sourceColor.rgb);
float lum1 = Luminance(historyColor.rgb);
#endif
float unbiased_diff = abs(lum0 - lum1) / max(lum0, max(lum1, 0.2));
float unbiased_weight = 1.0 - unbiased_diff;
float unbiased_weight_sqr = unbiased_weight * unbiased_weight;
float k_feedback = mix(_FeedbackMin, _FeedbackMax, unbiased_weight_sqr);
vec3 nextColor = mix(historyColor, sourceColor, k_feedback * blendFactor).xyz;
return nextColor;
}
<$declareColorWheel()$>
vec3 taa_getVelocityColorRelative(float velocityPixLength) {
return colorRamp(velocityPixLength/params.debugShowVelocityThreshold);
}
vec3 taa_getVelocityColorAboveThreshold(float velocityPixLength) {
return colorRamp((velocityPixLength - params.debugShowVelocityThreshold)/params.debugShowVelocityThreshold);
}
vec3 taa_evalFXAA(vec2 fragUV) {
// vec2 texelSize = getInvWidthHeight();
vec2 texelSize = taa_getTexelSize();
// filter width limit for dependent "two-tap" texture samples
float FXAA_SPAN_MAX = 8.0;
// local contrast multiplier for performing AA
// higher = sharper, but setting this value too high will cause near-vertical and near-horizontal edges to fail
// see "fxaaQualityEdgeThreshold"
float FXAA_REDUCE_MUL = 1.0 / 8.0;
// luminance threshold for processing dark colors
// see "fxaaQualityEdgeThresholdMin"
float FXAA_REDUCE_MIN = 1.0 / 128.0;
// fetch raw RGB values for nearby locations
// sampling pattern is "five on a die" (each diagonal direction and the center)
// computing the coordinates for these texture reads could be moved to the vertex shader for speed if needed
vec3 rgbNW = texture(sourceMap, fragUV + (vec2(-1.0, -1.0) * texelSize)).xyz;
vec3 rgbNE = texture(sourceMap, fragUV + (vec2(+1.0, -1.0) * texelSize)).xyz;
vec3 rgbSW = texture(sourceMap, fragUV + (vec2(-1.0, +1.0) * texelSize)).xyz;
vec3 rgbSE = texture(sourceMap, fragUV + (vec2(+1.0, +1.0) * texelSize)).xyz;
vec3 rgbM = texture(sourceMap, fragUV).xyz;
// convert RGB values to luminance
vec3 luma = vec3(0.299, 0.587, 0.114);
float lumaNW = dot(rgbNW, luma);
float lumaNE = dot(rgbNE, luma);
float lumaSW = dot(rgbSW, luma);
float lumaSE = dot(rgbSE, luma);
float lumaM = dot( rgbM, luma);
// luma range of local neighborhood
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
// direction perpendicular to local luma gradient
vec2 dir;
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
// compute clamped direction offset for additional "two-tap" samples
// longer vector = blurry, shorter vector = sharp
float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * texelSize;
// perform additional texture sampling perpendicular to gradient
vec3 rgbA = (1.0 / 2.0) * (
texture(sourceMap, fragUV + dir * (1.0 / 3.0 - 0.5)).xyz +
texture(sourceMap, fragUV + dir * (2.0 / 3.0 - 0.5)).xyz);
vec3 rgbB = rgbA * (1.0 / 2.0) + (1.0 / 4.0) * (
texture(sourceMap, fragUV + dir * (0.0 / 3.0 - 0.5)).xyz +
texture(sourceMap, fragUV + dir * (3.0 / 3.0 - 0.5)).xyz);
float lumaB = dot(rgbB, luma);
// compare luma of new samples to the luma range of the original neighborhood
// if the new samples exceed this range, just use the first two samples instead of all four
if (lumaB < lumaMin || lumaB > lumaMax) {
return rgbA;
} else {
return rgbB;
}
}

View file

@ -0,0 +1,182 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// taa_blend.frag
// fragment shader
//
// Created by Sam Gateau on 8/17/2017
// Copyright 2017 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include taa.slh@>
in vec2 varTexCoord0;
layout(location = 0) out vec4 outFragColor;
void main(void) {
vec3 nextColor = texture(nextMap, varTexCoord0).xyz;
outFragColor = vec4(nextColor, 1.0);
// Pixel being shaded
vec3 sourceColor = texture(sourceMap, varTexCoord0).xyz;
vec2 imageSize = getWidthHeight(0);
vec2 texelSize = getInvWidthHeight();
vec2 fragJitterPix = taa_getCurrentJitterSample();
vec2 pixPos = varTexCoord0 * imageSize;
vec2 pixVelocity = imageSize * texture(velocityMap, varTexCoord0).xy;
float pixVelocityLength = length(pixVelocity);
vec2 velocity = pixVelocity * texelSize;
vec2 prevTexCoord = varTexCoord0 - velocity;
vec2 prevPix = prevTexCoord * imageSize;
// Pixel Debugged
if (taa_showDebugCursor()) {
vec2 cursorUVRaw = taa_getDebugCursorTexcoord();
vec2 cursorPosRaw = floor(cursorUVRaw * imageSize) + vec2(0.5);
vec3 cursorFrag = taa_findClosestFragment3x3(cursorUVRaw);
vec2 cursorUV = cursorUVRaw - fragJitterPix * texelSize;
vec2 cursorPos = cursorUV * imageSize;
vec2 cursorVelocity = texture(velocityMap, cursorUV).xy;
vec2 cursorPrevUV = cursorUV - cursorVelocity;
cursorVelocity *= imageSize;
float cursorVelocityLength = length(cursorVelocity);
vec2 cursorVelocityDir = cursorVelocity / cursorVelocityLength;
vec2 cursorToFragVec = pixPos - cursorPos;
float cursorToFragLength = length(cursorToFragVec);
if ((cursorToFragLength <= cursorVelocityLength)) {
vec2 cursorVelocityDir = cursorVelocity / cursorVelocityLength;
vec2 cursorVelocityNor = vec2(cursorVelocityDir.y, -cursorVelocityDir.x);
if ((dot(cursorVelocityDir, cursorToFragVec) < 0) && abs(dot(cursorVelocityNor, cursorToFragVec)) < 1.0) {
vec3 speedColor = taa_getVelocityColorRelative(cursorToFragLength);
outFragColor = vec4(speedColor, 1.0);
return;
}
}
float tenPercentHeight = 0.1 * imageSize.y;
float centerWidth = imageSize.x * 0.5;
//vec2 nextOrbPos = vec2(centerWidth, imageSize.y - 3 * tenPercentHeight);
vec2 nextOrbPos = cursorPos;
vec2 nextOrbPosToPix = pixPos - nextOrbPos;
float nextOrbPosToPixLength = length(nextOrbPosToPix);
vec2 prevOrbPos = nextOrbPos - cursorVelocityDir * 2.0 * tenPercentHeight;
vec2 prevOrbPosToPix = pixPos - prevOrbPos;
float prevOrbPosToPixLength = length(prevOrbPosToPix);
float orbPixThreshold = 2.0 / taa_getDebugOrbZoom();
if ((prevOrbPosToPixLength < tenPercentHeight) && (cursorVelocityLength > 0.5)) {
vec2 prevOrbPosToPix_uv = cursorPrevUV + prevOrbPosToPix * texelSize / taa_getDebugOrbZoom();
vec3 preOrbColor = vec3(0.0);
if (!(any(lessThan(prevOrbPosToPix_uv, vec2(0.0))) || any(greaterThan(prevOrbPosToPix_uv, vec2(1.0))))) {
preOrbColor = texture(historyMap, prevOrbPosToPix_uv).xyz;
}
if (prevOrbPosToPixLength < orbPixThreshold) {
preOrbColor = vec3(1.0, 0.0, 1.0);
}
float distanceToNext = length(imageSize * (cursorUV - prevOrbPosToPix_uv));
if (distanceToNext < orbPixThreshold) {
preOrbColor = vec3(1.0, 0.5, 0.0);
}
outFragColor = vec4(preOrbColor, 1.0);
return;
}
if (nextOrbPosToPixLength < tenPercentHeight) {
vec2 nextOrbPosToPix_uv = cursorUV + nextOrbPosToPix * texelSize / taa_getDebugOrbZoom();
vec3 nextOrbColor = vec3(0.0);
if (!(any(lessThan(nextOrbPosToPix_uv, vec2(0.0))) || any(greaterThan(nextOrbPosToPix_uv, vec2(1.0))))) {
nextOrbColor = texture(nextMap, nextOrbPosToPix_uv).xyz;
}
float distanceToPrev = length(imageSize * (cursorPrevUV - nextOrbPosToPix_uv));
if (distanceToPrev < orbPixThreshold) {
nextOrbColor = vec3(1.0, 0.0, 1.0);
}
if (nextOrbPosToPixLength < orbPixThreshold) {
nextOrbColor = vec3(1.0, 0.5, 0.0);
}
outFragColor = vec4(nextOrbColor, 1.0);
return;
}
}
if (taa_showJitterSequence()) {
float tenPercentHeight = 0.1 * imageSize.y;
vec2 jitterRegionSize = vec2(tenPercentHeight);
vec2 jitterRegionPos = (pixPos - vec2(tenPercentHeight, imageSize.y - tenPercentHeight));
if ((all(lessThan(jitterRegionPos, jitterRegionSize)) && all(greaterThan(jitterRegionPos, vec2(0.0))))) {
float niceDotR2 = 4.0;
//int sequenceLength = taa_getJitterSequenceLength();
int sequenceLength = SEQUENCE_LENGTH;
for (int s = 0; s < sequenceLength; s++) {
vec2 pixToSampleVec = jitterRegionPos - (vec2(0.5) + taa_getJitterSample(s)) * jitterRegionSize;
float radius2 = (s == taa_getCurrentJitterIndex() ? 4.0 * niceDotR2 : niceDotR2);
float distToSample2 = dot(pixToSampleVec, pixToSampleVec);
if (distToSample2 < radius2) {
outFragColor = vec4(mix( outFragColor.rgb, colorRamp(float(s) / float(sequenceLength)), 1.0 - distToSample2 / radius2), 1.0);
return;
}
}
}
}
// Debug region before debug or fxaa region X
float distToRegionDebug = varTexCoord0.x - taa_getRegionDebug().x;
float distToRegionFXAA = varTexCoord0.x - taa_getRegionFXAA().x;
if ((distToRegionFXAA < 0.0) && (distToRegionDebug > 0.0)) {
return;
}
// draw region splitter
if ((abs(distToRegionDebug) < getInvWidthHeight().x) || (abs(distToRegionFXAA) < getInvWidthHeight().x)) {
outFragColor.rgb = vec3(1.0, 1.0, 0.0);
return;
}
if (distToRegionFXAA > 0.0) {
return;
}
if (taa_showClosestFragment()) {
vec3 fragUV = taa_findClosestFragment3x3(varTexCoord0);
outFragColor = vec4((fragUV.xy - varTexCoord0) * imageSize * 0.5 + vec2(0.5), 0.0, 1.0);
return;
}
outFragColor = vec4(nextColor, 1.0);
vec3 prevColor = nextColor;
if (!(any(lessThan(prevTexCoord, vec2(0.0))) || any(greaterThan(prevTexCoord, vec2(1.0))))) {
prevColor = texture(historyMap, prevTexCoord).xyz;
}
outFragColor.xyz = prevColor;
if (pixVelocityLength > params.debugShowVelocityThreshold) {
vec3 speedColor = taa_getVelocityColorAboveThreshold(pixVelocityLength);
outFragColor = vec4(0.0, 1.0, 1.0, 1.0);
}
}

View file

@ -0,0 +1,46 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Sam Gateau on 6/3/16.
// Copyright 2016 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include DeferredTransform.slh@>
<$declareDeferredFrameTransform()$>
in vec2 varTexCoord0;
out vec4 outFragColor;
uniform sampler2D depthMap;
void main(void) {
// Pixel being shaded
ivec2 pixelPos;
vec2 texcoordPos;
ivec4 stereoSide;
ivec2 framePixelPos = getPixelPosTexcoordPosAndSide(gl_FragCoord.xy, pixelPos, texcoordPos, stereoSide);
float Zdb = texelFetch(depthMap, ivec2(gl_FragCoord.xy), 0).x;
float Zeye = evalZeyeFromZdb(Zdb);
/* if (Zeye <= -getPosLinearDepthFar()) {
outFragColor = vec4(0.5, 0.5, 0.0, 0.0);
return;
}*/
// The position of the pixel fragment in Eye space then in world space
vec3 eyePos = evalEyePositionFromZeye(stereoSide.x, Zeye, texcoordPos);
vec3 worldPos = (frameTransform._viewInverse * cameraCorrection._correction * vec4(eyePos, 1.0)).xyz;
vec3 prevEyePos = (cameraCorrection._prevCorrectionInverse * frameTransform._prevView * vec4(worldPos, 1.0)).xyz;
vec4 prevClipPos = (frameTransform._projection[stereoSide.x] * vec4(prevEyePos, 1.0));
vec2 prevUV = 0.5 * (prevClipPos.xy / prevClipPos.w) + vec2(0.5);
//vec2 imageSize = getWidthHeight(0);
vec2 imageSize = vec2(1.0, 1.0);
outFragColor = vec4( ((texcoordPos - prevUV) * imageSize), 0.0, 0.0);
}

View file

@ -0,0 +1,93 @@
Copyright (c) 2009, Mark Simonson (http://www.ms-studio.com, mark@marksimonson.com),
with Reserved Font Name Anonymous Pro.
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Binary file not shown.

View file

@ -0,0 +1,94 @@
Digitized data copyright (c) 2012-2015, The Mozilla Foundation and Telefonica S.A.
with Reserved Font Name < Fira >,
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,94 @@
Copyright (c) 2010, Matt McInerney (matt@pixelspread.com),
Copyright (c) 2011, Pablo Impallari (www.impallari.com|impallari@gmail.com),
Copyright (c) 2011, Rodrigo Fuenzalida (www.rfuenzalida.com|hello@rfuenzalida.com), with Reserved Font Name Raleway
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Binary file not shown.

View file

@ -0,0 +1,93 @@
Copyright (c) 2009, Mark Simonson (http://www.ms-studio.com, mark@marksimonson.com),
with Reserved Font Name Anonymous Pro.
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View file

@ -0,0 +1,94 @@
Digitized data copyright (c) 2012-2015, The Mozilla Foundation and Telefonica S.A.
with Reserved Font Name < Fira >,
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Binary file not shown.

View file

@ -0,0 +1,94 @@
Copyright (c) 2010, Matt McInerney (matt@pixelspread.com),
Copyright (c) 2011, Pablo Impallari (www.impallari.com|impallari@gmail.com),
Copyright (c) 2011, Rodrigo Fuenzalida (www.rfuenzalida.com|hello@rfuenzalida.com), with Reserved Font Name Raleway
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,421 @@
@charset "UTF-8";
@font-face {
font-family: "hifi-glyphs";
src:url("fonts/hifi-glyphs.eot");
src:url("fonts/hifi-glyphs.eot?#iefix") format("embedded-opentype"),
url("fonts/hifi-glyphs.woff") format("woff"),
url("fonts/hifi-glyphs.ttf") format("truetype"),
url("fonts/hifi-glyphs.svg#hifi-glyphs") format("svg");
font-weight: normal;
font-style: normal;
}
[data-icon]:before {
font-family: "hifi-glyphs" !important;
content: attr(data-icon);
font-style: normal !important;
font-weight: normal !important;
font-variant: normal !important;
text-transform: none !important;
speak: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
[class^="icon-"]:before,
[class*=" icon-"]:before {
font-family: "hifi-glyphs" !important;
font-style: normal !important;
font-weight: normal !important;
font-variant: normal !important;
text-transform: none !important;
speak: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-hmd:before {
content: "\62";
}
.icon-2d-screen:before {
content: "\63";
}
.icon-keyboard:before {
content: "\64";
}
.icon-hand-controllers:before {
content: "\65";
}
.icon-headphones-mic:before {
content: "\66";
}
.icon-gamepad:before {
content: "\67";
}
.icon-headphones:before {
content: "\68";
}
.icon-mic:before {
content: "\69";
}
.icon-upload:before {
content: "\6a";
}
.icon-script:before {
content: "\6b";
}
.icon-text:before {
content: "\6c";
}
.icon-cube:before {
content: "\6d";
}
.icon-sphere:before {
content: "\6e";
}
.icon-zone:before {
content: "\6f";
}
.icon-light:before {
content: "\70";
}
.icon-web:before {
content: "\71";
}
.icon-web-2:before {
content: "\72";
}
.icon-edit:before {
content: "\73";
}
.icon-market:before {
content: "\74";
}
.icon-directory:before {
content: "\75";
}
.icon-menu:before {
content: "\76";
}
.icon-close:before {
content: "\77";
}
.icon-close-inverted:before {
content: "\78";
}
.icon-pin:before {
content: "\79";
}
.icon-pin-inverted:before {
content: "\7a";
}
.icon-resize-handle:before {
content: "\41";
}
.icon-diclosure-expand:before {
content: "\42";
}
.icon-reload-small:before {
content: "\61";
}
.icon-close-small:before {
content: "\43";
}
.icon-backward:before {
content: "\45";
}
.icon-reload:before {
content: "\46";
}
.icon-minimize:before {
content: "\49";
}
.icon-maximize:before {
content: "\4a";
}
.icon-maximize-inverted:before {
content: "\4b";
}
.icon-disclosure-button-expand:before {
content: "\4c";
}
.icon-disclosure-button-collapse:before {
content: "\4d";
}
.icon-script-stop:before {
content: "\4e";
}
.icon-script-reload:before {
content: "\4f";
}
.icon-script-run:before {
content: "\50";
}
.icon-script-new:before {
content: "\51";
}
.icon-hifi-forum:before {
content: "\32";
}
.icon-hifi-logo-small:before {
content: "\53";
}
.icon-avatar-1:before {
content: "\54";
}
.icon-placemark:before {
content: "\55";
}
.icon-box:before {
content: "\56";
}
.icon-community:before {
content: "\30";
}
.icon-grab-handle:before {
content: "\58";
}
.icon-search:before {
content: "\59";
}
.icon-disclosure-collapse:before {
content: "\5a";
}
.icon-script-upload:before {
content: "\52";
}
.icon-code:before {
content: "\57";
}
.icon-avatar:before {
content: "\3c";
}
.icon-arrows-h:before {
content: "\3a";
}
.icon-arrows-v:before {
content: "\3b";
}
.icon-arrows:before {
content: "\60";
}
.icon-compress:before {
content: "\21";
}
.icon-expand:before {
content: "\22";
}
.icon-placemark-1:before {
content: "\23";
}
.icon-circle:before {
content: "\24";
}
.icon-hand-pointer:before {
content: "\39";
}
.icon-plus-square-o:before {
content: "\25";
}
.icon-square:before {
content: "\27";
}
.icon-align-center:before {
content: "\38";
}
.icon-align-justify:before {
content: "\29";
}
.icon-align-left:before {
content: "\2a";
}
.icon-align-right:before {
content: "\5e";
}
.icon-bars:before {
content: "\37";
}
.icon-circle-slash:before {
content: "\2c";
}
.icon-sync:before {
content: "\28";
}
.icon-key:before {
content: "\2d";
}
.icon-link:before {
content: "\2e";
}
.icon-location:before {
content: "\2f";
}
.icon-carat-r:before {
content: "\33";
}
.icon-carat-l:before {
content: "\34";
}
.icon-folder-lg:before {
content: "\3e";
}
.icon-folder-sm:before {
content: "\3f";
}
.icon-level-up:before {
content: "\31";
}
.icon-info:before {
content: "\5b";
}
.icon-question:before {
content: "\5d";
}
.icon-alert:before {
content: "\2b";
}
.icon-home:before {
content: "\5f";
}
.icon-error:before {
content: "\3d";
}
.icon-settings:before {
content: "\40";
}
.icon-trash:before {
content: "\7b";
}
.icon-object-group:before {
content: "\e000";
}
.icon-cm:before {
content: "\7d";
}
.icon-msvg:before {
content: "\7e";
}
.icon-deg:before {
content: "\5c";
}
.icon-px:before {
content: "\7c";
}
.icon-m-sq:before {
content: "\e001";
}
.icon-m-cubed:before {
content: "\e002";
}
.icon-acceleration:before {
content: "\e003";
}
.icon-particles:before {
content: "\e004";
}
.icon-voxels:before {
content: "\e005";
}
.icon-lock:before {
content: "\e006";
}
.icon-visible:before {
content: "\e007";
}
.icon-model:before {
content: "\e008";
}
.icon-forward:before {
content: "\44";
}
.icon-avatar-2:before {
content: "\e009";
}
.icon-arrow-dn:before {
content: "\35";
}
.icon-arrow-up:before {
content: "\36";
}
.icon-time:before {
content: "\e00a";
}
.icon-transparency:before {
content: "\e00b";
}
.icon-unmuted:before {
content: "\47";
}
.icon-user:before {
content: "\e00c";
}
.icon-edit-pencil:before {
content: "\e00d";
}
.icon-muted:before {
content: "\48";
}
.icon-vol-0:before {
content: "\e00e";
}
.icon-vol-1:before {
content: "\e00f";
}
.icon-vol-2:before {
content: "\e010";
}
.icon-vol-3:before {
content: "\e011";
}
.icon-vol-4:before {
content: "\e012";
}
.icon-vol-x-0:before {
content: "\e013";
}
.icon-vol-x-1:before {
content: "\e014";
}
.icon-vol-x-2:before {
content: "\e015";
}
.icon-vol-x-3:before {
content: "\e016";
}
.icon-vol-x-4:before {
content: "\e017";
}
.icon-share-ext:before {
content: "\e018";
}
.icon-ellipsis:before {
content: "\e019";
}
.icon-check:before {
content: "\e01a";
}
.icon-sliders:before {
content: "\26";
}
.icon-polyline:before {
content: "\e01b";
}
.icon-source:before {
content: "\e01c";
}
.icon-playback-play:before {
content: "\e01d";
}
.icon-stop-square:before {
content: "\e01e";
}
.icon-avatar-t-pose:before {
content: "\e01f";
}
.icon-check-2-01:before {
content: "\e020";
}

View file

@ -0,0 +1,99 @@
"use strict";
//
// gemstoneMagicMaker.js
// tablet-sample-app
//
// Created by Faye Li on Feb 6 2017.
// Copyright 2017 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
(function() {
var TABLET_BUTTON_NAME = "TAA";
var QMLAPP_URL = Script.resolvePath("./Antialiasing.qml");
var onLuciScreen = false;
function onClicked() {
if (onLuciScreen) {
tablet.gotoHomeScreen();
} else {
tablet.loadQMLSource(QMLAPP_URL);
}
}
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
var button = tablet.addButton({
text: TABLET_BUTTON_NAME,
sortOrder: 1
});
var hasEventBridge = false;
function wireEventBridge(on) {
if (!tablet) {
print("Warning in wireEventBridge(): 'tablet' undefined!");
return;
}
if (on) {
if (!hasEventBridge) {
tablet.fromQml.connect(fromQml);
hasEventBridge = true;
}
} else {
if (hasEventBridge) {
tablet.fromQml.disconnect(fromQml);
hasEventBridge = false;
}
}
}
function onScreenChanged(type, url) {
if (url === QMLAPP_URL) {
onLuciScreen = true;
} else {
onLuciScreen = false;
}
button.editProperties({isActive: onLuciScreen});
wireEventBridge(onLuciScreen);
}
function fromQml(message) {
}
button.clicked.connect(onClicked);
tablet.screenChanged.connect(onScreenChanged);
var moveDebugCursor = false;
Controller.mousePressEvent.connect(function (e) {
if (e.isMiddleButton) {
moveDebugCursor = true;
setDebugCursor(e.x, e.y);
}
});
Controller.mouseReleaseEvent.connect(function() { moveDebugCursor = false; });
Controller.mouseMoveEvent.connect(function (e) { if (moveDebugCursor) setDebugCursor(e.x, e.y); });
Script.scriptEnding.connect(function () {
if (onLuciScreen) {
tablet.gotoHomeScreen();
}
button.clicked.disconnect(onClicked);
tablet.screenChanged.disconnect(onScreenChanged);
tablet.removeButton(button);
});
function setDebugCursor(x, y) {
nx = ((x + 0.5) / Window.innerWidth);
ny = 1.0 - ((y + 0.5) / (Window.innerHeight));
Render.getConfig("RenderMainView").getConfig("Antialiasing").debugCursorTexcoord = { x: nx, y: ny };
}
}());

View file

@ -0,0 +1,208 @@
//
// Antialiasing.qml
//
// Created by Sam Gateau on 8/14/2017
// Copyright 2016 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3
import "../lib/styles-uit"
import "../lib/controls-uit" as HifiControls
import "configSlider"
import "../lib/plotperf"
Item {
Rectangle {
id: root;
HifiConstants { id: hifi; }
color: hifi.colors.baseGray;
Column {
id: antialiasing
spacing: 20
padding: 10
Column{
spacing: 10
Row {
spacing: 10
id: fxaaOnOff
property bool debugFXAA: false
HifiControls.Button {
text: {
if (fxaaOnOff.debugFXAA) {
return "FXAA"
} else {
return "TAA"
}
}
onClicked: {
fxaaOnOff.debugFXAA = !fxaaOnOff.debugFXAA
if (fxaaOnOff.debugFXAA) {
Render.getConfig("RenderMainView.JitterCam").none();
Render.getConfig("RenderMainView.Antialiasing").debugFXAAX = 0;
} else {
Render.getConfig("RenderMainView.JitterCam").play();
Render.getConfig("RenderMainView.Antialiasing").debugFXAAX = 1.0;
}
}
}
}
Separator {}
Row {
spacing: 10
HifiControls.Button {
text: {
var state = 2 - (Render.getConfig("RenderMainView.JitterCam").freeze * 1 - Render.getConfig("RenderMainView.JitterCam").stop * 2);
if (state === 2) {
return "Jitter"
} else if (state === 1) {
return "Paused at " + Render.getConfig("RenderMainView.JitterCam").index + ""
} else {
return "No Jitter"
}
}
onClicked: { Render.getConfig("RenderMainView.JitterCam").cycleStopPauseRun(); }
}
HifiControls.Button {
text: "<"
onClicked: { Render.getConfig("RenderMainView.JitterCam").prev(); }
}
HifiControls.Button {
text: ">"
onClicked: { Render.getConfig("RenderMainView.JitterCam").next(); }
}
}
Row {
spacing: 10
HifiControls.CheckBox {
boxSize: 20
text: "Unjitter"
checked: Render.getConfig("RenderMainView.Antialiasing")["unjitter"]
onCheckedChanged: { Render.getConfig("RenderMainView.Antialiasing")["unjitter"] = checked }
}
HifiControls.CheckBox {
boxSize: 20
text: "Show Sequence"
checked: Render.getConfig("RenderMainView.Antialiasing")["showJitterSequence"]
onCheckedChanged: { Render.getConfig("RenderMainView.Antialiasing")["showJitterSequence"] = checked }
}
}
Separator {}
Column {
spacing: 10
Row {
spacing: 10
HifiControls.CheckBox {
boxSize: 20
text: "Constrain color"
checked: Render.getConfig("RenderMainView.Antialiasing")["constrainColor"]
onCheckedChanged: { Render.getConfig("RenderMainView.Antialiasing")["constrainColor"] = checked }
}
Column {
spacing: 10
HifiControls.CheckBox {
boxSize: 20
text: "Covariance Min Max"
checked: Render.getConfig("RenderMainView.Antialiasing")["covarianceClipColor"]
onCheckedChanged: { Render.getConfig("RenderMainView.Antialiasing")["covarianceClipColor"] = checked }
}
HifiControls.CheckBox {
boxSize: 20
text: "Clip exact color"
checked: Render.getConfig("RenderMainView.Antialiasing")["clipExactColor"]
onCheckedChanged: { Render.getConfig("RenderMainView.Antialiasing")["clipExactColor"] = checked }
}
}
}
HifiControls.ConfigSlider {
label: qsTr("Covariance gamma")
integral: false
config: Render.getConfig("RenderMainView.Antialiasing")
property: "covarianceGamma"
max: 1.5
min: 0.5
}
Separator {}
HifiControls.CheckBox {
boxSize: 20
text: "Feedback history color"
checked: Render.getConfig("RenderMainView.Antialiasing")["feedbackColor"]
onCheckedChanged: { Render.getConfig("RenderMainView.Antialiasing")["feedbackColor"] = checked }
}
HifiControls.ConfigSlider {
label: qsTr("Source blend")
integral: false
config: Render.getConfig("RenderMainView.Antialiasing")
property: "blend"
max: 1.0
min: 0.0
}
}
Separator {}
Row {
spacing: 10
HifiControls.CheckBox {
boxSize: 20
text: "Debug"
checked: Render.getConfig("RenderMainView.Antialiasing")["debug"]
onCheckedChanged: { Render.getConfig("RenderMainView.Antialiasing")["debug"] = checked }
}
HifiControls.CheckBox {
boxSize: 20
text: "Show Debug Cursor"
checked: Render.getConfig("RenderMainView.Antialiasing")["showCursorPixel"]
onCheckedChanged: { Render.getConfig("RenderMainView.Antialiasing")["showCursorPixel"] = checked }
}
}
HifiControls.ConfigSlider {
label: qsTr("Debug Region <")
integral: false
config: Render.getConfig("RenderMainView.Antialiasing")
property: "debugX"
max: 1.0
min: 0.0
}
HifiControls.CheckBox {
boxSize: 20
text: "Closest Fragment"
checked: Render.getConfig("RenderMainView.Antialiasing")["showClosestFragment"]
onCheckedChanged: { Render.getConfig("RenderMainView.Antialiasing")["showClosestFragment"] = checked }
}
HifiControls.ConfigSlider {
label: qsTr("Debug Velocity Threshold [pix]")
integral: false
config: Render.getConfig("RenderMainView.Antialiasing")
property: "debugShowVelocityThreshold"
max: 50
min: 0.0
}
HifiControls.ConfigSlider {
label: qsTr("Debug Orb Zoom")
integral: false
config: Render.getConfig("RenderMainView.Antialiasing")
property: "debugOrbZoom"
max: 32.0
min: 1.0
}
}
}
}
}