From 3f60d749e94889899fc87fbdab05c2c8a158d52a Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 8 Oct 2021 18:56:36 -0500 Subject: [PATCH] Added Exo Dye --- Effects/Dyes/ExoDyeShader.fx | 69 ++++++++++++++++++++++++++++++++++ Effects/Dyes/ExoDyeShader.xnb | Bin 0 -> 3800 bytes Items/Dyes/ExoDye.cs | 39 +++++++++++++++++++ Items/Dyes/ExoDye.png | Bin 0 -> 382 bytes 4 files changed, 108 insertions(+) create mode 100644 Effects/Dyes/ExoDyeShader.fx create mode 100644 Effects/Dyes/ExoDyeShader.xnb create mode 100644 Items/Dyes/ExoDye.cs create mode 100644 Items/Dyes/ExoDye.png diff --git a/Effects/Dyes/ExoDyeShader.fx b/Effects/Dyes/ExoDyeShader.fx new file mode 100644 index 0000000000..763efe3d25 --- /dev/null +++ b/Effects/Dyes/ExoDyeShader.fx @@ -0,0 +1,69 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +float3 specialPalette[9] = +{ + float3(250, 255, 112) / 255.0, + float3(211, 235, 108) / 255.0, + float3(166, 240, 105) / 255.0, + float3(105, 240, 220) / 255.0, + float3(64, 130, 145) / 255.0, + float3(145, 96, 145) / 255.0, + float3(242, 112, 73) / 255.0, + float3(199, 62, 62) / 255.0, + float3(250, 255, 112) / 255.0, +}; + +float InverseLerp(float from, float to, float x) +{ + return saturate((x - from) / (to - from)); +} + +// Multi-color lerp which uses the palette. +float3 PaletteLerp(float interpolant) +{ + float startingIndex = floor(interpolant * 8); + float squashedInterpolant = frac(interpolant * 8); + return lerp(specialPalette[startingIndex], specialPalette[startingIndex + 1], squashedInterpolant); +} + +// (Co)sines use a lot of instructions. As such, a more linear wave constructed by moduli is used instead. +// Is this kind of ridiculous? Probably. But there's basically nothing I can do until 1.4 rolls around +// and the pathetically low instruction count cap is increased significantly. -Dominic +float FastPeriodicFunction(float x) +{ + if (x % 2 < 1) + return x % 2; + return -(x % 2) + 2; +} + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom. + float4 noiseColor = tex2D(uImage1, float2(coords.x, frameY - uTime * 0.45) * 0.1); + float4 color = tex2D(uImage0, coords); + float3 blendColor = PaletteLerp(frac(frameY + uTime * 1.3)); + float blendFactor = (FastPeriodicFunction(uTime * 9 + coords.x * 2 - frameY * 2.1) * 0.5 + 0.5) * 0.5; + float brightness = (blendFactor * 0.4 + noiseColor.r * 0.9) * 1.2; + + float4 colorBlendMultiplier = lerp(float4(blendColor, 1), float4(1, 1, 1, 1), saturate(blendFactor * 1.5)); + return (lerp(color, float4(blendColor, 1), blendFactor * 0.5 + 0.2) * color.a) * colorBlendMultiplier * (1 + brightness); +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/ExoDyeShader.xnb b/Effects/Dyes/ExoDyeShader.xnb new file mode 100644 index 0000000000000000000000000000000000000000..87e8fad776744e53a4634823a217d7a2478b6a54 GIT binary patch literal 3800 zcmbtWOKe+36rJZdtxMB7pQcnO5*9+JNWpSKf>Nom(v0ThL;mJZee7KaJwa*kwr^BPgf@2q)@S$wh z&N$H9>kW-o@=m2>4;So;Q%dK1Ly5}C zd@l2%y)aQcZ5M`z2KqDEp_6vsv^^LZ9DH7otO&CEX8XMx?NU`g);4ebLW`0g!^02m zQEKBi0I70pHhs#D2yHXcSXDyPrcZD?3+xy+8Z#iV6-s5am@k%uPp@Ay3^Zmyg1J|c zcBWXEPL~#xGwn#L>LGs_pG?{YuDmjr&g7g0>e{|d8vrxy+i0Imq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^R#W+{#&;IJYF+-T6RE>LSjI*X}RJ=~C zcZ$Ua%%We$roDwRK~!Zp7!z`thz{ z?|SXhXNk2RME+{t*Oo+JP3jhAjB{&2XOCOzGsu}^-&wPICp?#DL)|a-$h^9-r}E+4 zcrqsa)O*v+LBCVlpFM<)+l72p4XUm#)YR;g!ge9Xu14?GyD8wy7`R7}$C}G~@^4gB BgERmD literal 0 HcmV?d00001 diff --git a/Items/Dyes/ExoDye.cs b/Items/Dyes/ExoDye.cs new file mode 100644 index 0000000000..1e2f58d72c --- /dev/null +++ b/Items/Dyes/ExoDye.cs @@ -0,0 +1,39 @@ +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Dyes +{ + public class ExoDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind + { + get => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/ExoDyeShader")), "DyePass").UseImage("Images/Misc/Perlin"); + } + + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Exo Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; + item.value = Item.sellPrice(0, 10, 0, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater, 3); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this, 3); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Dyes/ExoDye.png b/Items/Dyes/ExoDye.png new file mode 100644 index 0000000000000000000000000000000000000000..6cc8ebfeec067dadb92aabbceac29ce1ab3f81c8 GIT binary patch literal 382 zcmV-^0fGLBP)Px$I7vi7R5*>*)W0jmVHC&l*H@Gn41VRum0VmRS(H(UvN8G#3`Vh_3^o}JMw2ob z3^p5O5K4aDFo;A_cVN&pd|kOH^1X}C@|@@CoZioQ&T~%SP3=uXAoX;f_CW$ar z?|eL#=a0(I7>}tdP+Q&$D%( z04In0X&4+H`POlDc@b2{8iHs09+0m70P`tbMMx4kI@p3Y(U!p7l+RcE0z87#_ z7k1C#x*QSLdTv3g^agA>?07Wdm+r`rKI?N|=5FTv cq{uVp6&Yt-cm0t%761SM07*qoM6N<$f_QbRy8r+H literal 0 HcmV?d00001