You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
51 lines
1.4 KiB
using System.Linq;
|
|
using System.Collections.Generic;
|
|
|
|
namespace UnityEditor.VFX.Operator
|
|
{
|
|
[VFXHelpURL("Operator-SawtoothWave")]
|
|
[VFXInfo(category = "Math/Wave")]
|
|
class SawtoothWave : VFXOperatorNumericUnified, IVFXOperatorNumericUnifiedConstrained
|
|
{
|
|
public class InputProperties
|
|
{
|
|
public float input = 0.5f;
|
|
public float frequency = 1.0f;
|
|
public float min = 0.0f;
|
|
public float max = 1.0f;
|
|
}
|
|
|
|
protected override sealed string operatorName { get { return "Sawtooth Wave"; } }
|
|
|
|
public IEnumerable<int> slotIndicesThatMustHaveSameType
|
|
{
|
|
get
|
|
{
|
|
return Enumerable.Range(0, 4);
|
|
}
|
|
}
|
|
|
|
public IEnumerable<int> slotIndicesThatCanBeScalar
|
|
{
|
|
get
|
|
{
|
|
return Enumerable.Range(1, 4);
|
|
}
|
|
}
|
|
|
|
protected sealed override ValidTypeRule typeFilter
|
|
{
|
|
get
|
|
{
|
|
return ValidTypeRule.allowEverythingExceptInteger;
|
|
}
|
|
}
|
|
|
|
protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression)
|
|
{
|
|
// abs(frac(x*F))
|
|
var res = new VFXExpressionAbs(VFXOperatorUtility.Frac(inputExpression[0] * inputExpression[1]));
|
|
return new[] { VFXOperatorUtility.Lerp(inputExpression[2], inputExpression[3], res) };
|
|
}
|
|
}
|
|
}
|