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
Merge requests
!89
Resolve "Indirect Dispatch"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Indirect Dispatch"
106-indirect-dispatch
into
develop
Overview
2
Commits
58
Pipelines
45
Changes
34
Merged
Ghost User
requested to merge
106-indirect-dispatch
into
develop
3 years ago
Overview
1
Commits
58
Pipelines
45
Changes
5
Expand
Closes
#106 (closed)
Edited
3 years ago
by
Ghost User
0
0
Merge request reports
Compare
version 13
version 43
a8a1ac35
3 years ago
version 42
df9b1274
3 years ago
version 41
0940a458
3 years ago
version 40
3c2a5543
3 years ago
version 39
0af7fdb8
3 years ago
version 38
cbbd528e
3 years ago
version 37
a8b06ccf
3 years ago
version 36
06c23ba7
3 years ago
version 35
3e563900
3 years ago
version 34
d3c4a125
3 years ago
version 33
b01d16c2
3 years ago
version 32
dd3a67ea
3 years ago
version 31
17e3458b
3 years ago
version 30
47c79462
3 years ago
version 29
598c348c
3 years ago
version 28
9d0c4b86
3 years ago
version 27
d0073d09
3 years ago
version 26
3d19a3cd
3 years ago
version 25
0bc597bb
3 years ago
version 24
d4066ff3
3 years ago
version 23
7aded7d5
3 years ago
version 22
a43d5f81
3 years ago
version 21
de2c73f3
3 years ago
version 20
f1e06018
3 years ago
version 19
02fd8f79
3 years ago
version 18
b5f28798
3 years ago
version 17
51330d76
3 years ago
version 16
c0719894
3 years ago
version 15
a82d4018
3 years ago
version 14
7a78a501
3 years ago
version 13
eabfdb7b
3 years ago
version 12
1c54fe17
3 years ago
version 11
2ccb059f
3 years ago
version 10
21502286
3 years ago
version 9
898a2709
3 years ago
version 8
2afcd5fa
3 years ago
version 7
df8a0038
3 years ago
version 6
a8a3b210
3 years ago
version 5
0fa26d45
3 years ago
version 4
31de9c08
3 years ago
version 3
401ed7ad
3 years ago
version 2
fe4da00f
3 years ago
version 1
220d58d8
3 years ago
develop (base)
and
version 16
latest version
958588c6
58 commits,
3 years ago
version 43
a8a1ac35
55 commits,
3 years ago
version 42
df9b1274
54 commits,
3 years ago
version 41
0940a458
53 commits,
3 years ago
version 40
3c2a5543
52 commits,
3 years ago
version 39
0af7fdb8
51 commits,
3 years ago
version 38
cbbd528e
49 commits,
3 years ago
version 37
a8b06ccf
48 commits,
3 years ago
version 36
06c23ba7
47 commits,
3 years ago
version 35
3e563900
46 commits,
3 years ago
version 34
d3c4a125
45 commits,
3 years ago
version 33
b01d16c2
44 commits,
3 years ago
version 32
dd3a67ea
43 commits,
3 years ago
version 31
17e3458b
42 commits,
3 years ago
version 30
47c79462
41 commits,
3 years ago
version 29
598c348c
40 commits,
3 years ago
version 28
9d0c4b86
39 commits,
3 years ago
version 27
d0073d09
38 commits,
3 years ago
version 26
3d19a3cd
37 commits,
3 years ago
version 25
0bc597bb
35 commits,
3 years ago
version 24
d4066ff3
34 commits,
3 years ago
version 23
7aded7d5
33 commits,
3 years ago
version 22
a43d5f81
32 commits,
3 years ago
version 21
de2c73f3
31 commits,
3 years ago
version 20
f1e06018
30 commits,
3 years ago
version 19
02fd8f79
28 commits,
3 years ago
version 18
b5f28798
27 commits,
3 years ago
version 17
51330d76
24 commits,
3 years ago
version 16
c0719894
23 commits,
3 years ago
version 15
a82d4018
19 commits,
3 years ago
version 14
7a78a501
18 commits,
3 years ago
version 13
eabfdb7b
17 commits,
3 years ago
version 12
1c54fe17
16 commits,
3 years ago
version 11
2ccb059f
15 commits,
3 years ago
version 10
21502286
13 commits,
3 years ago
version 9
898a2709
12 commits,
3 years ago
version 8
2afcd5fa
11 commits,
3 years ago
version 7
df8a0038
10 commits,
3 years ago
version 6
a8a3b210
7 commits,
3 years ago
version 5
0fa26d45
5 commits,
3 years ago
version 4
31de9c08
4 commits,
3 years ago
version 3
401ed7ad
3 commits,
3 years ago
version 2
fe4da00f
2 commits,
3 years ago
version 1
220d58d8
1 commit,
3 years ago
Show latest version
5 files
+
171
−
69
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
Search (e.g. *.vue) (Ctrl+P)
projects/indirect_dispatch/resources/shaders/motionBlur.comp
0 → 100644
+
126
−
0
Options
#version 440
#extension GL_GOOGLE_include_directive : enable
layout(set=0, binding=0) uniform texture2D inColor;
layout(set=0, binding=1) uniform texture2D inDepth;
layout(set=0, binding=2) uniform texture2D inMotion;
layout(set=0, binding=3) uniform sampler nearestSampler;
layout(set=0, binding=4, r11f_g11f_b10f) uniform image2D outImage;
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
layout( push_constant ) uniform constants{
float motionFactor; // computed from delta time and shutter speed
float minVelocity;
// camera planes are needed to linearize depth
float cameraNearPlane;
float cameraFarPlane;
};
float linearizeDepth(float depth, float near, float far){
return near * far / (far + depth * (near - far));
}
struct SampleData{
float depthLinear;
vec2 uv;
vec2 motion;
float velocity;
};
// estimates if a points lies within the influence of another point
// uv1 and uv2 can be interchanged, the velocity belongs to the point whose influence is estimated
float cone(vec2 uv1, vec2 uv2, float velocity){
return clamp(1 - distance(uv1, uv2) / velocity, 0, 1);
}
// similar to cone, but with a different shape
// see paper for usage details
float cylinder(vec2 uv1, vec2 uv2, float velocity){
return 1 - smoothstep(0.95 * velocity, 1.05 * velocity, distance(uv1, uv2));
}
// checks if depth2 is closer than depth1, result within range [0, 1]
float softDepthCompare(float depth1, float depth2){
float softDepthExtent = 0.1;
return clamp(1 - (depth1 - depth2) / softDepthExtent, 0, 1);
}
// reconstruction filter and helper functions from "A Reconstruction Filter for Plausible Motion Blur", McGuire
float computeSampleWeigth(SampleData mainPixel, SampleData samplePixel){
float foreground = softDepthCompare( mainPixel.depthLinear, samplePixel.depthLinear);
float background = softDepthCompare(samplePixel.depthLinear, mainPixel.depthLinear);
// blurry sample in front of main pixel
float weight = foreground * cone(mainPixel.uv, samplePixel.uv, samplePixel.velocity);
// any sample behind blurry main pixel: estimate background by using sample
weight += background * cone(mainPixel.uv, samplePixel.uv, mainPixel.velocity);
// both main pixel and sample are blurry and overlap
weight += 2 * cylinder(mainPixel.uv, samplePixel.uv, mainPixel.velocity) * cylinder(mainPixel.uv, samplePixel.uv, samplePixel.velocity);
return weight;
}
SampleData loadSampleData(vec2 uv){
SampleData data;
data.uv = uv;
data.motion = texture(sampler2D(inMotion, nearestSampler), uv).rg * motionFactor;
data.velocity = length(data.motion);
data.depthLinear = texture(sampler2D(inDepth, nearestSampler), uv).r;
data.depthLinear = linearizeDepth(data.depthLinear, cameraNearPlane, cameraFarPlane);
return data;
}
void main(){
if(any(greaterThanEqual(gl_GlobalInvocationID.xy, imageSize(outImage))))
return;
ivec2 textureRes = textureSize(sampler2D(inColor, nearestSampler), 0);
ivec2 coord = ivec2(gl_GlobalInvocationID.xy);
vec2 uv = vec2(coord + 0.5) / textureRes; // + 0.5 to shift uv into pixel center
SampleData mainPixel = loadSampleData(uv);
// early out on little movement
if(mainPixel.velocity <= minVelocity){
vec3 color = texture(sampler2D(inColor, nearestSampler), uv).rgb;
imageStore(outImage, coord, vec4(color, 0.f));
return;
}
// TODO: check if a max velocity is necessary
// // TODO: should be configurable by user or computed by velocity tile sizes
// const float maxBlurDistance = 0.075;
// if(mainPixel.velocity > maxBlurDistance)
// motion *= maxBlurDistance / velocity;
vec3 color = vec3(0);
float weightSum = 0;
const int sampleCount = 16;
// clamping start and end points avoids artifacts at image borders
// the sampler clamps the sample uvs anyways, but without clamping here, many samples can be stuck at the border
vec2 uvStart = clamp(uv - mainPixel.motion, 0, 1);
vec2 uvEnd = clamp(uv + mainPixel.motion, 0, 1);
for(int i = 0; i < sampleCount; i++){
vec2 sampleUV = mix(uvStart, uvEnd, i / float(sampleCount - 1));
vec3 sampleColor = texture(sampler2D(inColor, nearestSampler), sampleUV).rgb;
SampleData samplePixel = loadSampleData(sampleUV);
float weightSample = computeSampleWeigth(mainPixel, samplePixel);
weightSum += weightSample;
color += sampleColor * weightSample;
}
color /= weightSum;
imageStore(outImage, coord, vec4(color, 0.f));
}
\ No newline at end of file
Loading