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
51330d76
Commit
51330d76
authored
3 years ago
by
Alexander Gauggel
Browse files
Options
Downloads
Patches
Plain Diff
[
#106
] Add motion blur filter jitter to reduce banding
parent
c0719894
No related branches found
No related tags found
1 merge request
!89
Resolve "Indirect Dispatch"
Pipeline
#26781
failed
3 years ago
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
projects/indirect_dispatch/resources/shaders/motionBlur.comp
+21
-2
21 additions, 2 deletions
projects/indirect_dispatch/resources/shaders/motionBlur.comp
projects/indirect_dispatch/src/App.cpp
+4
-2
4 additions, 2 deletions
projects/indirect_dispatch/src/App.cpp
with
25 additions
and
4 deletions
projects/indirect_dispatch/resources/shaders/motionBlur.comp
+
21
−
2
View file @
51330d76
...
...
@@ -15,6 +15,7 @@ layout( push_constant ) uniform constants{
// camera planes are needed to linearize depth
float cameraNearPlane;
float cameraFarPlane;
float time;
};
float linearizeDepth(float depth, float near, float far){
...
...
@@ -76,6 +77,21 @@ SampleData loadSampleData(vec2 uv){
return data;
}
// simple hash/noise function from: https://www.shadertoy.com/view/ttc3zr
uint murmurHash12(uvec2 src) {
const uint M = 0x5bd1e995u;
uint h = 1190494759u;
src *= M; src ^= src>>24u; src *= M;
h *= M; h ^= src.x; h *= M; h ^= src.y;
h ^= h>>13u; h *= M; h ^= h>>15u;
return h;
}
float hash12(vec2 src) {
uint h = murmurHash12(floatBitsToUint(src));
return uintBitsToFloat(h & 0x007fffffu | 0x3f800000u) - 1.0;
}
void main(){
if(any(greaterThanEqual(gl_GlobalInvocationID.xy, imageSize(outImage))))
...
...
@@ -89,7 +105,7 @@ void main(){
// early out on little movement
if(mainPixel.velocity <= minVelocity){
vec3 color = texture(sampler2D(inColor, nearestSampler), uv).rgb;
vec3 color = texture(sampler2D(inColor, nearestSampler), uv).rgb;
imageStore(outImage, coord, vec4(color, 0.f));
return;
}
...
...
@@ -109,8 +125,11 @@ void main(){
vec2 uvStart = clamp(uv - mainPixel.motion, 0, 1);
vec2 uvEnd = clamp(uv + mainPixel.motion, 0, 1);
// samples are placed evenly, but the entire filter is jittered
float random = hash12(uv + time) - 0.5; // in range [-0.5, 0.5]
for(int i = 0; i < sampleCount; i++){
vec2 sampleUV = mix(uvStart, uvEnd,
i
/ float(sampleCount
-
1));
vec2 sampleUV = mix(uvStart, uvEnd,
(i + random + 1)
/ float(sampleCount
+
1));
vec3 sampleColor = texture(sampler2D(inColor, nearestSampler), sampleUV).rgb;
SampleData samplePixel = loadSampleData(sampleUV);
...
...
This diff is collapsed.
Click to expand it.
projects/indirect_dispatch/src/App.cpp
+
4
−
2
View file @
51330d76
...
...
@@ -305,6 +305,7 @@ void App::run() {
float
minVelocity
;
float
cameraNearPlane
;
float
cameraFarPlane
;
float
time
;
};
MotionBlurConstantData
motionBlurConstantData
;
...
...
@@ -320,8 +321,9 @@ void App::run() {
float
cameraNear
,
cameraFar
;
m_cameraManager
.
getActiveCamera
().
getNearFar
(
cameraNear
,
cameraFar
);
motionBlurConstantData
.
cameraNearPlane
=
cameraNear
;
motionBlurConstantData
.
cameraFarPlane
=
cameraFar
;
motionBlurConstantData
.
cameraNearPlane
=
cameraNear
;
motionBlurConstantData
.
cameraFarPlane
=
cameraFar
;
motionBlurConstantData
.
time
=
fCurrentTime
;
vkcv
::
PushConstants
motionBlurPushConstants
(
sizeof
(
motionBlurConstantData
));
motionBlurPushConstants
.
appendDrawcall
(
motionBlurConstantData
);
...
...
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