Added Auric Dye

This commit is contained in:
DominicKarma committed 2021-10-04 22:41:23 -05:00
1 parent 23344c4f09
commit 921739d2dc
6 files changed
+95 -2

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
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;
float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0
{
// Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom.
float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w;
float twinkleOffset = frac(uTime * 0.51);
float3 goldColor = float3(228 / 255.0, 175 / 255.0, 72 / 255.0);
float4 noiseColor = tex2D(uImage1, float2(coords.x, sin(3.141 * frac(frameY + twinkleOffset))) * 0.067);
float4 color = tex2D(uImage0, coords);
float shineFactor = pow(noiseColor.r, 0.8);
color *= lerp(0.7, 5, shineFactor);
float3 metalColor = lerp(uColor, uSecondaryColor, shineFactor);
color.rgb = lerp(color.rgb, metalColor, lerp(0.35, 0.8, shineFactor));
color.rgb = (length(color.rgb) <= 0.5) ? 2 * color.rgb * goldColor : 1 - 2 * (1 - color.rgb) * (1 - goldColor);
return (color + noiseColor * 0.45) * color.a;
}
technique Technique1
{
pass DyePass
{
PixelShader = compile ps_2_0 PixelShaderFunction();
}
}
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

+38
View File
@@ -0,0 +1,38 @@
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables.Ores;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Dyes
{
public class AuricDye : BaseDye
{
public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref<Effect>(mod.GetEffect("Effects/Dyes/AuricDyeShader")), "DyePass").
UseColor(new Color(170, 96, 60)).UseSecondaryColor(new Color(226, 196, 106)).SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/SharpNoise"));
public override void SafeSetStaticDefaults()
{
DisplayName.SetDefault("Auric Dye");
}
public override void SafeSetDefaults()
{
item.rare = ItemRarityID.Purple;
item.Calamity().customRarity = CalamityRarity.Violet;
item.value = Item.sellPrice(0, 9, 0, 0);
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.BottledWater);
recipe.AddIngredient(ModContent.ItemType<AuricOre>(), 5);
recipe.AddTile(TileID.DyeVat);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

+18 -2
View File
@@ -469,14 +469,30 @@ namespace CalamityMod
}
// Cached for efficiency purposes.
internal static readonly FieldInfo UImageField = typeof(MiscShaderData).GetField("_uImage", BindingFlags.NonPublic | BindingFlags.Instance);
internal static readonly FieldInfo UImageFieldMisc = typeof(MiscShaderData).GetField("_uImage", BindingFlags.NonPublic | BindingFlags.Instance);
internal static readonly FieldInfo UImageFieldArmor = typeof(ArmorShaderData).GetField("_uImage", BindingFlags.NonPublic | BindingFlags.Instance);
/// <summary>
/// Manually sets the texture of a <see cref="MiscShaderData"/> instance, since vanilla's implementation only supports strings that access vanilla textures.
/// </summary>
/// <param name="shader">The shader to bind the texture to.</param>
/// <param name="texture">The texture to bind.</param>
public static void SetShaderTexture(this MiscShaderData shader, Texture2D texture) => UImageField.SetValue(shader, new Ref<Texture2D>(texture));
public static MiscShaderData SetShaderTexture(this MiscShaderData shader, Texture2D texture)
{
UImageFieldMisc.SetValue(shader, new Ref<Texture2D>(texture));
return shader;
}
/// <summary>
/// Manually sets the texture of a <see cref="ArmorShaderData"/> instance, since vanilla's implementation only supports strings that access vanilla textures.
/// </summary>
/// <param name="shader">The shader to bind the texture to.</param>
/// <param name="texture">The texture to bind.</param>
public static ArmorShaderData SetShaderTexture(this ArmorShaderData shader, Texture2D texture)
{
UImageFieldArmor.SetValue(shader, new Ref<Texture2D>(texture));
return shader;
}
public static void EnterShaderRegion(this SpriteBatch spriteBatch)
{