Files
CalamityModPublic/Effects/SylvestaffProjectileShader.fx
T
2025-05-28 18:48:13 -07:00

77 lines
2.0 KiB
HLSL

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;
matrix uWorldViewProjection;
float4 uShaderSpecificData;
struct VertexShaderInput
{
float4 Position : POSITION0;
float4 Color : COLOR0;
float3 TextureCoordinates : TEXCOORD0;
};
struct VertexShaderOutput
{
float4 Position : SV_POSITION;
float4 Color : COLOR0;
float3 TextureCoordinates : TEXCOORD0;
};
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
{
VertexShaderOutput output = (VertexShaderOutput) 0;
float4 pos = mul(input.Position, uWorldViewProjection);
output.Position = pos;
output.Color = input.Color;
output.TextureCoordinates = input.TextureCoordinates;
return output;
}
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
float4 color = input.Color;
float2 coords = input.TextureCoordinates;
// Account for texture distortion artifacts.
coords.y = (coords.y - 0.5) / input.TextureCoordinates.z + 0.5;
float bump = sin(coords.y * 3.141);
// Calculate the amount of additive glow for this pixel, using a combination of a scrolling texture and an extreme
// exponential squash of the prior 0-1-0 bump, creating a "center" to the glow and ensuring that the
// ray doesn't look like just a scrolling gradient.
float streakColor = tex2D(uImage1, coords + float2(uTime * -2.75, 0));
float glow = streakColor.r + pow(bump, 20) * 0.4;
// Determine opacity based on a weaker exponential squash of the bump in order to create faded horizontal edges.
float opacity = pow(bump, 5);
// Apply glow.
opacity += glow * opacity;
return color * opacity;
}
technique Technique1
{
pass TrailPass
{
VertexShader = compile vs_2_0 VertexShaderFunction();
PixelShader = compile ps_2_0 PixelShaderFunction();
}
}