74 lines
2.1 KiB
HLSL
74 lines
2.1 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;
|
|
}
|
|
|
|
// The X coordinate is the trail completion, the Y coordinate is the same as any other.
|
|
// This is simply how the primitive TextCoord is layed out in the C# code.
|
|
// Inputted images go into uImage1 sampler, in case you have a noise map or something similar.
|
|
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 areaFadeGlow = lerp(1.2, 17, coords.x);
|
|
if (coords.x < 0.25)
|
|
areaFadeGlow = lerp(areaFadeGlow, 1.2, 1 - coords.x / 0.25);
|
|
float2 mapColor = tex2D(uImage1, float2(frac(coords.x - uTime * 4.2), coords.y));
|
|
float opacity = pow(sin(coords.y * 3.141), areaFadeGlow) + 0.6 * lerp(1.1, 0.3, coords.x) * mapColor.r;
|
|
|
|
if (coords.x > 0.66)
|
|
opacity = lerp(opacity, 0, (coords.x - 0.66) / 0.3);
|
|
|
|
return color * opacity;
|
|
}
|
|
|
|
technique Technique1
|
|
{
|
|
pass TrailPass
|
|
{
|
|
VertexShader = compile vs_2_0 VertexShaderFunction();
|
|
PixelShader = compile ps_2_0 PixelShaderFunction();
|
|
}
|
|
}
|