Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VkCV Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vulkan2021
VkCV Framework
Commits
b01d16c2
Commit
b01d16c2
authored
3 years ago
by
Alexander Gauggel
Browse files
Options
Downloads
Patches
Plain Diff
[
#106
] Add motion blur mirrored background reconstruction from Jimenez paper
parent
dd3a67ea
No related branches found
No related tags found
1 merge request
!89
Resolve "Indirect Dispatch"
Pipeline
#26850
passed
3 years ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
projects/indirect_dispatch/resources/shaders/motionBlur.comp
+38
-9
38 additions, 9 deletions
projects/indirect_dispatch/resources/shaders/motionBlur.comp
with
38 additions
and
9 deletions
projects/indirect_dispatch/resources/shaders/motionBlur.comp
+
38
−
9
View file @
b01d16c2
...
...
@@ -175,21 +175,50 @@ void main(){
// the sampleUV code expects an offset in range [-0.5, 0.5], so the dither is rescaled to a binary -0.25/0.25
float random = dither(coord) * 0.5 - 0.25;
const int sampleCount =
15
;
const int sampleCount
Half
=
8
;
for(int i = 0; i < sampleCount; i++){
vec2 sampleUV = mix(uvStart, uvEnd, (i + random + 1) / float(sampleCount + 1));
// two samples are processed at a time to allow for mirrored background reconstruction
for(int i = 0; i < sampleCountHalf; i++){
SampleData samplePixel = loadSampleD
at
a
(sample
UV
);
float weightSample = computeSampleWeigth(mainPixel, samplePixel
);
vec2 sampleUV1 = mix(uv, uvEnd, (i + random + 1) / flo
at(sample
CountHalf + 1)
);
vec2 sampleUV2 = mix(uv, uvStart, (i + random + 1) / float(sampleCountHalf + 1)
);
weightSum += weightSample;
color += samplePixel.color * weightSample;
SampleData sample1 = loadSampleData(sampleUV1);
SampleData sample2 = loadSampleData(sampleUV2);
float weight1 = computeSampleWeigth(mainPixel, sample1);
float weight2 = computeSampleWeigth(mainPixel, sample2);
bool mirroredBackgroundReconstruction = true;
if(mirroredBackgroundReconstruction){
// see Jimenez paper for details and comparison
// problem is that in the foreground the background is reconstructed, which is blurry
// in the background the background is obviously known, so it is sharper
// at the border between fore- and background this causes a discontinuity
// to fix this the weights are mirrored on this border, effectively reconstructing the background, even though it is known
// these bools check if sample1 is an affected background pixel (further away and slower moving than sample2)
bool inBackground = sample1.depthLinear > sample2.depthLinear;
bool blurredOver = sample1.velocityPixels < sample2.velocityPixels;
// this mirrors the weights depending on the results:
// if both conditions are true, then weight2 is mirrored to weight1
// if both conditions are false, then weight1 is mirrored to weight2, as sample2 is an affected background pixel
// if only one condition is true, then the weights are kept as is
weight1 = inBackground && blurredOver ? weight2 : weight1;
weight2 = inBackground || blurredOver ? weight2 : weight1;
}
weightSum += weight1;
weightSum += weight2;
color += sample1.color * weight1;
color += sample2.color * weight2;
}
// normalize color and weight
weightSum /= sampleCount;
color /= sampleCount;
weightSum /= sampleCount
Half * 2
;
color /= sampleCount
Half * 2
;
// the main color is considered the background
// the weight sum can be interpreted as the alpha of the combined samples, see Jimenez paper
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment