nanioblack slash + new prims + test
This commit is contained in:
1 parent
bbc9a82e04
commit
d9dd10f89f
9 files changed
+2593
-42
No files matched your search
@@ -100,6 +100,9 @@ namespace CalamityMod.Effects
|
||||
// Exoblade's melee slash trails. Also used by Terratomere
|
||||
internal static Asset<Effect> ExobladeSlashShader;
|
||||
|
||||
// nanoblack reaper slash effect !!!!
|
||||
internal static Asset<Effect> NanoblackSlashShader;
|
||||
|
||||
// Exoblade's projectile on-hit "anime slash marks". Also used by Terratomere
|
||||
internal static Asset<Effect> ExobladePierceShader;
|
||||
|
||||
@@ -362,6 +365,9 @@ namespace CalamityMod.Effects
|
||||
ExobladeSlashShader = LoadShader("ExobladeSlashShader");
|
||||
RegisterMiscShader(ExobladeSlashShader, "TrailPass", "ExobladeSlash");
|
||||
|
||||
NanoblackSlashShader = LoadShader("SlashEffects/NanoblackSlash");
|
||||
RegisterMiscShader(NanoblackSlashShader, "SlashPass", "NanoblackSlash");
|
||||
|
||||
ExobladePierceShader = LoadShader("ExobladePierceShader");
|
||||
RegisterMiscShader(ExobladePierceShader, "PiercePass", "ExobladePierce");
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,106 @@
|
||||
// Judgement Cut–style horizontal slash
|
||||
// HLSL for use with SanePrimitiveRenderer's custom Effect path
|
||||
|
||||
matrix uTransformMatrix;
|
||||
float uTime;
|
||||
|
||||
struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
{
|
||||
VertexShaderOutput output;
|
||||
output.Position = mul(input.Position, uTransformMatrix);
|
||||
output.Color = input.Color;
|
||||
output.TextureCoordinates = input.TextureCoordinates;
|
||||
return output;
|
||||
}
|
||||
|
||||
float hash21(float2 p)
|
||||
{
|
||||
p = frac(p * float2(123.34, 456.21));
|
||||
p += dot(p, p + 45.32);
|
||||
return frac(p.x * p.y);
|
||||
}
|
||||
|
||||
float noise(float2 p)
|
||||
{
|
||||
float2 i = floor(p);
|
||||
float2 f = frac(p);
|
||||
float2 u = f * f * (3.0 - 2.0 * f);
|
||||
|
||||
return lerp(
|
||||
lerp(hash21(i), hash21(i + float2(1.0, 0.0)), u.x),
|
||||
lerp(hash21(i + float2(0.0, 1.0)), hash21(i + float2(1.0, 1.0)), u.x),
|
||||
u.y
|
||||
);
|
||||
}
|
||||
|
||||
float slashMask(float2 uv, float thickness, float feather)
|
||||
{
|
||||
float d = abs(uv.y);
|
||||
return smoothstep(thickness + feather, thickness, d);
|
||||
}
|
||||
|
||||
float3 chromaSlash(float2 uv, float time)
|
||||
{
|
||||
float thickness = 0.02;
|
||||
float feather = 0.08;
|
||||
|
||||
float distort = noise(float2(uv.x * 8.0, time * 6.0)) * 0.05;
|
||||
uv.y += distort * slashMask(uv, thickness * 2.0, feather);
|
||||
|
||||
float aberr = 0.015;
|
||||
float r = slashMask(uv + float2( aberr, 0.0), thickness, feather);
|
||||
float g = slashMask(uv, thickness, feather);
|
||||
float b = slashMask(uv + float2(-aberr, 0.0), thickness, feather);
|
||||
|
||||
float3 col = float3(r, g, b);
|
||||
|
||||
float core = slashMask(uv, thickness * 0.4, feather * 0.2);
|
||||
col += core * float3(1.2, 1.3, 1.5);
|
||||
|
||||
float glow = slashMask(uv, thickness * 3.5, feather * 2.0);
|
||||
col += glow * float3(0.3, 0.6, 1.0);
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
|
||||
{
|
||||
float2 uv = input.TextureCoordinates * 2.0 - 1.0;
|
||||
|
||||
float time = uTime;
|
||||
float3 col = chromaSlash(uv, time);
|
||||
|
||||
float flicker = 0.85 + 0.15 * sin(time * 40.0);
|
||||
col *= flicker;
|
||||
|
||||
float edgeFade = smoothstep(1.0, 0.3, abs(uv.x));
|
||||
col *= edgeFade;
|
||||
|
||||
col *= input.Color.rgb;
|
||||
|
||||
float alpha = max(col.r, max(col.g, col.b)) * input.Color.a;
|
||||
return float4(col, alpha);
|
||||
}
|
||||
|
||||
technique Technique1
|
||||
{
|
||||
pass SlashPass
|
||||
{
|
||||
VertexShader = compile vs_2_0 VertexShaderFunction();
|
||||
PixelShader = compile ps_3_0 PixelShaderFunction();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
File diff suppressed because it is too large.
Load diff
@@ -2,13 +2,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CalamityMod.Buffs.StatDebuffs;
|
||||
using CalamityMod.Effects;
|
||||
using CalamityMod.Graphics.Primitives;
|
||||
using CalamityMod.Items.Weapons.Melee;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using static CalamityMod.CalamityUtils;
|
||||
@@ -219,10 +220,6 @@ namespace CalamityMod.Projectiles.Melee
|
||||
return false;
|
||||
}
|
||||
|
||||
public float SlashWidthFunction(float completionRatio, Vector2 vertexPos) => Projectile.scale * 22f;
|
||||
|
||||
public Color SlashColorFunction(float completionRatio, Vector2 vertexPos) => Color.Lime * Utils.GetLerpValue(0.9f, 0.4f, completionRatio, true) * Projectile.Opacity;
|
||||
|
||||
public IEnumerable<Vector2> GenerateSlashPoints()
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
@@ -239,16 +236,45 @@ namespace CalamityMod.Projectiles.Melee
|
||||
|
||||
public void DrawSlash()
|
||||
{
|
||||
// Draw the slash effect.
|
||||
Main.spriteBatch.EnterShaderRegion();
|
||||
if (SwingCompletionAtStartOfTrail <= SwingCompletionRatio)
|
||||
return;
|
||||
|
||||
// Prepare shader parameters. This relies on the same shader as the Exoblade, albeit with a less contrasted palette.
|
||||
PrepareSlashShader(Direction == 1);
|
||||
var slashPoints = GenerateSlashPoints().ToArray();
|
||||
var path = new List<Vector3>();
|
||||
for (int i = 0; i < slashPoints.Length; i++)
|
||||
{
|
||||
Vector2 screenPos = Projectile.Center + slashPoints[i] - Main.screenPosition;
|
||||
path.Add(new Vector3(screenPos, 0f));
|
||||
}
|
||||
|
||||
if (SwingCompletionAtStartOfTrail > SwingCompletionRatio)
|
||||
PrimitiveRenderer.RenderTrail(GenerateSlashPoints().ToArray(), new(SlashWidthFunction, SlashColorFunction, (_,_) => Projectile.Center, shader: GameShaders.Misc["CalamityMod:ExobladeSlash"]), 95);
|
||||
if (path.Count < 2)
|
||||
return;
|
||||
|
||||
Main.spriteBatch.ExitShaderRegion();
|
||||
float width = Projectile.scale * 22f;
|
||||
PrimitiveMesh mesh = TriangleStripBuilder.BuildStrip(
|
||||
path,
|
||||
_ => width,
|
||||
Color.White,
|
||||
textured: true,
|
||||
smoothingSegments: 4);
|
||||
|
||||
Effect shader = CalamityShaders.NanoblackSlashShader.Value;
|
||||
shader.Parameters["uTime"]?.SetValue((float)Main.gameTimeCache.TotalGameTime.TotalSeconds);
|
||||
|
||||
Matrix view = Main.GameViewMatrix.ZoomMatrix;
|
||||
Matrix projection = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -1f, 1f);
|
||||
|
||||
Main.spriteBatch.End(out var ss);
|
||||
|
||||
SanePrimitiveRenderer.DrawMesh(
|
||||
Matrix.Identity,
|
||||
view,
|
||||
projection,
|
||||
mesh,
|
||||
shader,
|
||||
blendState: BlendState.Additive);
|
||||
|
||||
Main.spriteBatch.Begin(ss);
|
||||
}
|
||||
|
||||
public void DrawBlade(Color lightColor)
|
||||
@@ -262,16 +288,6 @@ namespace CalamityMod.Projectiles.Melee
|
||||
SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
|
||||
Main.spriteBatch.Draw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, direction, 0f);
|
||||
}
|
||||
|
||||
public static void PrepareSlashShader(bool flipped)
|
||||
{
|
||||
GameShaders.Misc["CalamityMod:ExobladeSlash"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/VoronoiShapes"));
|
||||
GameShaders.Misc["CalamityMod:ExobladeSlash"].UseColor(Terratomere.TerraColor1);
|
||||
GameShaders.Misc["CalamityMod:ExobladeSlash"].UseSecondaryColor(Terratomere.TerraColor2);
|
||||
GameShaders.Misc["CalamityMod:ExobladeSlash"].Shader.Parameters["fireColor"].SetValue(Terratomere.TerraColor1.ToVector3());
|
||||
GameShaders.Misc["CalamityMod:ExobladeSlash"].Shader.Parameters["flipped"].SetValue(flipped);
|
||||
GameShaders.Misc["CalamityMod:ExobladeSlash"].Apply();
|
||||
}
|
||||
#endregion Drawing
|
||||
|
||||
#region Hit Effects and Collision
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using CalamityMod.Effects;
|
||||
using CalamityMod.Graphics.Primitives;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Melee
|
||||
@@ -39,25 +41,50 @@ namespace CalamityMod.Projectiles.Melee
|
||||
Projectile.scale *= 1.01f;
|
||||
}
|
||||
|
||||
public float SlashWidthFunction(float completionRatio, Vector2 vertexPos) => Projectile.scale * 22f;
|
||||
|
||||
public Color SlashColorFunction(float completionRatio, Vector2 vertexPos) => Color.Lime * Utils.GetLerpValue(0.04f, 0.27f, completionRatio, true) * Projectile.Opacity;
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
// Draw the slash effect.
|
||||
Main.spriteBatch.EnterShaderRegion();
|
||||
|
||||
TerratomereHoldoutProj.PrepareSlashShader(Flipped);
|
||||
if (ControlPoints == null || ControlPoints.Length < 2)
|
||||
return false;
|
||||
|
||||
List<Vector2> points = new List<Vector2>();
|
||||
var path = new List<Vector3>();
|
||||
for (int i = 0; i < ControlPoints.Length; i++)
|
||||
points.Add(ControlPoints[i] + ControlPoints[i].SafeNormalize(Vector2.Zero) * (Projectile.scale - 1f) * 40f);
|
||||
{
|
||||
Vector2 worldPos = Projectile.Center + ControlPoints[i] + ControlPoints[i].SafeNormalize(Vector2.Zero) * (Projectile.scale - 1f) * 40f;
|
||||
Vector2 screenPos = worldPos - Main.screenPosition;
|
||||
path.Add(new Vector3(screenPos, 0f));
|
||||
}
|
||||
|
||||
// 17MAY2024: Ozzatron: remove Terratomere rendering its trails multiple times
|
||||
PrimitiveRenderer.RenderTrail(points, new(SlashWidthFunction, SlashColorFunction, (_,_) => Projectile.Center, shader: GameShaders.Misc["CalamityMod:ExobladeSlash"]), 65);
|
||||
if (path.Count < 2)
|
||||
return false;
|
||||
|
||||
float width = Projectile.scale * 40f;
|
||||
Color trailColor = Color.White * Projectile.Opacity;
|
||||
|
||||
PrimitiveMesh mesh = TriangleStripBuilder.BuildStrip(
|
||||
path,
|
||||
_ => width,
|
||||
trailColor,
|
||||
textured: true,
|
||||
smoothingSegments: 4);
|
||||
|
||||
Effect shader = CalamityShaders.NanoblackSlashShader.Value;
|
||||
shader.Parameters["uTime"]?.SetValue((float)Main.gameTimeCache.TotalGameTime.TotalSeconds);
|
||||
|
||||
Matrix view = Main.GameViewMatrix.ZoomMatrix;
|
||||
Matrix projection = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -1f, 1f);
|
||||
|
||||
Main.spriteBatch.End(out var ss);
|
||||
|
||||
SanePrimitiveRenderer.DrawMesh(
|
||||
Matrix.Identity,
|
||||
view,
|
||||
projection,
|
||||
mesh,
|
||||
shader,
|
||||
blendState: BlendState.Additive);
|
||||
|
||||
Main.spriteBatch.Begin(ss);
|
||||
|
||||
Main.spriteBatch.ExitShaderRegion();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
using CalamityMod.Items.Weapons.Melee;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CalamityMod.Effects;
|
||||
using CalamityMod.Graphics.Primitives;
|
||||
using CalamityMod.Items.Weapons.Melee;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Melee
|
||||
@@ -9,7 +16,17 @@ namespace CalamityMod.Projectiles.Melee
|
||||
public class TerratomereSlash : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Melee";
|
||||
public override string Texture => "CalamityMod/Projectiles/Melee/ExobeamSlash";
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
private const int MaxTrailPoints = 20;
|
||||
private const int Lifetime = 35;
|
||||
private const float StripWidth = 30f;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ProjectileID.Sets.TrailingMode[Type] = 2;
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = MaxTrailPoints;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
@@ -21,7 +38,7 @@ namespace CalamityMod.Projectiles.Melee
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.penetrate = 2;
|
||||
Projectile.Opacity = 1f;
|
||||
Projectile.timeLeft = 35;
|
||||
Projectile.timeLeft = Lifetime;
|
||||
Projectile.MaxUpdates = 2;
|
||||
Projectile.scale = 0.75f;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
@@ -32,8 +49,8 @@ namespace CalamityMod.Projectiles.Melee
|
||||
public override void AI()
|
||||
{
|
||||
Projectile.rotation = Projectile.velocity.ToRotation();
|
||||
Projectile.Opacity = Projectile.timeLeft / 35f;
|
||||
if (Projectile.timeLeft == 34)
|
||||
Projectile.Opacity = Projectile.timeLeft / (float)Lifetime;
|
||||
if (Projectile.timeLeft == Lifetime - 1)
|
||||
{
|
||||
Particle spark2 = new GlowSparkParticle(Projectile.Center, new Vector2(0.1f, 0.1f).RotatedByRandom(100), false, 12, Main.rand.NextFloat(0.05f, 0.09f), Main.rand.NextBool() ? Terratomere.TerraColor1 : Terratomere.TerraColor2, new Vector2(2, 0.5f), true);
|
||||
GeneralParticleHandler.SpawnParticle(spark2);
|
||||
@@ -44,10 +61,52 @@ namespace CalamityMod.Projectiles.Melee
|
||||
|
||||
public override bool ShouldUpdatePosition() => true;
|
||||
|
||||
public override Color? GetAlpha(Color lightColor) => Color.Lerp(Color.Cyan, Color.Lime, Projectile.identity / 7f % 1f) * Projectile.Opacity;
|
||||
public override Color? GetAlpha(Color lightColor) => Color.Lerp(Terratomere.TerraColor1, Terratomere.TerraColor2, Projectile.identity / 7f % 1f) * Projectile.Opacity;
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
var path = new List<Vector3>();
|
||||
for (int i = 0; i < Projectile.oldPos.Length; i++)
|
||||
{
|
||||
Vector2 pos = Projectile.oldPos[i];
|
||||
if (pos == Vector2.Zero)
|
||||
break;
|
||||
|
||||
Vector2 screenPos = pos + Projectile.Size * 0.5f - Main.screenPosition;
|
||||
path.Add(new Vector3(screenPos, 0f));
|
||||
}
|
||||
|
||||
if (path.Count < 2)
|
||||
return false;
|
||||
|
||||
Color trailColor = Color.Lerp(Terratomere.TerraColor1, Terratomere.TerraColor2, Projectile.identity / 7f % 1f) * Projectile.Opacity;
|
||||
|
||||
float width = StripWidth * Projectile.scale;
|
||||
PrimitiveMesh mesh = TriangleStripBuilder.BuildStrip(
|
||||
path,
|
||||
progress => width * (1f - progress * 0.6f),
|
||||
trailColor,
|
||||
textured: true,
|
||||
smoothingSegments: 2);
|
||||
|
||||
Effect shader = CalamityShaders.NanoblackSlashShader.Value;
|
||||
shader.Parameters["uTime"]?.SetValue((float)Main.gameTimeCache.TotalGameTime.TotalSeconds);
|
||||
|
||||
Matrix view = Main.GameViewMatrix.ZoomMatrix;
|
||||
Matrix projection = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -1f, 1f);
|
||||
|
||||
Main.spriteBatch.End(out var ss);
|
||||
|
||||
SanePrimitiveRenderer.DrawMesh(
|
||||
Matrix.Identity,
|
||||
view,
|
||||
projection,
|
||||
mesh,
|
||||
shader,
|
||||
blendState: BlendState.Additive);
|
||||
|
||||
Main.spriteBatch.Begin(ss);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user