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) }); }
public static IEnumerable <VFXExpression> SampleEdgeAttribute(VFXExpression source, VFXExpression index, VFXExpression lerp, IEnumerable <VertexAttribute> vertexAttributes) { bool skinnedMesh = source.valueType == UnityEngine.VFX.VFXValueType.SkinnedMeshRenderer; var mesh = !skinnedMesh ? source : new VFXExpressionMeshFromSkinnedMeshRenderer(source); var meshIndexFormat = new VFXExpressionMeshIndexFormat(mesh); var oneInt = VFXOperatorUtility.OneExpression[UnityEngine.VFX.VFXValueType.Int32]; var oneUint = VFXOperatorUtility.OneExpression[UnityEngine.VFX.VFXValueType.Uint32]; var threeUint = VFXOperatorUtility.ThreeExpression[UnityEngine.VFX.VFXValueType.Uint32]; var nextIndex = index + oneUint; //Loop triangle var loop = VFXOperatorUtility.Modulo(nextIndex, threeUint); var predicat = new VFXExpressionCondition(UnityEngine.VFX.VFXValueType.Uint32, VFXCondition.NotEqual, loop, VFXOperatorUtility.ZeroExpression[UnityEngine.VFX.VFXValueType.Uint32]); nextIndex = new VFXExpressionBranch(predicat, nextIndex, nextIndex - threeUint); var sampledIndex_A = new VFXExpressionSampleIndex(mesh, index, meshIndexFormat); var sampledIndex_B = new VFXExpressionSampleIndex(mesh, nextIndex, meshIndexFormat); var sampling_A = SampleVertexAttribute(source, sampledIndex_A, vertexAttributes).ToArray(); var sampling_B = SampleVertexAttribute(source, sampledIndex_B, vertexAttributes).ToArray(); for (int i = 0; i < vertexAttributes.Count(); ++i) { var outputValueType = sampling_A[i].valueType; var s = VFXOperatorUtility.CastFloat(lerp, outputValueType); yield return(VFXOperatorUtility.Lerp(sampling_A[i], sampling_B[i], s)); } }
protected override VFXExpression[] BuildExpression(VFXExpression[] inputExpression) { VFXExpression[] output = new VFXExpression[] { VFXOperatorUtility.Lerp(inputExpression[1].x, inputExpression[1].y, VFXOperatorUtility.Frac(VFXBuiltInExpression.TotalTime / inputExpression[0])), }; return(output); }
protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression) { //round(frac(x*F)) var expression = inputExpression[0] * inputExpression[1]; var res = VFXOperatorUtility.Round(VFXOperatorUtility.Frac(expression)); return(new[] { VFXOperatorUtility.Lerp(inputExpression[2], inputExpression[3], res) }); }
protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression) { // 2 * abs(round(frac(x*F)) - frac(x*F)) var expression = inputExpression[0] * inputExpression[1]; var dX = VFXOperatorUtility.Frac(expression); var slope = VFXOperatorUtility.Round(dX); var two = VFXOperatorUtility.TwoExpression[expression.valueType]; var res = two * (new VFXExpressionAbs(slope - dX)); return(new[] { VFXOperatorUtility.Lerp(inputExpression[2], inputExpression[3], res) }); }
protected override VFXExpression[] BuildExpression(VFXExpression[] inputExpression) { //(1-cos(F*2*pi*x))/2 var type = inputExpression[0].valueType; var one = VFXOperatorUtility.OneExpression[type]; var tau = VFXOperatorUtility.TauExpression[type]; var two = VFXOperatorUtility.TwoExpression[type]; var res = new VFXExpressionDivide(one - new VFXExpressionCos(inputExpression[0] * inputExpression[1] * tau), two); return(new[] { VFXOperatorUtility.Lerp(inputExpression[2], inputExpression[3], res) }); }
protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression) { VFXExpression rand = null; if (seed == VFXSeedMode.PerParticleStrip || constant) { rand = VFXOperatorUtility.FixedRandom(inputExpression[2], seed); } else { rand = new VFXExpressionRandom(seed == VFXSeedMode.PerParticle); } return(new[] { VFXOperatorUtility.Lerp(inputExpression[0], inputExpression[1], rand) }); }
public void ProcessOperatorLerp() { var a = new Vector3(0.2f, 0.3f, 0.4f); var b = new Vector3(1.0f, 2.3f, 5.4f); var c = 0.2f; var d = 1.5f; var resultA = Vector3.LerpUnclamped(a, b, c); var resultB = Vector3.LerpUnclamped(a, b, d); var value_a = new VFXValue <Vector3>(a); var value_b = new VFXValue <Vector3>(b); var value_c = new VFXValue <float>(c); var value_d = new VFXValue <float>(d); var expressionA = VFXOperatorUtility.Lerp(value_a, value_b, VFXOperatorUtility.CastFloat(value_c, value_b.valueType)); var expressionB = VFXOperatorUtility.Lerp(value_a, value_b, VFXOperatorUtility.CastFloat(value_d, value_b.valueType)); var context = new VFXExpression.Context(VFXExpressionContextOption.CPUEvaluation); var resultExpressionA = context.Compile(expressionA); var resultExpressionB = context.Compile(expressionB); Assert.AreEqual((resultA - resultExpressionA.Get <Vector3>()).magnitude, 0.0f, 0.001f); Assert.AreEqual((resultB - resultExpressionB.Get <Vector3>()).magnitude, 0.0f, 0.001f); }
protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression) { return(new[] { VFXOperatorUtility.Lerp(inputExpression[0], inputExpression[1], inputExpression[2]) }); }
protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression) { var rand = VFXOperatorUtility.BuildRandom(seed, constant, new RandId(this), inputExpression.Length > 2 ? inputExpression[2] : null); return(new[] { VFXOperatorUtility.Lerp(inputExpression[0], inputExpression[1], rand) }); }