|
@@ -21,6 +21,8 @@ public class MathNode : Node
|
|
|
|
|
|
public FuncInputProperty<Float1> Y { get; }
|
|
|
|
|
|
+ public FuncInputProperty<Float1> Z { get; }
|
|
|
+
|
|
|
public MathNode()
|
|
|
{
|
|
|
Result = CreateFuncOutput<Float1>(nameof(Result), "RESULT", Calculate);
|
|
@@ -28,11 +30,12 @@ public class MathNode : Node
|
|
|
Clamp = CreateInput(nameof(Clamp), "CLAMP", false);
|
|
|
X = CreateFuncInput<Float1>(nameof(X), "X", 0d);
|
|
|
Y = CreateFuncInput<Float1>(nameof(Y), "Y", 0d);
|
|
|
+ Z = CreateFuncInput<Float1>(nameof(Z), "Z", 0d);
|
|
|
}
|
|
|
|
|
|
private Float1 Calculate(FuncContext context)
|
|
|
{
|
|
|
- var (x, y) = GetValues(context);
|
|
|
+ var (x, y, z) = GetValues(context);
|
|
|
|
|
|
if (context.HasContext)
|
|
|
{
|
|
@@ -45,6 +48,11 @@ public class MathNode : Node
|
|
|
MathNodeMode.Sin => ShaderMath.Sin(x),
|
|
|
MathNodeMode.Cos => ShaderMath.Cos(x),
|
|
|
MathNodeMode.Tan => ShaderMath.Tan(x),
|
|
|
+ MathNodeMode.GreaterThan => ShaderMath.GreaterThan(x, y),
|
|
|
+ MathNodeMode.GreaterThanOrEqual => ShaderMath.GreaterThanOrEqual(x, y),
|
|
|
+ MathNodeMode.LessThan => ShaderMath.LessThan(x, y),
|
|
|
+ MathNodeMode.LessThanOrEqual => ShaderMath.LessThanOrEqual(x, y),
|
|
|
+ MathNodeMode.Compare => ShaderMath.Compare(x, y, z)
|
|
|
};
|
|
|
|
|
|
if (Clamp.Value)
|
|
@@ -57,7 +65,8 @@ public class MathNode : Node
|
|
|
|
|
|
var xConst = x.ConstantValue;
|
|
|
var yConst = y.ConstantValue;
|
|
|
-
|
|
|
+ var zConst = z.ConstantValue;
|
|
|
+
|
|
|
var constValue = Mode.Value switch
|
|
|
{
|
|
|
MathNodeMode.Add => xConst + yConst,
|
|
@@ -67,14 +76,19 @@ public class MathNode : Node
|
|
|
MathNodeMode.Sin => Math.Sin(xConst),
|
|
|
MathNodeMode.Cos => Math.Cos(xConst),
|
|
|
MathNodeMode.Tan => Math.Tan(xConst),
|
|
|
+ MathNodeMode.GreaterThan => xConst > yConst ? 1 : 0,
|
|
|
+ MathNodeMode.GreaterThanOrEqual => xConst >= yConst ? 1 : 0,
|
|
|
+ MathNodeMode.LessThan => xConst < yConst ? 1 : 0,
|
|
|
+ MathNodeMode.LessThanOrEqual => xConst <= yConst ? 1 : 0,
|
|
|
+ MathNodeMode.Compare => Math.Abs(xConst - yConst) < zConst ? 1 : 0
|
|
|
};
|
|
|
|
|
|
return new Float1(string.Empty) { ConstantValue = constValue };
|
|
|
}
|
|
|
|
|
|
- private (Float1 xConst, Float1 y) GetValues(FuncContext context)
|
|
|
+ private (Float1 xConst, Float1 y, Float1 z) GetValues(FuncContext context)
|
|
|
{
|
|
|
- return (context.GetValue(X), context.GetValue(Y));
|
|
|
+ return (context.GetValue(X), context.GetValue(Y), context.GetValue(Z));
|
|
|
}
|
|
|
|
|
|
|