Esempio n. 1
0
        static public VFXExpression Sequential3D(VFXExpression origin, VFXExpression axisX, VFXExpression axisY, VFXExpression axisZ, VFXExpression index, VFXExpression countX, VFXExpression countY, VFXExpression countZ, SequentialAddressingMode mode)
        {
            index = ApplyAddressingMode(index, countX * countY * countZ, mode);
            var z = new VFXExpressionCastUintToFloat(VFXOperatorUtility.Modulo(index, countZ));
            var y = new VFXExpressionCastUintToFloat(VFXOperatorUtility.Modulo(index / countZ, countY));
            var x = new VFXExpressionCastUintToFloat(index / (countY * countZ));

            VFXExpression volumeSize = new VFXExpressionCombine(new VFXExpressionCastUintToFloat(countX), new VFXExpressionCastUintToFloat(countY), new VFXExpressionCastUintToFloat(countZ));

            volumeSize = volumeSize - VFXOperatorUtility.OneExpression[VFXValueType.Float3];
            var scaleAxisZero = Saturate(volumeSize); //Handle special case for one count => lead to be centered on origin (instead of -axis)

            volumeSize = new VFXExpressionMax(volumeSize, VFXOperatorUtility.OneExpression[VFXValueType.Float3]);
            var dt = new VFXExpressionCombine(x, y, z) / volumeSize;

            dt = dt * VFXOperatorUtility.TwoExpression[VFXValueType.Float3] - VFXOperatorUtility.OneExpression[VFXValueType.Float3];

            var r = origin;

            r += dt.xxx * scaleAxisZero.xxx * axisX;
            r += dt.yyy * scaleAxisZero.yyy * axisY;
            r += dt.zzz * scaleAxisZero.zzz * axisZ;

            return(r);
        }
Esempio n. 2
0
        static public VFXExpression SequentialLine(VFXExpression start, VFXExpression end, VFXExpression index, VFXExpression count)
        {
            VFXExpression dt = new VFXExpressionCastUintToFloat(VFXOperatorUtility.Modulo(index, count));

            dt = dt / new VFXExpressionCastUintToFloat(count);
            dt = new VFXExpressionCombine(dt, dt, dt);
            return(VFXOperatorUtility.Lerp(start, end, dt));
        }
        static public VFXExpression SequentialLine(VFXExpression start, VFXExpression end, VFXExpression index, VFXExpression count)
        {
            VFXExpression dt   = new VFXExpressionCastUintToFloat(VFXOperatorUtility.Modulo(index, count));
            var           size = new VFXExpressionCastUintToFloat(count) - VFXOperatorUtility.OneExpression[VFXValueType.Float];

            size = new VFXExpressionMax(size, VFXOperatorUtility.OneExpression[VFXValueType.Float]);
            dt   = dt / size;
            dt   = new VFXExpressionCombine(dt, dt, dt);
            return(VFXOperatorUtility.Lerp(start, end, dt));
        }
        static public VFXExpression SequentialCircle(VFXExpression center, VFXExpression radius, VFXExpression normal, VFXExpression up, VFXExpression index, VFXExpression count)
        {
            VFXExpression dt = new VFXExpressionCastUintToFloat(VFXOperatorUtility.Modulo(index, count));

            dt = dt / new VFXExpressionCastUintToFloat(count);

            var cos  = new VFXExpressionCos(dt * VFXOperatorUtility.TauExpression[VFXValueType.Float]) as VFXExpression;
            var sin  = new VFXExpressionSin(dt * VFXOperatorUtility.TauExpression[VFXValueType.Float]) as VFXExpression;
            var left = VFXOperatorUtility.Normalize(VFXOperatorUtility.Cross(normal, up));

            radius = new VFXExpressionCombine(radius, radius, radius);
            sin    = new VFXExpressionCombine(sin, sin, sin);
            cos    = new VFXExpressionCombine(cos, cos, cos);

            return(center + (cos * up + sin * left) * radius);
        }
        static private VFXExpression ApplyAddressingMode(VFXExpression index, VFXExpression count, SequentialAddressingMode mode)
        {
            VFXExpression r = null;

            if (mode == SequentialAddressingMode.Wrap)
            {
                r = VFXOperatorUtility.Modulo(index, count);
            }
            else if (mode == SequentialAddressingMode.Clamp)
            {
                r = VFXOperatorUtility.Clamp(index, ZeroExpression[VFXValueType.Uint32], count, false);
            }
            else if (mode == SequentialAddressingMode.Mirror)
            {
                var direction = VFXOperatorUtility.Modulo(index / count, VFXOperatorUtility.TwoExpression[VFXValueType.Uint32]);
                var modulo    = VFXOperatorUtility.Modulo(index, count);
                r = VFXOperatorUtility.Lerp(modulo, count - modulo, direction);
            }
            return(r);
        }