mirror of
https://github.com/lubosz/overte.git
synced 2025-04-26 19:35:48 +02:00
Adding more debug and saving th emotion blur as pixel size, not uv
This commit is contained in:
parent
d6e0fd758f
commit
65ab2ce90d
5 changed files with 63 additions and 18 deletions
libraries/render-utils/src
|
@ -207,6 +207,8 @@ const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline() {
|
|||
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("historyMap"), AntialiasingPass_HistoryMapSlot));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("colorMap"), AntialiasingPass_SourceMapSlot));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("velocityMap"), AntialiasingPass_VelocityMapSlot));
|
||||
|
@ -278,6 +280,14 @@ void Antialiasing::configure(const Config& config) {
|
|||
_params.edit().blend = config.blend;
|
||||
_params.edit().velocityScale = config.velocityScale;
|
||||
_params.edit().debugShowVelocityThreshold = config.debugShowVelocityThreshold;
|
||||
|
||||
_params.edit().debugCursor.x = config.showCursorPixel;
|
||||
|
||||
auto cursorPos = glm::vec2(_params->pixelInfo);
|
||||
if (cursorPos != config.debugCursorTexcoord) {
|
||||
_params.edit().pixelInfo = glm::vec4(config.debugCursorTexcoord, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -350,7 +360,6 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const
|
|||
batch.setResourceTexture(AntialiasingPass_SourceMapSlot, nullptr);
|
||||
batch.setResourceTexture(AntialiasingPass_VelocityMapSlot, nullptr);
|
||||
batch.setResourceTexture(AntialiasingPass_CurrentMapSlot, nullptr);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,8 @@ class AntialiasingConfig : public render::Job::Config {
|
|||
Q_PROPERTY(float blend MEMBER blend NOTIFY dirty)
|
||||
Q_PROPERTY(float velocityScale MEMBER velocityScale 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)
|
||||
public:
|
||||
AntialiasingConfig() : render::Job::Config(true) {}
|
||||
|
||||
|
@ -33,6 +34,9 @@ public:
|
|||
float velocityScale{ 1.0f };
|
||||
float debugShowVelocityThreshold{ 1.0f };
|
||||
|
||||
bool showCursorPixel{ false };
|
||||
glm::vec2 debugCursorTexcoord{ 0.5f, 0.5f };
|
||||
|
||||
signals:
|
||||
void dirty();
|
||||
};
|
||||
|
@ -44,6 +48,9 @@ struct TAAParams {
|
|||
float velocityScale{ 1.0f };
|
||||
float debugShowVelocityThreshold{ 1.0f };
|
||||
|
||||
glm::vec4 debugCursor{ 0.0f };
|
||||
glm::vec4 pixelInfo{ 0.5f, 0.5f, 0.0f, 0.0f };
|
||||
|
||||
};
|
||||
using TAAParamsBuffer = gpu::StructBuffer<TAAParams>;
|
||||
|
||||
|
@ -62,9 +69,6 @@ public:
|
|||
const gpu::PipelinePointer& getBlendPipeline();
|
||||
const gpu::PipelinePointer& getDebugBlendPipeline();
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Uniforms for AA
|
||||
|
@ -81,6 +85,7 @@ private:
|
|||
int _currentFrame{ 0 };
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
class AntiAliasingConfig : public render::Job::Config {
|
||||
Q_OBJECT
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
//
|
||||
|
||||
|
||||
<@include DeferredTransform.slh@>
|
||||
<$declareDeferredFrameTransform()$>
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
|
@ -40,10 +43,9 @@ layout(std140) uniform taaParamsBuffer {
|
|||
void main() {
|
||||
vec3 currentColor = texture(colorMap, varTexCoord0).xyz;
|
||||
|
||||
vec2 rawVelocity = texture(velocityMap, varTexCoord0).xy;
|
||||
|
||||
vec2 velocity = rawVelocity;
|
||||
vec2 prevTexCoord = varTexCoord0 - params.motionScale * velocity;
|
||||
vec2 pixVelocity = texture(velocityMap, varTexCoord0).xy;
|
||||
vec2 velocity = params.motionScale * pixVelocity * getInvWidthHeight();
|
||||
vec2 prevTexCoord = varTexCoord0 - velocity;
|
||||
|
||||
vec3 prevColor = currentColor;
|
||||
|
||||
|
|
|
@ -30,29 +30,57 @@ struct TAAParams
|
|||
float blend;
|
||||
float motionScale;
|
||||
float debugShowVelocityThreshold;
|
||||
vec4 debugCursor;
|
||||
vec4 pixelInfo;
|
||||
};
|
||||
|
||||
layout(std140) uniform taaParamsBuffer {
|
||||
TAAParams params;
|
||||
};
|
||||
|
||||
vec2 getDebugCursorTexcoord() {
|
||||
return params.pixelInfo.xy;
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
vec3 newColor = texture(currentMap, varTexCoord0).xyz;
|
||||
outFragColor = vec4(newColor, 1.0);
|
||||
|
||||
if (varTexCoord0.x > params.debugX) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Pixel being shaded
|
||||
vec3 sourceColor = texture(colorMap, varTexCoord0).xyz;
|
||||
|
||||
vec2 velocity = texture(velocityMap, varTexCoord0).xy;
|
||||
vec2 pixelVelocity = velocity * getWidthHeight(0);
|
||||
vec2 prevTexCoord = varTexCoord0 - params.motionScale * velocity;
|
||||
vec2 imageSize = getWidthHeight(0);
|
||||
|
||||
vec2 pixPos = varTexCoord0 * imageSize;
|
||||
vec2 pixVelocity = texture(velocityMap, varTexCoord0).xy;
|
||||
vec2 velocity = params.motionScale * pixVelocity * getInvWidthHeight();
|
||||
vec2 prevTexCoord = varTexCoord0 - velocity;
|
||||
vec2 prevPix = prevTexCoord * imageSize;
|
||||
|
||||
outFragColor = vec4(sourceColor, 1.0);
|
||||
|
||||
// Pixel Debugged
|
||||
vec2 cursorUV = getDebugCursorTexcoord();
|
||||
vec2 cursorPixelPos = cursorUV * imageSize;
|
||||
vec2 cursorVelocity = texture(velocityMap, cursorUV).xy;
|
||||
float cursorVelocityLength = length(cursorVelocity);
|
||||
|
||||
vec2 cursorToFragVec = pixPos - cursorPixelPos;
|
||||
float cursorToFragLength = length(cursorToFragVec);
|
||||
|
||||
if (cursorToFragLength <= cursorVelocityLength) {
|
||||
vec2 cursorVelocityDir = cursorVelocity / cursorVelocityLength;
|
||||
|
||||
if (abs(dot(cursorVelocityDir, cursorToFragVec)) < 3.0) {
|
||||
outFragColor = vec4(0.5, 1.0, 1.0, 1.0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (varTexCoord0.x > params.debugX) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (abs(varTexCoord0.x - params.debugX) < getInvWidthHeight().x) {
|
||||
outFragColor.rgb = vec3(1.0, 1.0, 0.0);
|
||||
return;
|
||||
|
@ -65,7 +93,7 @@ void main(void) {
|
|||
}
|
||||
outFragColor.xyz = prevColor;
|
||||
|
||||
if (dot(pixelVelocity, pixelVelocity) > (params.debugShowVelocityThreshold * params.debugShowVelocityThreshold)) {
|
||||
if (dot(pixVelocity, pixVelocity) > (params.debugShowVelocityThreshold * params.debugShowVelocityThreshold)) {
|
||||
outFragColor = vec4(0.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,5 +40,6 @@ void main(void) {
|
|||
vec4 prevClipPos = (frameTransform._projection[stereoSide.x] * vec4(prevEyePos, 1.0));
|
||||
vec2 prevUV = 0.5 * (prevClipPos.xy / prevClipPos.w) + vec2(0.5);
|
||||
|
||||
outFragColor = vec4( ((texcoordPos - prevUV)), 0.0, 0.0);
|
||||
vec2 imageSize = getWidthHeight(0);
|
||||
outFragColor = vec4( ((texcoordPos - prevUV) * imageSize), 0.0, 0.0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue