mirror of
https://github.com/lubosz/overte.git
synced 2025-04-15 19:47:38 +02:00
Refining the debugging to better understand the issues
This commit is contained in:
parent
7d8356686c
commit
66d35118cb
7 changed files with 111 additions and 23 deletions
|
@ -287,6 +287,7 @@ void Antialiasing::configure(const Config& config) {
|
|||
_params.edit().velocityScale = config.velocityScale;
|
||||
|
||||
_params.edit().setUnjitter(config.unjitter);
|
||||
_params.edit().setConstrainColor(config.constrainColor);
|
||||
|
||||
_params.edit().debugShowVelocityThreshold = config.debugShowVelocityThreshold;
|
||||
|
||||
|
@ -380,6 +381,34 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
void JitterSampleConfig::setIndex(int current) {
|
||||
_index = (current) % JitterSample::SampleSequence::SEQUENCE_LENGTH;
|
||||
emit dirty();
|
||||
}
|
||||
|
||||
int JitterSampleConfig::pause() {
|
||||
freeze = true;
|
||||
emit dirty();
|
||||
return _index;
|
||||
}
|
||||
|
||||
int JitterSampleConfig::prev() {
|
||||
setIndex(_index - 1);
|
||||
return _index;
|
||||
}
|
||||
|
||||
int JitterSampleConfig::next() {
|
||||
setIndex(_index + 1);
|
||||
return _index;
|
||||
}
|
||||
|
||||
int JitterSampleConfig::play() {
|
||||
freeze = false;
|
||||
emit dirty();
|
||||
return _index;
|
||||
}
|
||||
|
||||
JitterSample::SampleSequence::SampleSequence(){
|
||||
// Halton sequence (2,3)
|
||||
offsets[0] = { 1.0f / 2.0f, 1.0f / 3.0f };
|
||||
|
@ -398,6 +427,12 @@ JitterSample::SampleSequence::SampleSequence(){
|
|||
|
||||
void JitterSample::configure(const Config& config) {
|
||||
_freeze = config.freeze;
|
||||
if (_freeze) {
|
||||
auto pausedIndex = config.getIndex();
|
||||
if (_jitterBuffer->currentIndex != pausedIndex) {
|
||||
_jitterBuffer.edit().currentIndex = pausedIndex;
|
||||
}
|
||||
}
|
||||
_scale = config.scale;
|
||||
}
|
||||
void JitterSample::run(const render::RenderContextPointer& renderContext, JitterBuffer& jitterBuffer) {
|
||||
|
|
|
@ -23,13 +23,29 @@ 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(int index READ getIndex NOTIFY dirty)
|
||||
public:
|
||||
JitterSampleConfig() : render::Job::Config(true) {}
|
||||
|
||||
float scale{ 0.5f };
|
||||
bool freeze{ false };
|
||||
|
||||
void setIndex(int current);
|
||||
|
||||
public slots:
|
||||
int pause();
|
||||
int prev();
|
||||
int next();
|
||||
int play();
|
||||
|
||||
int getIndex() const { return _index; }
|
||||
|
||||
signals:
|
||||
void dirty();
|
||||
|
||||
private:
|
||||
int _index{ 0 };
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -68,6 +84,7 @@ class AntialiasingConfig : public render::Job::Config {
|
|||
Q_PROPERTY(float velocityScale MEMBER velocityScale NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(bool unjitter MEMBER unjitter NOTIFY dirty)
|
||||
Q_PROPERTY(bool constrainColor MEMBER constrainColor NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(bool debug MEMBER debug NOTIFY dirty)
|
||||
Q_PROPERTY(float debugX MEMBER debugX NOTIFY dirty)
|
||||
|
@ -91,6 +108,7 @@ public:
|
|||
float debugOrbZoom{ 2.0f };
|
||||
|
||||
bool unjitter{ true };
|
||||
bool constrainColor{ true };
|
||||
|
||||
bool debug { false };
|
||||
bool showCursorPixel { false };
|
||||
|
@ -116,6 +134,8 @@ struct TAAParams {
|
|||
void setUnjitter(bool enabled) { SET_BIT(debug.y, 0, enabled); }
|
||||
bool isUnjitter() const { return (bool)GET_BIT(debug.y, 0); }
|
||||
|
||||
void setConstrainColor(bool enabled) { SET_BIT(debug.y, 1, enabled); }
|
||||
bool isConstrainColor() const { return (bool)GET_BIT(debug.y, 1); }
|
||||
|
||||
void setDebug(bool enabled) { SET_BIT(debug.x, 0, enabled); }
|
||||
bool isDebug() const { return (bool) GET_BIT(debug.x, 0); }
|
||||
|
|
|
@ -20,12 +20,14 @@ layout(location = 0) out vec4 outFragColor;
|
|||
|
||||
void main() {
|
||||
vec2 texelSize = getInvWidthHeight();
|
||||
vec2 fragUV = varTexCoord0 - float(taa_unjitter()) * taa_getJitterSample(sequence.currentIndex) * texelSize;
|
||||
vec2 fragUV = varTexCoord0;
|
||||
if (taa_unjitter()) {
|
||||
fragUV -= taa_getJitterSample(sequence.currentIndex) * texelSize;
|
||||
}
|
||||
|
||||
vec3 nearFragUV = taa_findClosestFragment3x3(fragUV);
|
||||
vec2 fragVel = taa_fetchVelocityMap(nearFragUV.xy);
|
||||
|
||||
|
||||
/*vec3 sourceColor;
|
||||
vec3 historyColor;
|
||||
vec2 prevFragUV = taa_fetchSourceAndHistory(fragUV, fragVel, sourceColor, historyColor);
|
||||
|
|
|
@ -67,7 +67,9 @@ bool taa_showClosestFragment() {
|
|||
bool taa_unjitter() {
|
||||
return GET_BIT(params.debug.y, 0);
|
||||
}
|
||||
|
||||
bool taa_constrainColor() {
|
||||
return GET_BIT(params.debug.y, 1);
|
||||
}
|
||||
|
||||
vec2 taa_getDebugCursorTexcoord() {
|
||||
return params.pixelInfo_orbZoom.xy;
|
||||
|
@ -191,7 +193,10 @@ vec3 taa_temporalReprojection(vec2 fragUV, vec2 fragVelocity, float fragZe)
|
|||
|
||||
vec2 imageSize = getWidthHeight(0);
|
||||
vec2 texelSize = getInvWidthHeight();
|
||||
fragUV += float(taa_unjitter()) * taa_getJitterSample(sequence.currentIndex) * texelSize;
|
||||
|
||||
if (taa_unjitter()) {
|
||||
fragUV += taa_getJitterSample(sequence.currentIndex) * texelSize;
|
||||
}
|
||||
|
||||
const float _SubpixelThreshold = 0.5;
|
||||
const float _GatherBase = 0.5;
|
||||
|
@ -249,10 +254,11 @@ vec3 taa_temporalReprojection(vec2 fragUV, vec2 fragVelocity, float fragZe)
|
|||
float k_feedback = mix(_FeedbackMin, _FeedbackMax, unbiased_weight_sqr);
|
||||
|
||||
// output
|
||||
vec3 nextColor = mix(texel1, texel0, k_feedback).xyz;
|
||||
vec3 nextColor = mix(texel1, texel0, k_feedback).xyz;
|
||||
|
||||
|
||||
// vec3 nextColor = mix(texel0, texel1, params.blend);
|
||||
if (!taa_constrainColor()) {
|
||||
nextColor = mix(historyColor, sourceColor, params.blend);
|
||||
}
|
||||
|
||||
return taa_resolveColor(nextColor);
|
||||
}
|
||||
|
|
|
@ -73,17 +73,19 @@ void main(void) {
|
|||
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 < 2.0) {
|
||||
if (prevOrbPosToPixLength < orbPixThreshold) {
|
||||
preOrbColor = vec3(1.0, 0.0, 1.0);
|
||||
}
|
||||
float distanceToNext = length(imageSize * (cursorUV - prevOrbPosToPix_uv));
|
||||
if (distanceToNext < 2.0) {
|
||||
if (distanceToNext < orbPixThreshold) {
|
||||
preOrbColor = vec3(1.0, 0.5, 0.0);
|
||||
}
|
||||
outFragColor = vec4(preOrbColor, 1.0);
|
||||
|
@ -96,10 +98,10 @@ void main(void) {
|
|||
nextOrbColor = texture(nextMap, nextOrbPosToPix_uv).xyz;
|
||||
}
|
||||
float distanceToPrev = length(imageSize * (cursorPrevUV - nextOrbPosToPix_uv));
|
||||
if (distanceToPrev < 2.0) {
|
||||
if (distanceToPrev < orbPixThreshold) {
|
||||
nextOrbColor = vec3(1.0, 0.0, 1.0);
|
||||
}
|
||||
if (nextOrbPosToPixLength < 2.0) {
|
||||
if (nextOrbPosToPixLength < orbPixThreshold) {
|
||||
nextOrbColor = vec3(1.0, 0.5, 0.0);
|
||||
}
|
||||
|
||||
|
@ -114,13 +116,14 @@ void main(void) {
|
|||
vec2 jitterRegionPos = (pixPos - vec2(tenPercentHeight, imageSize.y - tenPercentHeight));
|
||||
if ((all(lessThan(jitterRegionPos, jitterRegionSize)) && all(greaterThan(jitterRegionPos, vec2(0.0))))) {
|
||||
|
||||
float niceDotR2 = 4;
|
||||
float niceDotR2 = 4.0;
|
||||
|
||||
for (int s = 0; s < SEQUENCE_LENGTH; s++) {
|
||||
vec2 pixToSampleVec = jitterRegionPos - (vec2(0.5) + taa_getJitterSample(s)) * jitterRegionSize;
|
||||
float radius2 = (s == sequence.currentIndex ? 2.0 * niceDotR2 : niceDotR2);
|
||||
if (dot(pixToSampleVec, pixToSampleVec) < radius2) {
|
||||
outFragColor = vec4(colorRamp(float(s) / float(SEQUENCE_LENGTH)), 1.0);
|
||||
float radius2 = (s == sequence.currentIndex ? 4.0 * niceDotR2 : niceDotR2);
|
||||
float distToSample2 = dot(pixToSampleVec, pixToSampleVec);
|
||||
if (distToSample2 < radius2) {
|
||||
outFragColor = vec4(mix( outFragColor.rgb, colorRamp(float(s) / float(SEQUENCE_LENGTH)), 1.0 - distToSample2 / radius2), 1.0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -30,6 +30,8 @@ Rectangle {
|
|||
spacing: 20
|
||||
|
||||
Column{
|
||||
spacing: 10
|
||||
|
||||
ConfigSlider {
|
||||
label: qsTr("Source blend")
|
||||
integral: false
|
||||
|
@ -47,11 +49,36 @@ Rectangle {
|
|||
min: 0.0
|
||||
}
|
||||
Row {
|
||||
spacing: 10
|
||||
CheckBox {
|
||||
text: "Unjitter"
|
||||
checked: Render.getConfig("RenderMainView.Antialiasing")["unjitter"]
|
||||
onCheckedChanged: { Render.getConfig("RenderMainView.Antialiasing")["unjitter"] = checked }
|
||||
}
|
||||
CheckBox {
|
||||
text: "Freeze "
|
||||
checked: Render.getConfig("RenderMainView.JitterCam")["freeze"]
|
||||
onCheckedChanged: { Render.getConfig("RenderMainView.JitterCam")["freeze"] = checked }
|
||||
}
|
||||
Text {
|
||||
text: Render.getConfig("RenderMainView.JitterCam").index
|
||||
}
|
||||
Button {
|
||||
text: "<"
|
||||
onClicked: { Render.getConfig("RenderMainView.JitterCam").prev(); }
|
||||
}
|
||||
Button {
|
||||
text: ">"
|
||||
onClicked: { Render.getConfig("RenderMainView.JitterCam").next(); }
|
||||
}
|
||||
}
|
||||
Row {
|
||||
spacing: 10
|
||||
CheckBox {
|
||||
text: "Constrain color"
|
||||
checked: Render.getConfig("RenderMainView.Antialiasing")["constrainColor"]
|
||||
onCheckedChanged: { Render.getConfig("RenderMainView.Antialiasing")["constrainColor"] = checked }
|
||||
}
|
||||
}
|
||||
Row {
|
||||
CheckBox {
|
||||
|
@ -59,11 +86,6 @@ Rectangle {
|
|||
checked: Render.getConfig("RenderMainView.Antialiasing")["debug"]
|
||||
onCheckedChanged: { Render.getConfig("RenderMainView.Antialiasing")["debug"] = checked }
|
||||
}
|
||||
CheckBox {
|
||||
text: "Freeze "
|
||||
checked: Render.getConfig("RenderMainView.JitterCam")["freeze"]
|
||||
onCheckedChanged: { Render.getConfig("RenderMainView.JitterCam")["freeze"] = checked }
|
||||
}
|
||||
CheckBox {
|
||||
text: "Show Debug Cursor"
|
||||
checked: Render.getConfig("RenderMainView.Antialiasing")["showCursorPixel"]
|
||||
|
@ -85,7 +107,7 @@ Rectangle {
|
|||
onCheckedChanged: { Render.getConfig("RenderMainView.Antialiasing")["showJitterSequence"] = checked }
|
||||
}
|
||||
CheckBox {
|
||||
text: "CLosest Fragment"
|
||||
text: "Closest Fragment"
|
||||
checked: Render.getConfig("RenderMainView.Antialiasing")["showClosestFragment"]
|
||||
onCheckedChanged: { Render.getConfig("RenderMainView.Antialiasing")["showClosestFragment"] = checked }
|
||||
}
|
||||
|
@ -103,8 +125,8 @@ Rectangle {
|
|||
integral: false
|
||||
config: Render.getConfig("RenderMainView.Antialiasing")
|
||||
property: "debugOrbZoom"
|
||||
max: 8.0
|
||||
min: 0.0
|
||||
max: 32.0
|
||||
min: 1.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue