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
ae0450b3
Commit
ae0450b3
authored
3 years ago
by
Alexander Gauggel
Browse files
Options
Downloads
Patches
Plain Diff
[
#82
] Add UI controls for volumetric lighting
parent
eb723db1
No related branches found
No related tags found
1 merge request
!70
Resolve "Voxel cone tracing"
Pipeline
#26025
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/shader.frag
+8
-4
8 additions, 4 deletions
projects/voxelization/resources/shaders/shader.frag
projects/voxelization/src/main.cpp
+28
-1
28 additions, 1 deletion
projects/voxelization/src/main.cpp
with
36 additions
and
5 deletions
projects/voxelization/resources/shaders/shader.frag
+
8
−
4
View file @
ae0450b3
...
...
@@ -32,6 +32,13 @@ layout(set=0, binding=6) uniform VoxelInfoBuffer{
VoxelInfo
voxelInfo
;
};
layout
(
set
=
0
,
binding
=
7
)
uniform
VolumetricSettings
{
vec3
scatteringCoefficient
;
float
volumetricAmbientLight
;
vec3
absorptionCoefficient
;
};
vec3
cookTorrance
(
vec3
f0
,
float
r
,
vec3
N
,
vec3
V
,
vec3
L
){
vec3
H
=
normalize
(
L
+
V
);
...
...
@@ -78,10 +85,7 @@ vec3 volumetricLighting(vec3 colorIn, vec3 V, vec3 pos, float d){
int
sampleCount
=
48
;
float
stepSize
=
d
/
sampleCount
;
vec3
scatteringCoefficient
=
vec3
(
0
.
005
);
vec3
absorptionCoefficient
=
vec3
(
0
.
01
);
vec3
extinctionCoefficient
=
scatteringCoefficient
+
absorptionCoefficient
;
vec3
ambientLight
=
vec3
(
0
.
2
);
float
noiseScale
=
0
.
1
;
pos
+=
V
*
noiseScale
*
interleavedGradientNoise
(
gl_FragCoord
.
xy
);
...
...
@@ -92,7 +96,7 @@ vec3 volumetricLighting(vec3 colorIn, vec3 V, vec3 pos, float d){
vec3
light
=
lightInfo
.
sunColor
*
lightInfo
.
sunStrength
;
float
shadow
=
shadowTest
(
samplePoint
,
lightInfo
,
shadowMap
,
shadowMapSampler
,
vec2
(
0
));
light
*=
shadow
;
light
+=
a
mbientLight
;
light
+=
volumetricA
mbientLight
;
color
+=
phase
*
light
*
scatteringCoefficient
*
stepSize
;
color
*=
exp
(
-
stepSize
*
extinctionCoefficient
);
...
...
This diff is collapsed.
Click to expand it.
projects/voxelization/src/main.cpp
+
28
−
1
View file @
ae0450b3
...
...
@@ -444,12 +444,21 @@ int main(int argc, const char** argv) {
vkcv
::
Buffer
<
glm
::
vec3
>
cameraPosBuffer
=
core
.
createBuffer
<
glm
::
vec3
>
(
vkcv
::
BufferType
::
UNIFORM
,
1
);
struct
VolumetricSettings
{
glm
::
vec3
scatteringCoefficient
;
float
ambientLight
;
glm
::
vec3
absorptionCoefficient
;
};
vkcv
::
Buffer
<
VolumetricSettings
>
volumetricSettingsBuffer
=
core
.
createBuffer
<
VolumetricSettings
>
(
vkcv
::
BufferType
::
UNIFORM
,
1
);
// write forward pass descriptor set
vkcv
::
DescriptorWrites
forwardDescriptorWrites
;
forwardDescriptorWrites
.
uniformBufferWrites
=
{
vkcv
::
UniformBufferDescriptorWrite
(
0
,
shadowMapping
.
getLightInfoBuffer
()),
vkcv
::
UniformBufferDescriptorWrite
(
3
,
cameraPosBuffer
.
getHandle
()),
vkcv
::
UniformBufferDescriptorWrite
(
6
,
voxelization
.
getVoxelInfoBufferHandle
())
};
vkcv
::
UniformBufferDescriptorWrite
(
6
,
voxelization
.
getVoxelInfoBufferHandle
()),
vkcv
::
UniformBufferDescriptorWrite
(
7
,
volumetricSettingsBuffer
.
getHandle
())};
forwardDescriptorWrites
.
sampledImageWrites
=
{
vkcv
::
SampledImageDescriptorWrite
(
1
,
shadowMapping
.
getShadowMap
()),
vkcv
::
SampledImageDescriptorWrite
(
4
,
voxelization
.
getVoxelImageHandle
())
};
...
...
@@ -470,6 +479,12 @@ int main(int argc, const char** argv) {
bool
msaaCustomResolve
=
true
;
glm
::
vec3
scatteringColor
=
glm
::
vec3
(
1
);
float
scatteringDensity
=
0.001
;
glm
::
vec3
absorptionColor
=
glm
::
vec3
(
1
);
float
absorptionDensity
=
0.001
;
float
volumetricAmbient
=
0.2
;
auto
start
=
std
::
chrono
::
system_clock
::
now
();
const
auto
appStartTime
=
start
;
while
(
window
.
isWindowOpen
())
{
...
...
@@ -567,6 +582,12 @@ int main(int argc, const char** argv) {
mainPassMatrices
.
push_back
({
viewProjectionCamera
*
m
,
m
});
}
VolumetricSettings
volumeSettings
;
volumeSettings
.
scatteringCoefficient
=
scatteringColor
*
scatteringDensity
;
volumeSettings
.
absorptionCoefficient
=
absorptionColor
*
absorptionDensity
;
volumeSettings
.
ambientLight
=
volumetricAmbient
;
volumetricSettingsBuffer
.
fill
({
volumeSettings
});
const
vkcv
::
PushConstantData
pushConstantData
((
void
*
)
mainPassMatrices
.
data
(),
2
*
sizeof
(
glm
::
mat4
));
const
std
::
vector
<
vkcv
::
ImageHandle
>
renderTargets
=
{
colorBuffer
,
depthBuffer
};
...
...
@@ -655,6 +676,12 @@ int main(int argc, const char** argv) {
voxelizationExtent
=
std
::
max
(
voxelizationExtent
,
1.
f
);
voxelVisualisationMip
=
std
::
max
(
voxelVisualisationMip
,
0
);
ImGui
::
ColorEdit3
(
"Scattering color"
,
&
scatteringColor
.
x
);
ImGui
::
DragFloat
(
"Scattering density"
,
&
scatteringDensity
,
0.0001
);
ImGui
::
ColorEdit3
(
"Absorption color"
,
&
absorptionColor
.
x
);
ImGui
::
DragFloat
(
"Absorption density"
,
&
absorptionDensity
,
0.0001
);
ImGui
::
DragFloat
(
"Volumetric ambient"
,
&
volumetricAmbient
,
0.002
);
if
(
ImGui
::
Button
(
"Reload forward pass"
))
{
vkcv
::
ShaderProgram
newForwardProgram
;
...
...
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