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
fe9de4d9
Commit
fe9de4d9
authored
3 years ago
by
Alexander Gauggel
Browse files
Options
Downloads
Patches
Plain Diff
[
#106
] Add shutter speed and make motion blur framerate independant
parent
a8a3b210
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!89
Resolve "Indirect Dispatch"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
projects/indirect_dispatch/resources/shaders/motionBlurDummy.comp
+7
-0
7 additions, 0 deletions
.../indirect_dispatch/resources/shaders/motionBlurDummy.comp
projects/indirect_dispatch/src/App.cpp
+12
-3
12 additions, 3 deletions
projects/indirect_dispatch/src/App.cpp
with
19 additions
and
3 deletions
projects/indirect_dispatch/resources/shaders/motionBlurDummy.comp
+
7
−
0
View file @
fe9de4d9
...
@@ -8,6 +8,12 @@ layout(set=0, binding=3, r11f_g11f_b10f) uniform image2D outImage;
...
@@ -8,6 +8,12 @@ layout(set=0, binding=3, r11f_g11f_b10f) uniform image2D outImage;
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
layout( push_constant ) uniform constants{
// computed from delta time and shutter speed
float motionFactor;
};
void main(){
void main(){
if(any(greaterThanEqual(gl_GlobalInvocationID.xy, imageSize(outImage))))
if(any(greaterThanEqual(gl_GlobalInvocationID.xy, imageSize(outImage))))
...
@@ -18,6 +24,7 @@ void main(){
...
@@ -18,6 +24,7 @@ void main(){
vec2 uv = vec2(coord) / textureRes;
vec2 uv = vec2(coord) / textureRes;
vec2 motion = texture(sampler2D(inMotion, textureSampler), uv).rg;
vec2 motion = texture(sampler2D(inMotion, textureSampler), uv).rg;
motion *= motionFactor;
vec3 color = vec3(0);
vec3 color = vec3(0);
const int sampleCount = 16;
const int sampleCount = 16;
...
...
This diff is collapsed.
Click to expand it.
projects/indirect_dispatch/src/App.cpp
+
12
−
3
View file @
fe9de4d9
...
@@ -101,7 +101,8 @@ void App::run() {
...
@@ -101,7 +101,8 @@ void App::run() {
eDebugView
debugView
=
eDebugView
::
None
;
eDebugView
debugView
=
eDebugView
::
None
;
eMotionBlurInput
motionBlurInput
=
eMotionBlurInput
::
MotionVectorMaxTileNeighbourhood
;
eMotionBlurInput
motionBlurInput
=
eMotionBlurInput
::
MotionVectorMaxTileNeighbourhood
;
float
objectVerticalSpeed
=
0.005
;
float
objectVerticalSpeed
=
0.005
;
int
cameraShutterSpeedInverse
=
48
;
glm
::
mat4
mvpPrevious
=
glm
::
mat4
(
1.
f
);
glm
::
mat4
mvpPrevious
=
glm
::
mat4
(
1.
f
);
glm
::
mat4
viewProjectionPrevious
=
m_cameraManager
.
getActiveCamera
().
getMVP
();
glm
::
mat4
viewProjectionPrevious
=
m_cameraManager
.
getActiveCamera
().
getMVP
();
...
@@ -126,7 +127,6 @@ void App::run() {
...
@@ -126,7 +127,6 @@ void App::run() {
auto
frameEndTime
=
std
::
chrono
::
system_clock
::
now
();
auto
frameEndTime
=
std
::
chrono
::
system_clock
::
now
();
auto
deltatime
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
frameEndTime
-
frameStartTime
);
auto
deltatime
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
frameEndTime
-
frameStartTime
);
frameStartTime
=
frameEndTime
;
m_cameraManager
.
update
(
0.000001
*
static_cast
<
double
>
(
deltatime
.
count
()));
m_cameraManager
.
update
(
0.000001
*
static_cast
<
double
>
(
deltatime
.
count
()));
const
glm
::
mat4
viewProjection
=
m_cameraManager
.
getActiveCamera
().
getMVP
();
const
glm
::
mat4
viewProjection
=
m_cameraManager
.
getActiveCamera
().
getMVP
();
...
@@ -281,12 +281,19 @@ void App::run() {
...
@@ -281,12 +281,19 @@ void App::run() {
m_core
.
prepareImageForSampling
(
cmdStream
,
m_renderTargets
.
colorBuffer
);
m_core
.
prepareImageForSampling
(
cmdStream
,
m_renderTargets
.
colorBuffer
);
m_core
.
prepareImageForSampling
(
cmdStream
,
motionBuffer
);
m_core
.
prepareImageForSampling
(
cmdStream
,
motionBuffer
);
const
float
microsecondToSecond
=
0.000001
;
const
float
fDeltatimeSeconds
=
microsecondToSecond
*
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
frameEndTime
-
frameStartTime
).
count
();
const
float
motionBlurMotionFactor
=
1
/
(
fDeltatimeSeconds
*
cameraShutterSpeedInverse
);
vkcv
::
PushConstants
motionBlurPushConstants
(
sizeof
(
float
));
motionBlurPushConstants
.
appendDrawcall
(
motionBlurMotionFactor
);
m_core
.
recordComputeDispatchToCmdStream
(
m_core
.
recordComputeDispatchToCmdStream
(
cmdStream
,
cmdStream
,
m_motionBlurDummyPass
.
pipeline
,
m_motionBlurDummyPass
.
pipeline
,
fullScreenImageDispatch
,
fullScreenImageDispatch
,
{
vkcv
::
DescriptorSetUsage
(
0
,
m_core
.
getDescriptorSet
(
m_motionBlurDummyPass
.
descriptorSet
).
vulkanHandle
)
},
{
vkcv
::
DescriptorSetUsage
(
0
,
m_core
.
getDescriptorSet
(
m_motionBlurDummyPass
.
descriptorSet
).
vulkanHandle
)
},
vkcv
::
PushConstants
(
0
)
);
motionBlur
PushConstants
);
// gamma correction
// gamma correction
vkcv
::
ImageHandle
gammaCorrectionInput
;
vkcv
::
ImageHandle
gammaCorrectionInput
;
...
@@ -342,6 +349,7 @@ void App::run() {
...
@@ -342,6 +349,7 @@ void App::run() {
static_cast
<
int
>
(
eMotionBlurInput
::
OptionCount
));
static_cast
<
int
>
(
eMotionBlurInput
::
OptionCount
));
ImGui
::
InputFloat
(
"Object movement speed"
,
&
objectVerticalSpeed
);
ImGui
::
InputFloat
(
"Object movement speed"
,
&
objectVerticalSpeed
);
ImGui
::
InputInt
(
"Camera shutter speed inverse"
,
&
cameraShutterSpeedInverse
);
ImGui
::
End
();
ImGui
::
End
();
gui
.
endGUI
();
gui
.
endGUI
();
...
@@ -350,5 +358,6 @@ void App::run() {
...
@@ -350,5 +358,6 @@ void App::run() {
viewProjectionPrevious
=
viewProjection
;
viewProjectionPrevious
=
viewProjection
;
mvpPrevious
=
mvp
;
mvpPrevious
=
mvp
;
frameStartTime
=
frameEndTime
;
}
}
}
}
\ No newline at end of file
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