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
e9c8097c
Commit
e9c8097c
authored
3 years ago
by
Alexander Gauggel
Browse files
Options
Downloads
Patches
Plain Diff
[
#81
] Optimize reflections by using noise to hide lower sample count
parent
e2c97ce3
No related branches found
No related tags found
1 merge request
!70
Resolve "Voxel cone tracing"
Pipeline
#25921
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
+7
-0
7 additions, 0 deletions
projects/voxelization/resources/shaders/shader.frag
projects/voxelization/resources/shaders/voxel.inc
+2
-2
2 additions, 2 deletions
projects/voxelization/resources/shaders/voxel.inc
with
9 additions
and
2 deletions
projects/voxelization/resources/shaders/shader.frag
+
7
−
0
View file @
e9c8097c
...
@@ -50,6 +50,12 @@ float roughnessToConeAngle(float r){
...
@@ -50,6 +50,12 @@ float roughnessToConeAngle(float r){
return
mix
(
degreeToRadian
(
20
),
degreeToRadian
(
90
),
r
);
return
mix
(
degreeToRadian
(
20
),
degreeToRadian
(
90
),
r
);
}
}
// from: "Next Generation Post Processing in Call Of Duty Advanced Warfare" slide page 123
float
interleavedGradientNoise
(
vec2
uv
){
vec3
magic
=
vec3
(
0
.
06711056
,
0
.
005
83715
,
62
.
9829189
);
return
fract
(
magic
.
z
*
fract
(
dot
(
uv
,
magic
.
xy
)));
}
void
main
()
{
void
main
()
{
vec3
albedoTexel
=
texture
(
sampler2D
(
albedoTexture
,
textureSampler
),
passUV
).
rgb
;
vec3
albedoTexel
=
texture
(
sampler2D
(
albedoTexture
,
textureSampler
),
passUV
).
rgb
;
...
@@ -95,6 +101,7 @@ void main() {
...
@@ -95,6 +101,7 @@ void main() {
vec3
R
=
reflect
(
-
V
,
N
);
vec3
R
=
reflect
(
-
V
,
N
);
float
reflectionConeAngle
=
degreeToRadian
(
roughnessToConeAngle
(
r
));
float
reflectionConeAngle
=
degreeToRadian
(
roughnessToConeAngle
(
r
));
vec3
offsetTraceStart
=
passPos
+
N_geo
*
0
.
1
f
;
vec3
offsetTraceStart
=
passPos
+
N_geo
*
0
.
1
f
;
offsetTraceStart
+=
R
*
interleavedGradientNoise
(
gl_FragCoord
.
xy
)
*
0
.
5
;
vec3
specularTrace
=
voxelConeTrace
(
R
,
offsetTraceStart
,
reflectionConeAngle
,
voxelTexture
,
voxelSampler
,
voxelInfo
);
vec3
specularTrace
=
voxelConeTrace
(
R
,
offsetTraceStart
,
reflectionConeAngle
,
voxelTexture
,
voxelSampler
,
voxelInfo
);
specularTrace
*=
clamp
(
dot
(
N
,
R
),
0
,
1
);
specularTrace
*=
clamp
(
dot
(
N
,
R
),
0
,
1
);
vec3
reflectionBRDF
=
cookTorrance
(
f0
,
r
,
N
,
V
,
R
);
vec3
reflectionBRDF
=
cookTorrance
(
f0
,
r
,
N
,
V
,
R
);
...
...
This diff is collapsed.
Click to expand it.
projects/voxelization/resources/shaders/voxel.inc
+
2
−
2
View file @
e9c8097c
...
@@ -130,7 +130,7 @@ vec3 voxelConeTrace(vec3 direction, vec3 startPosition, float coneAngleRadian, t
...
@@ -130,7 +130,7 @@ vec3 voxelConeTrace(vec3 direction, vec3 startPosition, float coneAngleRadian, t
float
coneAngleHalf
=
coneAngleRadian
*
0.5
f
;
float
coneAngleHalf
=
coneAngleRadian
*
0.5
f
;
int
maxSamples
=
1
28
;
int
maxSamples
=
1
6
;
for
(
int
i
=
0
;
i
<
maxSamples
;
i
++
){
for
(
int
i
=
0
;
i
<
maxSamples
;
i
++
){
vec3
samplePos
=
startPosition
+
d
*
direction
;
vec3
samplePos
=
startPosition
+
d
*
direction
;
...
@@ -149,7 +149,7 @@ vec3 voxelConeTrace(vec3 direction, vec3 startPosition, float coneAngleRadian, t
...
@@ -149,7 +149,7 @@ vec3 voxelConeTrace(vec3 direction, vec3 startPosition, float coneAngleRadian, t
color
+=
(
1
-
a
)
*
voxelSample
.
rgb
;
color
+=
(
1
-
a
)
*
voxelSample
.
rgb
;
a
+=
(
1
-
a
)
*
voxelSample
.
a
;
a
+=
(
1
-
a
)
*
voxelSample
.
a
;
float
minStepSize
=
0.
1
5
;
float
minStepSize
=
0.5
f
;
d
+=
max
(
coneDiameter
,
minStepSize
);
d
+=
max
(
coneDiameter
,
minStepSize
);
samplePos
=
startPosition
+
d
*
direction
;
samplePos
=
startPosition
+
d
*
direction
;
sampleUV
=
worldToVoxelCoordinates
(
samplePos
,
voxelInfo
);
sampleUV
=
worldToVoxelCoordinates
(
samplePos
,
voxelInfo
);
...
...
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