Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float remap(float s, float a1, float a2, float b1, float b2)
- {
- return b1 + (s - a1) * (b2 - b1) / (a2 - a1);
- }
- fixed4 circuit(fixed2 uv, sampler2D tex, fixed4 color, half delay, half speed, half range, half dir) {
- //half pivot = frac(_Time.y / speed) * _MainTex_ST.x + delay;
- // Goes from 0 to 1 over 1/speed total duration
- half pivot = frac((_Time.y - delay) / speed) * _MainTex_ST.x;
- fixed comp = (dir == 0) ? uv.x : uv.y;
- fixed4 mask = tex2D(tex, uv) * color;
- fixed min = pivot - range;
- fixed max = pivot + range;
- // Ramp color
- fixed2 rampUV = fixed2(remap(comp, min, max, 0, 1), 0);
- fixed4 rampColor = tex2D(_ColorRamp, rampUV * _ColorRamp_ST.xy);
- mask *= rampColor.r;
- if (comp >= pivot - range && comp <= pivot + range)
- return mask;
- if (pivot + range > 1.0)
- if (comp >= pivot - range || comp <= pivot + range - 1.0)
- return mask;
- if (pivot - range < 0)
- if (comp >= pivot - range + 1.0 || comp <= pivot + range)
- return mask;
- return fixed4(0, 0, 0, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement