Skip to content

Commit 88c0fd5

Browse files
committed
Added bitwave2
1 parent 8836132 commit 88c0fd5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Runtime/mathx.common.float.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,18 @@ public static partial class mathx
273273
/// <inheritdoc cref="bitwave(float4)" />
274274
[MethodImpl(IL)] public static float bitwave(float x) => floor(math.fmod(x, 2));
275275
#endregion
276+
277+
#region bitwave
278+
279+
/// <summary> Samples a square wave that goes between 0 and 1. </summary>
280+
[MethodImpl(IL)] public static float4 bitwave2(float4 x) => (int4)x & 1;
281+
/// <inheritdoc cref="bitwave2(float4)" />
282+
[MethodImpl(IL)] public static float3 bitwave2(float3 x) => (int3)x & 1;
283+
/// <inheritdoc cref="bitwave2(float4)" />
284+
[MethodImpl(IL)] public static float2 bitwave2(float2 x) => (int2)x & 1;
285+
/// <inheritdoc cref="bitwave2(float4)" />
286+
[MethodImpl(IL)] public static float bitwave2(float x) => (int)x & 1;
287+
#endregion
276288

277289
#region triwave
278290
/// <summary> Samples a triangle wave between +0.5f and -0.5f. </summary>

0 commit comments

Comments
 (0)