Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
GameDevWeek
Dependencies
Cpp
mirrage
Commits
6b13ef67
Commit
6b13ef67
authored
Feb 17, 2018
by
Florian Oetke
Browse files
tweaked specular GI
parent
d9d1da53
Changes
2
Hide whitespace changes
Inline
Side-by-side
assets/core_assets/shader/bin/gi_sample_spec.frag.spv
View file @
6b13ef67
No preview for this file type
assets/core_assets/shader/gi_sample_spec.frag
View file @
6b13ef67
...
...
@@ -41,7 +41,7 @@ float luminance_norm(vec3 c) {
float
roughness_to_spec_lobe_angle
(
float
roughness
)
{
// see: http://graphicrants.blogspot.de/2013/08/specular-brdf-reference.html
float
power
=
clamp
(
2
/
max
(
0
.
0001
,
roughness
*
roughness
)
-
2
,
4
.
0
,
1024
*
16
)
;
float
power
=
2
/
max
(
0
.
0001
,
roughness
*
roughness
)
-
2
;
return
acos
(
pow
(
0
.
244
,
1
.
0
/
(
power
+
1
.
0
)));
}
...
...
@@ -98,12 +98,12 @@ void main() {
vec3
dir
=
-
reflect
(
V
,
N
);
P
+=
dir
*
0
.
1
;
bool
spec_visible
=
metallic
>
0
.
01
||
(
max
(
0
,
dot
(
normalize
(
V
+
dir
),
dir
))
<
0
.
6
);
// convert to cone angle (maximum extent of the specular lobe aperture)
// only want half the full cone angle since we're slicing the isosceles triangle in half to get a right triangle
float
coneTheta
=
roughness_to_spec_lobe_angle
(
roughness
)
*
0
.
5
f
;
bool
spec_visible
=
metallic
>
0
.
01
||
(
max
(
0
,
dot
(
normalize
(
V
+
dir
),
dir
))
<
0
.
6
&&
coneTheta
<
0
.
2
*
PI
);
// calculate max distance based on roughness
float
max_distance
=
min
(
32
,
4
/
(
tan
(
coneTheta
)
*
2
));
float
max_steps
=
max_distance
*
8
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment