Skip to content

Commit

Permalink
fix world particle artifacts (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmriggs committed Jan 26, 2022
1 parent 80b97b2 commit bd9a0f9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 26 deletions.
27 changes: 3 additions & 24 deletions ACViewer/Content/texture.fx
Original file line number Diff line number Diff line change
Expand Up @@ -794,41 +794,20 @@ float4 ParticleInstancePS(ParticleVertexShaderOutput input) : COLOR

color.a *= input.OpacityActive.x;

// only output completely opaque pixels
// also discard inactive particles
clip(color.a < 1.0f || input.OpacityActive.y == 0 ? -1 : 1);

return color;
}

float4 ParticleInstanceTransPS(ParticleVertexShaderOutput input) : COLOR
{
float4 color = xTextures.Sample(TextureSampler, input.TextureCoordIdx);

color.a *= input.OpacityActive.x;

// only output semi-transparent pixels
// also discard inactive particles
clip(color.a < 1.0f && input.OpacityActive.y > 0 ? 1 : -1);
// discard inactive particles
clip(input.OpacityActive.y == 0 ? -1 : 1);

return color;
}

technique ParticleInstance
{
pass Pass0
{
ZWriteEnable = true;

VertexShader = compile vs_4_0 ParticleInstanceVS();
PixelShader = compile ps_4_0 ParticleInstancePS();
}
pass Pass1
{
ZWriteEnable = false;

VertexShader = compile vs_4_0 ParticleInstanceVS();
PixelShader = compile ps_4_0 ParticleInstanceTransPS();
PixelShader = compile ps_4_0 ParticleInstancePS();
}
}

Expand Down
Binary file modified ACViewer/Content/texture.mgfxo
Binary file not shown.
4 changes: 2 additions & 2 deletions ACViewer/GameView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ protected override void Update(GameTime time)
_graphicsDeviceManager.ApplyChanges();
}

PrevKeyboardState = keyboardState;

if (Player != null)
Player.Update(time);

Expand All @@ -165,6 +163,8 @@ protected override void Update(GameTime time)
ParticleViewer.Update(time);
break;
}

PrevKeyboardState = keyboardState;
}

private static readonly Color BackgroundColor = new Color(0, 0, 0);
Expand Down
6 changes: 6 additions & 0 deletions ACViewer/Picker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,5 +370,11 @@ public static void DrawHitPoly()
GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList, HitVertices, 0, HitVertices.Length, HitIndices, 0, HitIndices.Length / 2);
}
}

public static void ClearSelection()
{
HitVertices = null;
HitIndices = null;
}
}
}
5 changes: 5 additions & 0 deletions ACViewer/WorldViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ public void Update(GameTime time)
ShowLocation();
}

if (keyboardState.IsKeyDown(Keys.C) && !PrevKeyboardState.IsKeyDown(Keys.C))
{
Picker.ClearSelection();
}

PrevKeyboardState = keyboardState;

if (Camera != null)
Expand Down

0 comments on commit bd9a0f9

Please sign in to comment.