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
b1013c2b
Commit
b1013c2b
authored
Mar 13, 2019
by
Florian Oetke
Browse files
soft particles
parent
5562d169
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/mirrage/renderer/shader/particle.vert
View file @
b1013c2b
...
...
@@ -19,6 +19,7 @@ layout(location = 0) out vec3 out_view_pos;
layout
(
location
=
1
)
out
vec3
out_normal
;
layout
(
location
=
2
)
out
vec2
out_tex_coords
;
layout
(
location
=
3
)
out
vec4
out_particle_color
;
layout
(
location
=
4
)
out
vec4
out_screen_pos
;
layout
(
std140
,
set
=
2
,
binding
=
0
)
readonly
buffer
Particle_type_config
{
PARTICLE_TYPE_CONFIG
...
...
@@ -163,5 +164,7 @@ void main() {
vec4
color
=
calc_color
(
keyframe_a
,
keyframe_b
,
keyframe_t
,
rand_color
);;
out_particle_color
=
vec4
(
hsv2rgb
(
color
.
xyz
),
color
.
a
);
gl_Position
=
global_uniforms
.
proj_mat
*
view_pos
;
vec4
screen_pos
=
global_uniforms
.
proj_mat
*
view_pos
;
out_screen_pos
=
screen_pos
;
gl_Position
=
screen_pos
;
}
src/mirrage/renderer/shader/particle_transparent_lit.frag
View file @
b1013c2b
...
...
@@ -12,6 +12,7 @@ layout(location = 0) in vec3 view_pos;
layout
(
location
=
1
)
in
vec3
normal
;
layout
(
location
=
2
)
in
vec2
tex_coords
;
layout
(
location
=
3
)
in
vec4
out_particle_color
;
layout
(
location
=
4
)
in
vec4
out_screen_pos
;
layout
(
location
=
0
)
out
vec4
accum_out
;
layout
(
location
=
1
)
out
vec4
revealage_out
;
...
...
@@ -25,10 +26,13 @@ layout(std140, set=2, binding = 0) readonly buffer Particle_type_config {
PARTICLE_TYPE_CONFIG
}
particle_config
;
layout
(
set
=
3
,
binding
=
0
)
uniform
sampler2D
depth_sampler
;
layout
(
push_constant
)
uniform
Per_model_uniforms
{
mat4
model
;
vec4
light_color
;
vec4
options
;
vec4
light_data2
;
// R=shadowmapID
}
model_uniforms
;
const
float
PI
=
3
.
14159265359
;
...
...
@@ -38,9 +42,15 @@ vec3 decode_tangent_normal(vec2 tn);
vec3
tangent_space_to_world
(
vec3
N
);
void
main
()
{
int
mip
=
int
(
model_uniforms
.
light_data2
.
w
);
vec4
albedo
=
texture
(
albedo_sampler
,
tex_coords
);
albedo
*=
out_particle_color
;
vec2
screen_uv
=
out_screen_pos
.
xy
/
out_screen_pos
.
w
*
0
.
5
+
0
.
5
;
float
background_depth
=
textureLod
(
depth_sampler
,
screen_uv
,
mip
).
r
*
-
global_uniforms
.
proj_planes
.
y
;
albedo
.
a
*=
smoothstep
(
0
,
0
.
5
,
abs
(
background_depth
-
view_pos
.
z
));
if
(
albedo
.
a
<
0
.
001
)
{
discard
;
}
...
...
Write
Preview
Markdown
is supported
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