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
8d6fbab4
Commit
8d6fbab4
authored
3 years ago
by
Alexander Gauggel
Browse files
Options
Downloads
Patches
Plain Diff
[
#82
] Add light lens distortion
parent
b0690281
No related branches found
No related tags found
1 merge request
!70
Resolve "Voxel cone tracing"
Pipeline
#26032
passed
3 years ago
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
projects/voxelization/resources/shaders/tonemapping.comp
+20
-7
20 additions, 7 deletions
projects/voxelization/resources/shaders/tonemapping.comp
projects/voxelization/src/main.cpp
+10
-9
10 additions, 9 deletions
projects/voxelization/src/main.cpp
with
30 additions
and
16 deletions
projects/voxelization/resources/shaders/tonemapping.comp
+
20
−
7
View file @
8d6fbab4
#version 440
#version 440
layout(set=0, binding=0, r11f_g11f_b10f) uniform image2D inImage;
layout(set=0, binding=0) uniform texture2D inTexture;
layout(set=0, binding=1, rgba8) uniform image2D outImage;
layout(set=0, binding=1) uniform sampler textureSampler;
layout(set=0, binding=2, rgba8) 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;
...
@@ -69,16 +70,28 @@ vec3 applyGrain(ivec2 uv, vec3 c){
...
@@ -69,16 +70,28 @@ vec3 applyGrain(ivec2 uv, vec3 c){
return c * grain;
return c * grain;
}
}
vec2 computeDistortedUV(vec2 uv, float aspectRatio){
vec2 toCenter = vec2(vec2(0.5) - uv);
float r2 = dot(toCenter, toCenter);
float k1 = 0.15f;
float k2 = 0.2f;
return uv + toCenter * (r2*k1 + r2*r2*k2);
}
void main(){
void main(){
if(any(greaterThanEqual(gl_GlobalInvocationID.xy, imageSize(
in
Image)))){
if(any(greaterThanEqual(gl_GlobalInvocationID.xy, imageSize(
out
Image)))){
return;
return;
}
}
ivec2 uv = ivec2(gl_GlobalInvocationID.xy);
ivec2 textureRes = textureSize(sampler2D(inTexture, textureSampler), 0);
vec3 linearColor = imageLoad(inImage, uv).rgb;
ivec2 coord = ivec2(gl_GlobalInvocationID.xy);
vec2 uv = vec2(coord) / textureRes;
float aspectRatio = float(textureRes.x) / textureRes.y;
uv = computeDistortedUV(uv, aspectRatio);
vec3 linearColor = texture(sampler2D(inTexture, textureSampler), uv).rgb;
vec3 tonemapped = ACESFilm(linearColor);
vec3 tonemapped = ACESFilm(linearColor);
tonemapped = applyGrain(
uv
, tonemapped);
tonemapped = applyGrain(
coord
, tonemapped);
vec3 gammaCorrected = pow(tonemapped, vec3(1.f / 2.2f));
vec3 gammaCorrected = pow(tonemapped, vec3(1.f / 2.2f));
imageStore(outImage,
uv
, vec4(gammaCorrected, 0.f));
imageStore(outImage,
coord
, vec4(gammaCorrected, 0.f));
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
projects/voxelization/src/main.cpp
+
10
−
9
View file @
8d6fbab4
...
@@ -26,12 +26,12 @@ int main(int argc, const char** argv) {
...
@@ -26,12 +26,12 @@ int main(int argc, const char** argv) {
true
true
);
);
vkcv
::
camera
::
CameraManager
cameraManager
(
window
);
vkcv
::
camera
::
CameraManager
cameraManager
(
window
);
uint32_t
camIndex
=
cameraManager
.
addCamera
(
vkcv
::
camera
::
ControllerType
::
PILOT
);
uint32_t
camIndex
=
cameraManager
.
addCamera
(
vkcv
::
camera
::
ControllerType
::
PILOT
);
uint32_t
camIndex2
=
cameraManager
.
addCamera
(
vkcv
::
camera
::
ControllerType
::
TRACKBALL
);
uint32_t
camIndex2
=
cameraManager
.
addCamera
(
vkcv
::
camera
::
ControllerType
::
TRACKBALL
);
cameraManager
.
getCamera
(
camIndex
).
setPosition
(
glm
::
vec3
(
0.
f
,
0.
f
,
3.
f
));
cameraManager
.
getCamera
(
camIndex
).
setPosition
(
glm
::
vec3
(
0.
f
,
0.
f
,
3.
f
));
cameraManager
.
getCamera
(
camIndex
).
setNearFar
(
0.1
f
,
30.0
f
);
cameraManager
.
getCamera
(
camIndex
).
setNearFar
(
0.1
f
,
30.0
f
);
cameraManager
.
getCamera
(
camIndex
).
setYaw
(
180.0
f
);
cameraManager
.
getCamera
(
camIndex
).
setYaw
(
180.0
f
);
cameraManager
.
getCamera
(
camIndex
).
setFov
(
glm
::
radians
(
37.8
));
// fov of a 35mm lens
cameraManager
.
getCamera
(
camIndex
).
setFov
(
glm
::
radians
(
37.8
));
// fov of a 35mm lens
...
@@ -523,9 +523,10 @@ int main(int argc, const char** argv) {
...
@@ -523,9 +523,10 @@ int main(int argc, const char** argv) {
// update descriptor sets which use swapchain image
// update descriptor sets which use swapchain image
vkcv
::
DescriptorWrites
tonemappingDescriptorWrites
;
vkcv
::
DescriptorWrites
tonemappingDescriptorWrites
;
tonemappingDescriptorWrites
.
storageImageWrites
=
{
tonemappingDescriptorWrites
.
sampledImageWrites
=
{
vkcv
::
SampledImageDescriptorWrite
(
0
,
resolvedColorBuffer
)
};
vkcv
::
StorageImageDescriptorWrite
(
0
,
resolvedColorBuffer
),
tonemappingDescriptorWrites
.
samplerWrites
=
{
vkcv
::
SamplerDescriptorWrite
(
1
,
colorSampler
)
};
vkcv
::
StorageImageDescriptorWrite
(
1
,
swapchainInput
)
};
tonemappingDescriptorWrites
.
storageImageWrites
=
{
vkcv
::
StorageImageDescriptorWrite
(
2
,
swapchainInput
)
};
core
.
writeDescriptorSet
(
tonemappingDescriptorSet
,
tonemappingDescriptorWrites
);
core
.
writeDescriptorSet
(
tonemappingDescriptorSet
,
tonemappingDescriptorWrites
);
// update resolve descriptor, color images could be changed
// update resolve descriptor, color images could be changed
...
@@ -651,7 +652,7 @@ int main(int argc, const char** argv) {
...
@@ -651,7 +652,7 @@ int main(int argc, const char** argv) {
}
}
core
.
prepareImageForStorage
(
cmdStream
,
swapchainInput
);
core
.
prepareImageForStorage
(
cmdStream
,
swapchainInput
);
core
.
prepareImageForS
torage
(
cmdStream
,
resolvedColorBuffer
);
core
.
prepareImageForS
ampling
(
cmdStream
,
resolvedColorBuffer
);
auto
timeSinceStart
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
end
-
appStartTime
);
auto
timeSinceStart
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
end
-
appStartTime
);
float
timeF
=
static_cast
<
float
>
(
timeSinceStart
.
count
())
*
0.01
;
float
timeF
=
static_cast
<
float
>
(
timeSinceStart
.
count
())
*
0.01
;
...
...
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