From e63429f6372ac120b162a7448ee919eee5512be3 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 18 Nov 2020 14:15:01 +0000 Subject: [PATCH] Temporarily make particles opaque to avoid depth-related rendering problems --- assets/voxygen/shaders/particle-frag.glsl | 3 ++- assets/voxygen/shaders/particle-vert.glsl | 11 +++++++---- voxygen/src/render/pipelines/particle.rs | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/assets/voxygen/shaders/particle-frag.glsl b/assets/voxygen/shaders/particle-frag.glsl index 8849598bf9..8a2c48cb9d 100644 --- a/assets/voxygen/shaders/particle-frag.glsl +++ b/assets/voxygen/shaders/particle-frag.glsl @@ -78,5 +78,6 @@ void main() { surf_color = illuminate(max_light, view_dir, surf_color * emitted_light, surf_color * reflected_light * f_reflect); - tgt_color = vec4(surf_color, f_col.a); + // Temporarily disable particle transparency to avoid artifacts + tgt_color = vec4(surf_color, 1.0 /*f_col.a*/); } diff --git a/assets/voxygen/shaders/particle-vert.glsl b/assets/voxygen/shaders/particle-vert.glsl index 09920976e6..46dea26b5a 100644 --- a/assets/voxygen/shaders/particle-vert.glsl +++ b/assets/voxygen/shaders/particle-vert.glsl @@ -160,7 +160,7 @@ void main() { vec3(rand2 * 0.1, rand3 * 0.1, 2.0 + rand4 * 1.0) ), vec3(1.0), - vec4(2, 1.5 + rand5 * 0.5, 0, 1), + vec4(2, 1.5 + rand5 * 0.5, 0, start_end(1.0, 0.0)), spin_in_axis(vec3(rand6, rand7, rand8), rand9 * 3) ); } else if (inst_mode == GUN_POWDER_SPARK) { @@ -284,7 +284,7 @@ void main() { attr = Attr( spiral_motion(inst_dir, 0.3 * (floor(2 * rand0 + 0.5) - 0.5) * min(linear_scale(10), 1), lifetime / inst_lifespan), vec3((1.7 - 0.7 * abs(floor(2 * rand0 - 0.5) + 0.5)) * (1.5 + 0.5 * sin(tick.x * 10 - lifetime * 4))), - vec4(vec3(0.4, 2.7 + 0.4 * sin(tick.x * 8 - lifetime * 3 + 4), 0.5 + 0.6 * sin(tick.x * 7)), 0.3), + vec4(vec3(0.4, 2.7 + 0.4 * sin(tick.x * 8 - lifetime * 3 + 4), 0.5 + 0.6 * sin(tick.x * 7)), start_end(1.0, 0.0) /*0.3*/), spin_in_axis(inst_dir, tick.z) ); } else if (inst_mode == ENERGY_NATURE) { @@ -303,7 +303,7 @@ void main() { attr = Attr( (inst_dir * lifetime / inst_lifespan) + vec3(rand0, rand1, rand2) * (lifetime * 5 + 0.25), vec3(0.6 + rand3 * 0.5 + lifetime / inst_lifespan * 5), - vec4(3, 1.6 + rand5 * 0.3 - 0.6 * lifetime / inst_lifespan, 0.2, 0.8 - 0.6 * lifetime / inst_lifespan), + vec4(3, 1.6 + rand5 * 0.3 - 0.6 * lifetime / inst_lifespan, 0.2, start_end(1.0, 0.0) /*0.8 - 0.6 * lifetime / inst_lifespan*/), spin_in_axis(vec3(rand6, rand7, rand8), lifetime / inst_lifespan * 10 + 3 * rand9) ); } else if (inst_mode == FIRE_SHOCKWAVE) { @@ -311,7 +311,7 @@ void main() { attr = Attr( vec3(rand0, rand1, lifetime * 10 + rand2), vec3(1.6 + rand3 * 1.5 + 10 * (lifetime + inst_lifespan)), - vec4(3, 1.6 + rand7 * 0.3 - 5 * inst_lifespan + 2 * lifetime, 0.2, 0.8 - 3.5 * inst_lifespan), + vec4(3, 1.6 + rand7 * 0.3 - 5 * inst_lifespan + 2 * lifetime, 0.2, start_end(1.0, 0.0) /*0.8 - 3.5 * inst_lifespan*/), spin_in_axis(vec3(rand3, rand4, rand5), rand6) ); } else { @@ -326,6 +326,9 @@ void main() { ); } + // Temporary: use shrinking particles as a substitute for fading ones + attr.scale *= pow(attr.col.a, 0.25); + f_pos = (inst_pos - focus_off.xyz) + (v_pos * attr.scale * SCALE * mat3(attr.rot) + attr.offs); // First 3 normals are negative, next 3 are positive diff --git a/voxygen/src/render/pipelines/particle.rs b/voxygen/src/render/pipelines/particle.rs index e7ccd64ae3..bc71c54e38 100644 --- a/voxygen/src/render/pipelines/particle.rs +++ b/voxygen/src/render/pipelines/particle.rs @@ -71,7 +71,7 @@ gfx_defines! { light_shadows: gfx::ConstantBuffer = "u_light_shadows", tgt_color: gfx::BlendTarget = ("tgt_color", ColorMask::all(), gfx::preset::blend::ALPHA), - tgt_depth_stencil: gfx::DepthTarget = gfx::preset::depth::LESS_EQUAL_TEST, + tgt_depth_stencil: gfx::DepthTarget = gfx::preset::depth::LESS_EQUAL_WRITE, // tgt_depth_stencil: gfx::DepthStencilTarget = (gfx::preset::depth::LESS_EQUAL_WRITE,Stencil::new(Comparison::Always,0xff,(StencilOp::Keep,StencilOp::Keep,StencilOp::Keep))), } }