public static string AdaptNodeOutputForPreview(AbstractMaterialNode node, int slotId, string variableName)
        {
            var slot = node.FindSlot <MaterialSlot>(slotId);

            if (slot == null)
            {
                return(kErrorString);
            }

            var convertFromType = slot.concreteValueType;

            // preview is always dimension 4
            switch (convertFromType)
            {
            case ConcreteSlotValueType.Vector1:
                return(string.Format("half4({0}, {0}, {0}, 1.0)", variableName));

            case ConcreteSlotValueType.Vector2:
                return(string.Format("half4({0}.x, {0}.y, 0.0, 1.0)", variableName));

            case ConcreteSlotValueType.Vector3:
                return(string.Format("half4({0}.x, {0}.y, {0}.z, 1.0)", variableName));

            case ConcreteSlotValueType.Vector4:
                return(string.Format("half4({0}.x, {0}.y, {0}.z, 1.0)", variableName));

            default:
                return(kErrorString);
            }
        }
Exemplo n.º 2
0
        static List <MaterialSlot> FindMaterialSlotsOnNode(IEnumerable <int> slots, AbstractMaterialNode node)
        {
            var activeSlots = new List <MaterialSlot>();

            if (slots != null)
            {
                foreach (var id in slots)
                {
                    MaterialSlot slot = node.FindSlot <MaterialSlot>(id);
                    if (slot != null)
                    {
                        activeSlots.Add(slot);
                    }
                }
            }
            return(activeSlots);
        }