70 lines
1.9 KiB
HLSL
70 lines
1.9 KiB
HLSL
sampler uImage0 : register(s0);
|
|
sampler uImage1 : register(s1);
|
|
sampler uImage2 : register(s2);
|
|
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;
|
|
float2 TextureCoordinates : TEXCOORD0;
|
|
};
|
|
|
|
struct VertexShaderOutput
|
|
{
|
|
float4 Position : SV_POSITION;
|
|
float4 Color : COLOR0;
|
|
float2 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;
|
|
float coordsFactor = 40;
|
|
if (uOpacity >= 0)
|
|
coordsFactor *= uOpacity;
|
|
|
|
float laserbeamCutoffOpacity = tex2D(uImage2, frac(coords * float2(coordsFactor, 1) - float2(uTime * 3.43, 0))).r;
|
|
laserbeamCutoffOpacity = laserbeamCutoffOpacity + tex2D(uImage1, coords * 0.3).r * 4.4;
|
|
|
|
float bloomOpacity = pow(sin(coords.y * 3.141), 4);
|
|
return color * bloomOpacity * laserbeamCutoffOpacity * 1.5;
|
|
}
|
|
|
|
technique Technique1
|
|
{
|
|
pass TrailPass
|
|
{
|
|
VertexShader = compile vs_2_0 VertexShaderFunction();
|
|
PixelShader = compile ps_2_0 PixelShaderFunction();
|
|
}
|
|
} |