Coral Spout uses a shader + EasyXNB is here

This commit is contained in:
IbanPlay committed 2022-06-14 06:16:17 +02:00
1 parent be4021142e
commit df2e8bc9ca
13 files changed
+160 -10

No files matched your search

+5
View File
@@ -115,6 +115,11 @@ namespace CalamityMod.Effects
GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"] = new MiscShaderData(new Ref<Effect>(AdditiveFusableParticleEdgeShader), "ParticlePass");
GameShaders.Misc["CalamityMod:DoGPortal"] = new MiscShaderData(new Ref<Effect>(DoGPortalShader), "ScreenPass");
//A little experimenting courtesy of looking at how slr does it.
var screenRef = new Ref<Effect>(CalamityMod.Instance.Assets.Request<Effect>("Effects/SpreadTelegraph", AssetRequestMode.ImmediateLoad).Value);
Filters.Scene["SpreadTelegraph"] = new Filter(new ScreenShaderData(screenRef, "TelegraphPass"), EffectPriority.High);
Filters.Scene["SpreadTelegraph"].Load();
}
}
}
Binary file not shown.
+46
View File
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<!--Should fonts be compiled. => | true | false |-->
<add key="CompileFonts" value="false" />
<!--Should materials be compiled seperately, or included with the model. => | true | false |-->
<add key="CompileMaterialsSeperate" value="false" />
<!--Should textures be compiled. => | true | false |-->
<add key="CompileTextures" value="true" />
<!--Should pngs be ignored when compiling textures. => | true | false |-->
<add key="IgnorePng" value="true" />
<!--Target profile options. => | HiDef | Reach |-->
<add key="TargetProfile" value="HiDef" />
<!--Compress output options. => | true | false |-->
<add key="CompressOutput" value="false" />
<!--Full path to input folder. Default => | default |-->
<add key="InputDirectory" value="default" />
<!--Full path to intermediate folder. Default => | default |-->
<!--Note: This in unimportant.-->
<add key="IntermediateDirectory" value="default" />
<!--Full path to output folder. Default => | default |-->
<add key="OutputDirectory" value="default" />
<!--Should files be rebuilt if an xnb already exists. => | true | false |-->
<!--Warning: If this is disabled content will not be rebuilt even if the xnb is out-of-date-->
<add key="RebuildAll" value="true" />
<!--Scale multiplier for compiled models. Default => | 1f |-->
<add key="ModelScale" value="1.0" />
<!--Should the vertex winding order be swapped for compiled models. Default => | false |-->
<add key="ModelSwapWindingOrder" value="false" />
<!--Should tangents be generated for compiled models. Default => | false |-->
<!--Note: Will increase file size, but is needed for normal/bump mapping.-->
<add key="ModelGenerateTangentFrames" value="false" />
<!--Should the output be shader bytecode (.fxc file) instead of compiling it into a xnb. Default => | false |-->
<add key="OutputEffectBytecode" value="false" />
<!--The file extension for the output file type, the default for some is xnc since terraria prevents the loading of most .xnb files-->
<!--Note: Include the period-->
<add key="EffectExtension" value=".xnb" />
<add key="FontExtension" value=".xnb" />
<add key="TextureExtension" value=".xnc" />
<add key="ModelExtension" value=".xnc" />
<add key="MaterialExtension" value=".xnc" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
Binary file not shown.
Binary file not shown.
+91
View File
@@ -0,0 +1,91 @@
float3 edgeColor;
float3 centerColor;
float edgeBlendLenght;
float edgeBlendStrength;
float mainOpacity;
float centerOpacity;
float halfSpreadAngle;
texture sampleTexture;
sampler2D Texture1Sampler = sampler_state { texture = <sampleTexture>; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = wrap; AddressV = wrap; };
//I can't believe it has gotten down to this.
float realCos(float value)
{
return sin(value + 1.57079);
}
//Gets the distance of a plot from a line with a specified origin and angle
float distanceFromLine(float2 origin, float angle, float2 plot)
{
return abs(realCos(angle) * (origin.y - plot.y) - sin(angle) * (origin.x - plot.x));
}
//Gets the distance of a plot from a line with a specified origin and angle, but crops the line so it only expands towards the angle
float distanceFromLineCropped(float2 origin, float angle, float2 plot, float plotAngle)
{
//If the angle between the line's angle and the plot's angle is less than 90° (aka , not BEHIND the half-line), return the distance from the line
if (abs(angle - plotAngle) < 1.5707)
return distanceFromLine(origin, angle, plot);
//If we are behind the line, just give the distance between the start point and the plot
else
return length(origin - plot);
}
float4 main(float2 uv : TEXCOORD) : COLOR
{
//Set the uv's Y position to be only contained within the upper half of the texture, to mirror it around a horizontal axis
if (uv.y > 0.5)
uv.y = 1 - uv.y;
float2 mappedUv = float2(uv.x - 0.5, abs(uv.y - 0.5));
//get the length of the doubled distance, so that 0 = at the center of the sprite and 1 = at the very edge of the circle
float distanceFromCenter = length(mappedUv) * 2;
//Crop the sprite into a circle
if (distanceFromCenter > 1)
return float4(0, 0, 0, 0);
//Grabs the angle (only as a positive angle, since it's a mirror image udnerneath.
float angle = atan2(mappedUv.y, mappedUv.x);
//Grabs the distance of the point from the edge line.
float distanceFromLine = distanceFromLineCropped(float2(0, 0), halfSpreadAngle, mappedUv, angle);
//Grab the colors to blend the edge lines with.
float3 colour = float3(0, 0, 0);
float opacity = 0;
//If we are inside the spread's radius.
if (angle <= halfSpreadAngle)
{
colour = lerp(centerColor, edgeColor, pow(angle / halfSpreadAngle, 9));
opacity = centerOpacity * pow(1 - distanceFromCenter, 2);
}
//If we are further from the line than the edge's blending lenght, just don't even do the blending.
if (distanceFromLine > edgeBlendLenght)
return float4(colour * opacity * mainOpacity, opacity * mainOpacity);
//The higher this value is, the more we blend with the edge's opacity & color.
float edgeBlendFactor = pow(1 - distanceFromLine / edgeBlendLenght, edgeBlendStrength);
colour = lerp(colour, edgeColor, edgeBlendFactor);
opacity = lerp(opacity, 1 * pow(1 - distanceFromCenter, 3), edgeBlendFactor) * mainOpacity;
colour = colour * opacity;
return float4(colour, opacity);
}
technique Technique1
{
pass TelegraphPass
{
PixelShader = compile ps_3_0 main();
}
}
Binary file not shown.
+18 -10
View File
@@ -7,6 +7,8 @@ using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
namespace CalamityMod.Projectiles.Magic
@@ -82,17 +84,23 @@ namespace CalamityMod.Projectiles.Magic
public override bool PreDraw(ref Color lightColor)
{
var effect = Filters.Scene["SpreadTelegraph"].GetShader().Shader;
effect.Parameters["centerOpacity"].SetValue(0.7f);
effect.Parameters["mainOpacity"].SetValue((float)Math.Sqrt(ChargeProgress));
effect.Parameters["halfSpreadAngle"].SetValue(Spread / 2f);
effect.Parameters["edgeColor"].SetValue(Color.DeepSkyBlue.ToVector3());
effect.Parameters["centerColor"].SetValue(Color.DodgerBlue.ToVector3());
effect.Parameters["edgeBlendLenght"].SetValue(0.07f);
effect.Parameters["edgeBlendStrength"].SetValue(8f);
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, effect, Main.GameViewMatrix.TransformationMatrix);
Texture2D texture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/InvisibleProj").Value;
Texture2D texture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Summon/DeathstareBeam").Value;
for (int i = -1; i <= 1; i += 2)
{
float angle = (Owner.MountedCenter - Owner.Calamity().mouseWorld).ToRotation() + (Spread / 2f) * i - MathHelper.PiOver2;
Vector2 scale = new Vector2(0.2f, 1f) * 3f;
Main.EntitySpriteDraw(texture, Owner.MountedCenter - Main.screenPosition, null, Color.DodgerBlue * 0.5f * (float)Math.Sqrt(ChargeProgress), angle, new Vector2(texture.Width / 2f, texture.Height), scale, 0, 0);
}
float angle = (Owner.Calamity().mouseWorld - Owner.MountedCenter).ToRotation();
Main.EntitySpriteDraw(texture, Owner.MountedCenter - Main.screenPosition, null, Color.White, angle, new Vector2(texture.Width / 2f, texture.Height/2f), 700f, 0, 0);
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
@@ -111,7 +119,7 @@ namespace CalamityMod.Projectiles.Magic
for (int i = 0; i < ShotProjectiles; i++)
{
float angleOffset = MathHelper.Lerp(Spread * -0.5f, Spread * 0.5f, i / (float)ShotProjectiles);
float angleOffset = MathHelper.Lerp(Spread * -0.5f, Spread * 0.5f, i / ((float)ShotProjectiles - 1));
Vector2 direction = (mainAngle + angleOffset).ToRotationVector2();
if (Owner.whoAmI == Main.myPlayer)