protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression)
        {
            VFXExpression height = new VFXExpressionTextureHeight(inputExpression[1]);
            VFXExpression width  = new VFXExpressionTextureWidth(inputExpression[1]);

            VFXExpression u_index = VFXOperatorUtility.ApplyAddressingMode(inputExpression[2], new VFXExpressionMin(height * width, inputExpression[0]), mode);
            VFXExpression y       = u_index / width;
            VFXExpression x       = u_index - (y * width);

            Type outputType = GetOperandType();
            var  type       = typeof(VFXExpressionSampleAttributeMap <>).MakeGenericType(outputType);
            var  outputExpr = Activator.CreateInstance(type, new object[] { inputExpression[1], x, y });

            return(new[] { (VFXExpression)outputExpr });
        }
Пример #2
0
        protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression)
        {
            VFXExpression[] expressions = new VFXExpression[asset.surfaces.Length + 1];
            expressions[0] = VFXValue.Constant((uint)asset.PointCount);

            for (int i = 0; i < asset.surfaces.Length; i++)
            {
                var           surfaceExpr = VFXValue.Constant(asset.surfaces[i]);
                VFXExpression height      = new VFXExpressionTextureHeight(surfaceExpr);
                VFXExpression width       = new VFXExpressionTextureWidth(surfaceExpr);
                VFXExpression u_index     = VFXOperatorUtility.ApplyAddressingMode(inputExpression[0], new VFXExpressionMin(height * width, expressions[0]), mode);
                VFXExpression y           = u_index / width;
                VFXExpression x           = u_index - (y * width);

                Type outputType = GetOutputType(asset.surfaces[i]);
                var  type       = typeof(VFXExpressionSampleAttributeMap <>).MakeGenericType(outputType);
                var  outputExpr = Activator.CreateInstance(type, new object[] { surfaceExpr, x, y });

                expressions[i + 1] = (VFXExpression)outputExpr;
            }

            return(expressions);
        }