chore: Project Restructuring & Theatre
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
#ifndef STRIPES_INCLUDED
|
||||
#define STRIPES_INCLUDED
|
||||
|
||||
// Returns a value in [0, 1)
|
||||
float VanDerCorput(uint index)
|
||||
{
|
||||
// Reverse bits of the integer and scale to [0,1]
|
||||
return (float) reversebits(index) * 2.3283064365386963e-10;
|
||||
}
|
||||
|
||||
void Stripes_float(
|
||||
float2 UV,
|
||||
float Density,
|
||||
float Count,
|
||||
float Thickness,
|
||||
float Offset,
|
||||
float DistortionAmplitude,
|
||||
float DistortionFrequency,
|
||||
out float Stripes
|
||||
)
|
||||
{
|
||||
float density = saturate(Density);
|
||||
float offset = frac(Offset);
|
||||
float distortionAmplitude = DistortionAmplitude * .1;
|
||||
uint stripeCount = max((uint) round(Count), 1u);
|
||||
|
||||
float2 uv = UV;
|
||||
uv.x += offset;
|
||||
|
||||
float2 uvA = uv;
|
||||
float2 uvB = uv;
|
||||
uvA.x = frac(uvA.x + cos((uv.y + offset) * sin(uv.x) * DistortionFrequency + offset * 7.8) * distortionAmplitude);
|
||||
uvB.x = frac(uvB.x + sin((uv.y + offset) * cos(uv.x) * DistortionFrequency + offset * 5.3) * distortionAmplitude);
|
||||
|
||||
float stripDistanceY = abs(saturate(uv.y) - .5);
|
||||
|
||||
float stripeMax = 0;
|
||||
|
||||
for (uint i = 0u; i < stripeCount; i++)
|
||||
{
|
||||
float vdc = VanDerCorput(i);
|
||||
bool usesSecondDistortion = vdc >= .5;
|
||||
|
||||
float thickness = vdc < .3 ? 1 : (vdc < .6 ? 1.8 : 2.6);
|
||||
thickness *= saturate(Thickness);
|
||||
|
||||
float wrappedX = usesSecondDistortion ? uvB.x : uvA.x;
|
||||
|
||||
float localProgress = saturate(density * stripeCount - vdc * stripeCount);
|
||||
|
||||
float stripeCenterX = frac((i + .5) / stripeCount);
|
||||
float stripDistanceX = abs(wrappedX - stripeCenterX);
|
||||
stripDistanceX = min(stripDistanceX, 1.0 - stripDistanceX);
|
||||
|
||||
float stepX = (1. / stripeCount) * localProgress * thickness * .5;
|
||||
float stepY = localProgress * .5 - .01;
|
||||
|
||||
float softEdgeX = .01;
|
||||
float softEdgeY = .05;
|
||||
|
||||
float widthMask = 1 - smoothstep(stepX - softEdgeX, stepX, stripDistanceX);
|
||||
float heightMask = 1 - smoothstep(stepY - softEdgeY, stepY, stripDistanceY);
|
||||
|
||||
float stripeMask = widthMask * heightMask;
|
||||
stripeMax = max(stripeMax, stripeMask);
|
||||
}
|
||||
|
||||
Stripes = stripeMax;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user