diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index 2c713b7d57..11ea63dea7 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -1,4 +1,5 @@ using CalamityMod.Skies; +using Iced.Intel; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; @@ -176,6 +177,16 @@ namespace CalamityMod.Effects #region Aqua's Shaders internal static Effect CircularGradientWithEdge; #endregion + + // + // All below shaders were added by Amber + // Authorship goes to Toasty + // + + #region Amber's Shaders + internal static Effect PrimitiveClearShader; + #endregion + // Shorthand to register a loaded shader in Terraria's graphics engine // All shaders registered this way are accessible under GameShaders.Misc // They will use the prefix described above @@ -373,6 +384,11 @@ namespace CalamityMod.Effects CircularGradientWithEdge = LoadShader("CircularGradientWithEdge"); RegisterMiscShader(CircularGradientWithEdge, "CircularGradientWithEdgePass", "CircularGradientWithEdge"); #endregion + + #region Loading Amber's Shaders + PrimitiveClearShader = LoadShader("PrimitiveClearShader"); + RegisterScreenShader(PrimitiveClearShader, "SightLinePass", "PrimitiveClearShader"); + #endregion } } } diff --git a/Effects/PrimitiveClearShader.fx b/Effects/PrimitiveClearShader.fx new file mode 100644 index 0000000000..e3b06a7741 --- /dev/null +++ b/Effects/PrimitiveClearShader.fx @@ -0,0 +1,43 @@ +sampler mainImage : register(s0); +matrix uWorldViewProjection; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float2 TextureCoordinates : TEXCOORD0; + float4 Color : COLOR0; +}; + +struct VertexShaderOutput +{ + float4 Position : POSITION0; + float2 TextureCoordinates : TEXCOORD0; + float4 Color : COLOR0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output = (VertexShaderOutput) 0; + output.Color = input.Color; + output.Position = mul(input.Position, uWorldViewProjection); + output.TextureCoordinates = input.TextureCoordinates; + return output; +} + +float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 +{ + float4 color = input.Color; + float2 coords = input.TextureCoordinates; + + float4 pixel = tex2D(mainImage, coords); + return color * pixel; +} + +technique Technique1 +{ + pass AutoloadPass + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/PrimitiveClearShader.xnb b/Effects/PrimitiveClearShader.xnb new file mode 100644 index 0000000000..2e8b98b734 Binary files /dev/null and b/Effects/PrimitiveClearShader.xnb differ diff --git a/Projectiles/Melee/BladecrestOathswordProj.cs b/Projectiles/Melee/BladecrestOathswordProj.cs index 88f544a91c..4e0b5e15f9 100644 --- a/Projectiles/Melee/BladecrestOathswordProj.cs +++ b/Projectiles/Melee/BladecrestOathswordProj.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework; using System; using System.IO; using Terraria; +using Terraria.Graphics.Effects; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.Localization; @@ -179,30 +180,6 @@ namespace CalamityMod.Projectiles.Melee } } - public override bool PreDraw(ref Color lightColor) - { - Main.spriteBatch.EnterShaderRegion(); - - CalamityUtils.CalculatePerspectiveMatricies(out Matrix viewMatrix, out Matrix projectionMatrix); - - GameShaders.Misc["CalamityMod:LinearTransformation"].UseColor(Main.hslToRgb(0.95f, 0.85f, 0.5f)); - GameShaders.Misc["CalamityMod:LinearTransformation"].UseOpacity(0f); - GameShaders.Misc["CalamityMod:LinearTransformation"].Shader.Parameters["uWorldViewProjection"].SetValue(viewMatrix * projectionMatrix); - GameShaders.Misc["CalamityMod:LinearTransformation"].Shader.Parameters["localMatrix"].SetValue(new Matrix() - { - M11 = BladeHorizontalFactor, - M12 = 0f, - M21 = 0f, - M22 = 1f, - }); - GameShaders.Misc["CalamityMod:LinearTransformation"].Apply(); - - CalamityUtils.DrawAfterimagesCentered(Projectile, 2, lightColor); - Main.spriteBatch.ExitShaderRegion(); - - return false; - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { ItemLoader.OnHitNPC(Owner.ActiveItem(), Owner, target, hit, damageDone);