Fixing Primitive Width Function Distortions (#25)
* Change width storage definitions * Update primitive shaders
This commit is contained in:
1 parent
c4845d0606
commit
820898bd0c
42 files changed
+143
-90
No files matched your search
@@ -20,22 +20,21 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
{
|
||||
VertexShaderOutput output = (VertexShaderOutput)0;
|
||||
VertexShaderOutput output = (VertexShaderOutput) 0;
|
||||
float4 pos = mul(input.Position, uWorldViewProjection);
|
||||
output.Position = pos;
|
||||
|
||||
output.Color = input.Color;
|
||||
output.TextureCoordinates = input.TextureCoordinates;
|
||||
|
||||
@@ -52,6 +51,9 @@ 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;
|
||||
|
||||
// Read the fade map as a streak.
|
||||
float4 fadeMapColor = tex2D(uImage1, coords - float2(uTime * 0.6, 0));
|
||||
float opacity = fadeMapColor.r;
|
||||
@@ -63,7 +65,7 @@ technique Technique1
|
||||
{
|
||||
pass TrailPass
|
||||
{
|
||||
VertexShader = compile vs_2_0 VertexShaderFunction();
|
||||
PixelShader = compile ps_2_0 PixelShaderFunction();
|
||||
VertexShader = compile vs_3_0 VertexShaderFunction();
|
||||
PixelShader = compile ps_3_0 PixelShaderFunction();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -21,22 +21,21 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
{
|
||||
VertexShaderOutput output = (VertexShaderOutput)0;
|
||||
VertexShaderOutput output = (VertexShaderOutput) 0;
|
||||
float4 pos = mul(input.Position, uWorldViewProjection);
|
||||
output.Position = pos;
|
||||
|
||||
output.Color = input.Color;
|
||||
output.TextureCoordinates = input.TextureCoordinates;
|
||||
|
||||
@@ -55,6 +54,9 @@ 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;
|
||||
|
||||
// Read the fade map as a streak.
|
||||
float bloomFadeout = pow(sin(coords.y * 3.141), 4);
|
||||
float4 fadeMapColor = tex2D(uImage1, float2(frac(coords.x * 20 - uTime * 5.5), coords.y));
|
||||
|
||||
Binary file not shown.
@@ -19,22 +19,21 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
{
|
||||
VertexShaderOutput output = (VertexShaderOutput)0;
|
||||
VertexShaderOutput output = (VertexShaderOutput) 0;
|
||||
float4 pos = mul(input.Position, uWorldViewProjection);
|
||||
output.Position = pos;
|
||||
|
||||
output.Color = input.Color;
|
||||
output.TextureCoordinates = input.TextureCoordinates;
|
||||
|
||||
|
||||
Binary file not shown.
@@ -19,14 +19,14 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
@@ -34,7 +34,6 @@ 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;
|
||||
|
||||
@@ -47,6 +46,9 @@ 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;
|
||||
|
||||
// Read the fade map as a streak.
|
||||
float fadeMapY = frac(coords.x - uTime * 1.4 * uSaturation);
|
||||
float4 fadeMapColor = tex2D(uImage1, float2(coords.y, fadeMapY));
|
||||
|
||||
Binary file not shown.
@@ -20,14 +20,14 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
@@ -35,7 +35,6 @@ 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;
|
||||
|
||||
@@ -49,6 +48,10 @@ 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 coordsFactor = 40;
|
||||
if (uOpacity >= 0)
|
||||
coordsFactor *= uOpacity;
|
||||
|
||||
Binary file not shown.
@@ -23,14 +23,14 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
@@ -54,6 +54,10 @@ 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 bloomOpacity = pow(sin(coords.y * 3.141), 5.6);
|
||||
float noise = tex2D(uImage1, coords * 3 - float2(uTime * 2.44, 0));
|
||||
float brightnessStreak = tex2D(uImage2, coords * float2(2, 1) - float2(uTime * 1.61, 0)) + noise * bloomOpacity;
|
||||
|
||||
Binary file not shown.
@@ -23,22 +23,21 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
{
|
||||
VertexShaderOutput output = (VertexShaderOutput)0;
|
||||
VertexShaderOutput output = (VertexShaderOutput) 0;
|
||||
float4 pos = mul(input.Position, uWorldViewProjection);
|
||||
output.Position = pos;
|
||||
|
||||
output.Color = input.Color;
|
||||
output.TextureCoordinates = input.TextureCoordinates;
|
||||
|
||||
@@ -54,6 +53,10 @@ 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;
|
||||
|
||||
if (flipped)
|
||||
coords.y = 1 - coords.y;
|
||||
|
||||
@@ -103,7 +106,7 @@ technique Technique1
|
||||
{
|
||||
pass TrailPass
|
||||
{
|
||||
VertexShader = compile vs_2_0 VertexShaderFunction();
|
||||
PixelShader = compile ps_2_0 PixelShaderFunction();
|
||||
VertexShader = compile vs_3_0 VertexShaderFunction();
|
||||
PixelShader = compile ps_3_0 PixelShaderFunction();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -19,19 +19,19 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
{
|
||||
VertexShaderOutput output = (VertexShaderOutput)0;
|
||||
VertexShaderOutput output = (VertexShaderOutput) 0;
|
||||
float4 pos = mul(input.Position, uWorldViewProjection);
|
||||
output.Position = pos;
|
||||
|
||||
@@ -48,6 +48,9 @@ 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;
|
||||
|
||||
// Read the fade map as a streak.
|
||||
float4 fadeMapColor = tex2D(uImage1, float2(frac(coords.x - uTime * 2.5), coords.y));
|
||||
float opacity = fadeMapColor.r;
|
||||
|
||||
Binary file not shown.
@@ -20,22 +20,21 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
{
|
||||
VertexShaderOutput output = (VertexShaderOutput)0;
|
||||
VertexShaderOutput output = (VertexShaderOutput) 0;
|
||||
float4 pos = mul(input.Position, uWorldViewProjection);
|
||||
output.Position = pos;
|
||||
|
||||
output.Color = input.Color;
|
||||
output.TextureCoordinates = input.TextureCoordinates;
|
||||
|
||||
@@ -48,6 +47,10 @@ 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;
|
||||
|
||||
if (shouldFlip == 1)
|
||||
coords.y = 1 - coords.y;
|
||||
|
||||
|
||||
Binary file not shown.
+5
-3
@@ -19,14 +19,14 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
@@ -34,7 +34,6 @@ 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;
|
||||
|
||||
@@ -48,6 +47,9 @@ 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;
|
||||
|
||||
// Read the fade map as a streak.
|
||||
float4 fadeMapColor = tex2D(uImage1, float2(frac(coords.y), frac(coords.x - uTime * 1.4 * uSaturation)));
|
||||
fadeMapColor.r *= pow(coords.x, 0.04);
|
||||
|
||||
Binary file not shown.
@@ -19,14 +19,14 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
@@ -34,7 +34,6 @@ 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;
|
||||
|
||||
@@ -45,6 +44,10 @@ 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 distortion = lerp(-1, 1, tex2D(uImage1, coords + float2(0, uTime * sign(coords.y > 0.5 ? -1 : 1) * 1.81)).r);
|
||||
float opacity = pow(sin((coords.y + distortion * 0.15) * 3.141), distortion * 3.95 + 7);
|
||||
return color * pow(opacity, 0.25) + opacity;
|
||||
|
||||
Binary file not shown.
@@ -23,14 +23,14 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
@@ -38,7 +38,6 @@ 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;
|
||||
|
||||
@@ -54,6 +53,10 @@ 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 bloomOpacity = pow(sin(coords.y * 3.141), 5.6);
|
||||
float noise = tex2D(uImage1, coords * 3 - float2(uTime * 2.44, 0));
|
||||
float brightnessStreak = tex2D(uImage2, coords * float2(2, 1) - float2(uTime * 1.61, 0)) + noise * bloomOpacity;
|
||||
|
||||
Binary file not shown.
@@ -19,22 +19,21 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
{
|
||||
VertexShaderOutput output = (VertexShaderOutput)0;
|
||||
VertexShaderOutput output = (VertexShaderOutput) 0;
|
||||
float4 pos = mul(input.Position, uWorldViewProjection);
|
||||
output.Position = pos;
|
||||
|
||||
output.Color = input.Color;
|
||||
output.TextureCoordinates = input.TextureCoordinates;
|
||||
|
||||
@@ -48,6 +47,10 @@ 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;
|
||||
|
||||
// Fade out at the edges of the trail to give a blur effect.
|
||||
// This is very important.
|
||||
float flameStreakBrightness = tex2D(uImage1, float2(frac(coords.x - uTime * 2.9), coords.y)).r;
|
||||
|
||||
Binary file not shown.
@@ -19,22 +19,21 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
{
|
||||
VertexShaderOutput output = (VertexShaderOutput)0;
|
||||
VertexShaderOutput output = (VertexShaderOutput) 0;
|
||||
float4 pos = mul(input.Position, uWorldViewProjection);
|
||||
output.Position = pos;
|
||||
|
||||
output.Color = input.Color;
|
||||
output.TextureCoordinates = input.TextureCoordinates;
|
||||
|
||||
@@ -47,6 +46,10 @@ 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 slashMapColor = tex2D(uImage1, coords);
|
||||
float opacity = 1 - slashMapColor.r;
|
||||
return color * pow(opacity, 3);
|
||||
|
||||
Binary file not shown.
@@ -21,22 +21,21 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
{
|
||||
VertexShaderOutput output = (VertexShaderOutput)0;
|
||||
VertexShaderOutput output = (VertexShaderOutput) 0;
|
||||
float4 pos = mul(input.Position, uWorldViewProjection);
|
||||
output.Position = pos;
|
||||
|
||||
output.Color = input.Color;
|
||||
output.TextureCoordinates = input.TextureCoordinates;
|
||||
|
||||
@@ -46,9 +45,15 @@ VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
|
||||
{
|
||||
float4 color = input.Color;
|
||||
float2 coords = input.TextureCoordinates * uPrimitiveSize / uImageSize1;
|
||||
float2 baseCoords = input.TextureCoordinates.xy;
|
||||
|
||||
// Account for texture distortion artifacts.
|
||||
baseCoords.y = (baseCoords.y - 0.5) / input.TextureCoordinates.z + 0.5;
|
||||
|
||||
float2 coords = baseCoords * uPrimitiveSize / uImageSize1;
|
||||
|
||||
coords.x = 1 - frac(coords.x);
|
||||
coords.y = saturate(input.TextureCoordinates.y);
|
||||
coords.y = saturate(baseCoords.y);
|
||||
if (flipVertically)
|
||||
coords.y = 1 - coords.y;
|
||||
|
||||
|
||||
Binary file not shown.
@@ -4,23 +4,25 @@ matrix uWorldViewProjection;
|
||||
struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float4 Color : COLOR0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
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.Position = mul(input.Position, uWorldViewProjection);
|
||||
output.TextureCoordinates = input.TextureCoordinates;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -29,7 +31,10 @@ float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
|
||||
float4 color = input.Color;
|
||||
float2 coords = input.TextureCoordinates;
|
||||
|
||||
float4 pixel = tex2D(mainImage, coords);
|
||||
// Account for texture distortion artifacts.
|
||||
coords.y = (coords.y - 0.5) / input.TextureCoordinates.z + 0.5;
|
||||
|
||||
float4 pixel = tex2D(mainImage, coords);
|
||||
return color * pixel;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -19,22 +19,21 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
{
|
||||
VertexShaderOutput output = (VertexShaderOutput)0;
|
||||
VertexShaderOutput output = (VertexShaderOutput) 0;
|
||||
float4 pos = mul(input.Position, uWorldViewProjection);
|
||||
output.Position = pos;
|
||||
|
||||
output.Color = input.Color;
|
||||
output.TextureCoordinates = input.TextureCoordinates;
|
||||
|
||||
@@ -49,6 +48,9 @@ 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);
|
||||
|
||||
Binary file not shown.
@@ -19,22 +19,21 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
{
|
||||
VertexShaderOutput output = (VertexShaderOutput)0;
|
||||
VertexShaderOutput output = (VertexShaderOutput) 0;
|
||||
float4 pos = mul(input.Position, uWorldViewProjection);
|
||||
output.Position = pos;
|
||||
|
||||
output.Color = input.Color;
|
||||
output.TextureCoordinates = input.TextureCoordinates;
|
||||
|
||||
@@ -49,6 +48,9 @@ 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);
|
||||
|
||||
Binary file not shown.
@@ -19,22 +19,21 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
{
|
||||
VertexShaderOutput output = (VertexShaderOutput)0;
|
||||
VertexShaderOutput output = (VertexShaderOutput) 0;
|
||||
float4 pos = mul(input.Position, uWorldViewProjection);
|
||||
output.Position = pos;
|
||||
|
||||
output.Color = input.Color;
|
||||
output.TextureCoordinates = input.TextureCoordinates;
|
||||
|
||||
@@ -46,6 +45,10 @@ float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
|
||||
float innerBrightnessIntensity = 2.7;
|
||||
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 bloomOpacity = pow(cos(coords.y * 4.8 - 0.8), 55 + pow(coords.x, 4) * 700);
|
||||
|
||||
// Create some noisy opaque blotches in the inner part of the trail.
|
||||
@@ -66,7 +69,7 @@ technique Technique1
|
||||
{
|
||||
pass TrailPass
|
||||
{
|
||||
VertexShader = compile vs_2_0 VertexShaderFunction();
|
||||
PixelShader = compile ps_2_0 PixelShaderFunction();
|
||||
VertexShader = compile vs_3_0 VertexShaderFunction();
|
||||
PixelShader = compile ps_3_0 PixelShaderFunction();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -19,14 +19,14 @@ struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
float3 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
@@ -34,7 +34,6 @@ 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;
|
||||
|
||||
|
||||
Binary file not shown.
@@ -242,14 +242,13 @@ namespace CalamityMod.Graphics.Primitives
|
||||
VerticesIndex = 0;
|
||||
for (int i = 0; i < PositionsIndex; i++)
|
||||
{
|
||||
float completionRatio = i / (float)(PositionsIndex - 1);
|
||||
float completionRatio = (i - 1f) / (float)(PositionsIndex - 1);
|
||||
float widthAtVertex = MainSettings.WidthFunction(completionRatio);
|
||||
Color vertexColor = MainSettings.ColorFunction(completionRatio);
|
||||
Vector2 currentPosition = MainPositions[i];
|
||||
Vector2 directionToAhead = i == PositionsIndex - 1 ? (MainPositions[i] - MainPositions[i - 1]).SafeNormalize(Vector2.Zero) : (MainPositions[i + 1] - MainPositions[i]).SafeNormalize(Vector2.Zero);
|
||||
|
||||
Vector2 leftCurrentTextureCoord = new(completionRatio, 0f);
|
||||
Vector2 rightCurrentTextureCoord = new(completionRatio, 1f);
|
||||
Vector2 leftCurrentTextureCoord = new(completionRatio, 0.5f - widthAtVertex * 0.5f);
|
||||
Vector2 rightCurrentTextureCoord = new(completionRatio, 0.5f + widthAtVertex * 0.5f);
|
||||
|
||||
// Point 90 degrees away from the direction towards the next point, and use it to mark the edges of the rectangle.
|
||||
// This doesn't use RotatedBy for the sake of performance (there can potentially be a lot of trail points).
|
||||
@@ -268,9 +267,9 @@ namespace CalamityMod.Graphics.Primitives
|
||||
// What this is doing, at its core, is defining a rectangle based on two triangles.
|
||||
// These triangles are defined based on the width of the strip at that point.
|
||||
// The resulting rectangles combined are what make the trail itself.
|
||||
MainVertices[VerticesIndex] = new VertexPosition2DColorTexture(left, vertexColor, leftCurrentTextureCoord);
|
||||
MainVertices[VerticesIndex] = new VertexPosition2DColorTexture(left, vertexColor, leftCurrentTextureCoord, widthAtVertex);
|
||||
VerticesIndex++;
|
||||
MainVertices[VerticesIndex] = new VertexPosition2DColorTexture(right, vertexColor, rightCurrentTextureCoord);
|
||||
MainVertices[VerticesIndex] = new VertexPosition2DColorTexture(right, vertexColor, rightCurrentTextureCoord, widthAtVertex);
|
||||
VerticesIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,10 @@ namespace CalamityMod.Graphics.Primitives
|
||||
/// <summary>
|
||||
/// The texture-coordinate of the vertex.
|
||||
/// </summary>
|
||||
public readonly Vector2 TextureCoordinates;
|
||||
/// <remarks>
|
||||
/// The Z component isn't actually related to 3D, it holds the width of the vertex at the given point, since arbitrary data cannot be saved on a per-vertex basis and needs to be contained within some pre-defined format.
|
||||
/// </remarks>
|
||||
public readonly Vector3 TextureCoordinates;
|
||||
|
||||
/// <summary>
|
||||
/// The vertex declaration. This declares the layout and size of the data in the vertex shader.
|
||||
@@ -33,14 +36,14 @@ namespace CalamityMod.Graphics.Primitives
|
||||
{
|
||||
new(0, VertexElementFormat.Vector2, VertexElementUsage.Position, 0),
|
||||
new(8, VertexElementFormat.Color, VertexElementUsage.Color, 0),
|
||||
new(12, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0),
|
||||
new(12, VertexElementFormat.Vector3, VertexElementUsage.TextureCoordinate, 0)
|
||||
});
|
||||
|
||||
public VertexPosition2DColorTexture(Vector2 position, Color color, Vector2 textureCoordinates)
|
||||
public VertexPosition2DColorTexture(Vector2 position, Color color, Vector2 textureCoordinates, float widthCorrectionFactor)
|
||||
{
|
||||
Position = position;
|
||||
Color = color;
|
||||
TextureCoordinates = textureCoordinates;
|
||||
TextureCoordinates = new(textureCoordinates, widthCorrectionFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user