// rebuilds the number of output slots, and also updates their ShaderStageCapability
 void UpdateLayerOutputSlots(int layerCount, List <int> usedSlots = null)
 {
     for (int i = 0; i < kMaxLayers; i++)
     {
         int outputID = OutputSlotIds[i];
         Vector4MaterialSlot outputSlot = FindSlot <Vector4MaterialSlot>(outputID);
         if (i < layerCount)
         {
             // add or update it
             if (outputSlot == null)
             {
                 string outputName = OutputSlotNames[i];
                 outputSlot = new Vector4MaterialSlot(outputID, outputName, outputName, SlotType.Output, Vector4.zero, (noFeedback && m_LodCalculation == LodCalculation.VtLevel_Lod) ? ShaderStageCapability.All : ShaderStageCapability.Fragment);
                 AddSlot(outputSlot);
             }
             else
             {
                 outputSlot.stageCapability = (noFeedback && m_LodCalculation == LodCalculation.VtLevel_Lod) ? ShaderStageCapability.All : ShaderStageCapability.Fragment;
             }
             if (usedSlots != null)
             {
                 usedSlots.Add(outputID);
             }
         }
         else
         {
             // remove it
             if (outputSlot != null)
             {
                 RemoveSlot(OutputSlotIds[i]);
             }
         }
     }
     outputLayerSlotCount = layerCount;
 }
Beispiel #2
0
        void UpdateLayerOutputSlots(bool inspectProperty, List <int> usedSlots = null)
        {
            // the default is to show all 4 slots, so we don't lose any existing connections
            int layerCount = kMaxLayers;

            if (inspectProperty)
            {
                var vtProperty = GetSlotProperty(VirtualTextureInputId) as VirtualTextureShaderProperty;
                if (vtProperty != null)
                {
                    layerCount = vtProperty?.value?.layers?.Count ?? kMaxLayers;
                }
                if (outputLayerSlotCount == layerCount)
                {
                    if (usedSlots != null)
                    {
                        for (int i = 0; i < layerCount; i++)
                        {
                            usedSlots.Add(OutputSlotIds[i]);
                        }
                    }
                    return;
                }
            }

            for (int i = 0; i < kMaxLayers; i++)
            {
                int outputID = OutputSlotIds[i];
                Vector4MaterialSlot outputSlot = FindSlot <Vector4MaterialSlot>(outputID);
                if (i < layerCount)
                {
                    // add or update it
                    if (outputSlot == null)
                    {
                        string outputName = OutputSlotNames[i];
                        outputSlot = new Vector4MaterialSlot(outputID, outputName, outputName, SlotType.Output, Vector4.zero, (noFeedback && m_LodCalculation == LodCalculation.VtLevel_Lod) ? ShaderStageCapability.All : ShaderStageCapability.Fragment);
                        AddSlot(outputSlot);
                    }
                    else
                    {
                        outputSlot.stageCapability = (noFeedback && m_LodCalculation == LodCalculation.VtLevel_Lod) ? ShaderStageCapability.All : ShaderStageCapability.Fragment;
                    }
                    if (usedSlots != null)
                    {
                        usedSlots.Add(outputID);
                    }
                }
                else
                {
                    // remove it
                    if (outputSlot != null)
                    {
                        RemoveSlot(OutputSlotIds[i]);
                    }
                }
            }
            outputLayerSlotCount = layerCount;
        }
Beispiel #3
0
        public MaterialSlot CreateVectorSlot(int dimension, int id, string name, SlotType slotType, Vector4 value = default)
        {
            MaterialSlot slot = null;

            switch (dimension)
            {
            case 1:
                slot = new Vector1MaterialSlot(id, name, name, slotType, value.x);
                break;

            case 2:
                slot = new Vector2MaterialSlot(id, name, name, slotType, value);
                break;

            case 3:
                slot = new Vector3MaterialSlot(id, name, name, slotType, value);
                break;

            case 4:
                slot = new Vector4MaterialSlot(id, name, name, slotType, value);
                break;
            }
            return(slot);
        }