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.
41 lines
1.4 KiB
41 lines
1.4 KiB
using UnityEngine;
|
|
|
|
namespace UnityEditor.VFX.Operator
|
|
{
|
|
[VFXHelpURL("Operator-Remap(-11)")]
|
|
[VFXInfo(name = "Remap [0..1] => [-1..1]", category = "Math/Remap")]
|
|
class RemapToNegOnePosOne : VFXOperatorNumericUniform
|
|
{
|
|
[VFXSetting, SerializeField, Tooltip("When enabled, the input value is clamped between 0 and 1.")]
|
|
private bool m_Clamp = false;
|
|
|
|
public class InputProperties
|
|
{
|
|
[Tooltip("Sets the value to be remapped into the [-1..1] range. If the input value is not clamped, the remapped value can go beyond that range.")]
|
|
public float input = 0.5f;
|
|
}
|
|
|
|
protected override sealed string operatorName { get { return "Remap [0..1] => [-1..1]"; } }
|
|
|
|
protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression)
|
|
{
|
|
var type = inputExpression[0].valueType;
|
|
|
|
VFXExpression input;
|
|
if (m_Clamp)
|
|
input = VFXOperatorUtility.Saturate(inputExpression[0]);
|
|
else
|
|
input = inputExpression[0];
|
|
|
|
return new[] { VFXOperatorUtility.Mad(input, VFXOperatorUtility.TwoExpression[type], VFXOperatorUtility.Negate(VFXOperatorUtility.OneExpression[type])) };
|
|
}
|
|
|
|
protected sealed override ValidTypeRule typeFilter
|
|
{
|
|
get
|
|
{
|
|
return ValidTypeRule.allowEverythingExceptInteger;
|
|
}
|
|
}
|
|
}
|
|
}
|