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
bdb6e3a5
Commit
bdb6e3a5
authored
Nov 13, 2017
by
Florian Oetke
Browse files
simplified spec gi
parent
ad6a641d
Changes
2
Hide whitespace changes
Inline
Side-by-side
assets/core_assets/shader/bin/gi_sample_spec.frag.spv
View file @
bdb6e3a5
No preview for this file type
assets/core_assets/shader/gi_sample_spec.frag
View file @
bdb6e3a5
...
...
@@ -62,7 +62,7 @@ float isosceles_triangle_next_adjacent(float adjacentLength, float incircleRadiu
return
adjacentLength
-
(
incircleRadius
*
2
.
0
f
);
}
vec3
cone_tracing
(
float
roughness
,
vec2
hit_uv
,
vec3
L
,
float
coneTheta
)
{
vec3
sample_color_lod
(
float
roughness
,
vec2
hit_uv
,
vec3
L
,
float
coneTheta
)
{
float
min_lod
=
pcs
.
prev_projection
[
0
][
3
];
float
max_lod
=
max
(
min_lod
,
pcs
.
prev_projection
[
1
][
3
]);
vec2
depth_size
=
textureSize
(
depth_sampler
,
int
(
min_lod
+
0
.
5
));
...
...
@@ -71,46 +71,13 @@ vec3 cone_tracing(float roughness, vec2 hit_uv, vec3 L, float coneTheta) {
vec2
delta
=
(
hit_uv
-
vertex_out
.
tex_coords
);
float
adjacent_length
=
length
(
delta
);
if
(
adjacent_length
<
0
.
000
0
1
)
if
(
adjacent_length
<
0
.
0001
)
return
vec3
(
0
,
0
,
0
);
vec2
adjacent_unit
=
delta
/
adjacent_length
;
vec4
color
=
vec4
(
0
,
0
,
0
,
0
);
float
glossiness_mult
=
glossiness
;
float
remaining_alpha
=
1
.
0
;
for
(
int
i
=
0
;
i
<
14
;
i
++
)
{
float
opposite_length
=
isosceles_triangle_opposite
(
adjacent_length
,
coneTheta
);
float
incircle_size
=
isosceles_triangle_inradius
(
adjacent_length
,
opposite_length
);
vec2
uv
=
(
vertex_out
.
tex_coords
+
adjacent_unit
*
(
adjacent_length
-
incircle_size
));
float
lod
=
incircle_size
<
0
.
00001
?
min_lod
:
clamp
(
log2
(
incircle_size
*
screen_size
)
-
1
,
min_lod
,
max_lod
);
vec4
s
=
vec4
(
textureLod
(
color_sampler
,
uv
,
lod
).
rgb
,
1
)
*
glossiness_mult
;
if
(
lod
>
max_lod
-
0
.
5
)
{
s
.
rgb
*=
1
.
0
-
min
(
0
.
5
,
lod
-
(
max_lod
-
0
.
5
))
*
2
;
}
else
{
int
ilod
=
int
(
lod
+
0
.
5
);
vec3
N
=
decode_normal
(
texelFetch
(
mat_data_sampler
,
ivec2
(
uv
*
textureSize
(
mat_data_sampler
,
ilod
)),
ilod
).
rg
);
s
.
rgb
*=
clamp
(
1
.
0
-
dot
(
L
,
N
),
0
,
1
);
}
remaining_alpha
-=
s
.
a
;
if
(
remaining_alpha
<
0
.
0
)
{
s
.
rgb
*=
(
1
.
0
-
abs
(
remaining_alpha
));
}
color
+=
s
;
if
(
color
.
a
>=
1
.
0
)
{
break
;
}
adjacent_length
=
isosceles_triangle_next_adjacent
(
adjacent_length
,
incircle_size
);
glossiness_mult
*=
glossiness
;
}
return
color
.
rgb
*
(
1
-
max
(
0
.
0
,
remaining_alpha
));
float
opposite_length
=
isosceles_triangle_opposite
(
adjacent_length
,
coneTheta
);
float
incircle_size
=
isosceles_triangle_inradius
(
adjacent_length
,
opposite_length
);
float
lod
=
incircle_size
<
0
.
00001
?
min_lod
:
clamp
(
log2
(
incircle_size
*
screen_size
)
-
1
,
min_lod
,
max_lod
);
return
textureLod
(
color_sampler
,
hit_uv
,
lod
).
rgb
;
}
void
main
()
{
...
...
@@ -148,7 +115,7 @@ void main() {
vec3
raycast_hit_point
;
if
(
spec_visible
&&
traceScreenSpaceRay1
(
P
+
dir
*
0
.
25
,
dir
,
pcs
.
projection
,
depth_sampler
,
depthSize
,
2
.
0
,
global_uniforms
.
proj_planes
.
x
,
depthSize
,
1
.
0
,
global_uniforms
.
proj_planes
.
x
,
10
,
0
.
5
*
jitter
.
z
,
max_distance
,
max_steps
,
int
(
startLod
+
0
.
5
),
raycast_hit_uv
,
raycast_hit_point
))
{
...
...
@@ -163,7 +130,7 @@ void main() {
float
factor_normal
=
mix
(
1
,
1
.
0
-
smoothstep
(
0
.
6
,
0
.
9
,
abs
(
dot
(
N
,
hit_N
))),
step
(
0
.
0001
,
hit_mat_data
.
b
));
vec3
color
=
cone_tracing
(
roughness
,
hit_uv
,
dir
,
coneTheta
);
vec3
color
=
sample_color_lod
(
roughness
,
hit_uv
,
dir
,
coneTheta
);
out_color
.
rgb
=
max
(
color
*
factor_distance
*
factor_normal
,
vec3
(
0
));
...
...
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