Very detailed comments in ExobladeShaderShader.fx
This commit is contained in:
1 parent
9341032a08
commit
8efefed241
2 files changed
+22
-4
No files matched your search
@@ -57,24 +57,42 @@ float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
|
||||
if (flipped)
|
||||
coords.y = 1 - coords.y;
|
||||
|
||||
float2 noiseCoords = coords * float2(0.5, 3) - float2(uTime * 0.45, 0);
|
||||
// Calculate the base noise sampling coordinates. They are firstly squished, with the X coordinate factor acting as a metric of the "sameness" of the trail patterns.
|
||||
// The lower the X coordinate factor is, the more detailed the trail is, while the inverse is true for the Y coordinate. After this, a time pass is incorporated to create the effect
|
||||
// that the slash is moving against the starting point, as one might expect a slash to do.
|
||||
float2 noiseDetail = float2(2, 2);
|
||||
float2 noiseCoords = coords * float2(1.0 / noiseDetail.x, noiseDetail.y) - float2(uTime * 0.45, 0);
|
||||
|
||||
// To prevent weird, sudden cutoffs unless the texture repeats, the X coordinate (which is in terms of the completion ratio of the trail) in transformed with a 0-1 sine instead of a
|
||||
// X Mod 1 cuttoff, which would essentially "cut off" the texture and return the start, turning a value of 1.1 to 0.1, 1.32 to 0.32, etc.
|
||||
noiseCoords.x = sin(noiseCoords.x * 5.4) * 0.5 + 0.5;
|
||||
|
||||
// Sample noise colors based on the original base noise coordination. These all vary somewhat to create more varied detail.
|
||||
float noise = tex2D(uImage1, noiseCoords).r;
|
||||
float noise2 = pow(tex2D(uImage1, noiseCoords * 2.2).r, 1.6);
|
||||
float noise3 = pow(tex2D(uImage1, noiseCoords * 1.1).r, 1.3);
|
||||
|
||||
// Combine all the noise values together. The base noise serves as a universal multiplier while the others are fed into a squishing function.
|
||||
// Importantly, the squishing function ensures that its inputs range from 0-1, such that power doesn't result in values beyond 1.
|
||||
// This is also where the "white hot edge" and trail fade effect comes from, due to the incorporation of the X and Y coordinate. In this context, the X coordinate exists to
|
||||
// create lower opacities (which then are squished to make the trail look like it's vanishing) the further along the trail the point is. The Y coordinate, meanwhile, it multiplied
|
||||
// with the noise such that values close to 1 (the top of the trail) are given more weight and recieve a greater brightness.
|
||||
float opacity = noise * pow(saturate((1 - coords.x) - noise * coords.y * 0.54), 3);
|
||||
|
||||
// Fade to the second primary color.
|
||||
// Fade to the second primary color based on one of the noise values.
|
||||
color = lerp(color, float4(uColor, 1), noise2);
|
||||
|
||||
// Create dark colors.
|
||||
// Create dark colors. Points that are further along the trail are incentized to fade to the dark color more strongly. This also holds true to points that are closer to the bottom of
|
||||
// the trail. To create some variance on top of this, the primary noise value is added as well.
|
||||
float darkColorWeight = saturate(coords.y * 1.8 + coords.x * 0.45 + noise * 0.1);
|
||||
color = lerp(color, float4(uSecondaryColor, 1), darkColorWeight);
|
||||
|
||||
// Create a fire streak.
|
||||
// Create a fire streak. This only applies to points in the top 30% of the trail, and the effect is stronger the closer a point is to the top. After this, a multiplier is incorporated
|
||||
// to make the effect dissipate the further along the trail a point is.
|
||||
float fireColorWeight = InverseLerp(0.3, 0, coords.y) * pow(1 - coords.x, 1.56);
|
||||
color = lerp(color, float4(fireColor, 1), fireColorWeight);
|
||||
|
||||
// Calculate the final color.
|
||||
float4 noiseColor = color * opacity * (noise3 * 2.4 + 2.4);
|
||||
noiseColor.a = lerp(noiseColor.a, 0, 1 - fireColorWeight);
|
||||
return noiseColor * input.Color.a;
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user