Esempio n. 1
0
        private void SetupOverlay(UMAData.MaterialFragment source, int i2, int textureType)
        {
            if (source.overlays[i2] == null)
            {
                return;
            }
            if (source.overlays[i2].textureList[textureType] == null)
            {
                return;
            }

            Rect overlayRect;

            if (source.rects[i2].width != 0)
            {
                overlayRect = new Rect(atlasRect.xMin + source.rects[i2].x * resolutionScale, atlasRect.yMax - source.rects[i2].y * resolutionScale - source.rects[i2].height * resolutionScale, source.rects[i2].width * resolutionScale, source.rects[i2].height * resolutionScale);
            }
            else
            {
                overlayRect = atlasRect;
            }

            SetupMaterial(ref textureMergeRects[textureMergeRectCount], source, i2, ref overlayRect, textureType);
            textureMergeRectCount++;
        }
Esempio n. 2
0
        private void SetupMaterial(ref TextureMergeRect textureMergeRect, UMAData.MaterialFragment source, int i2, ref Rect overlayRect, int textureType)
        {
            textureMergeRect.rect = overlayRect;
            textureMergeRect.tex  = source.overlays[i2].textureList[textureType];
            if (source.overlays[i2].overlayType == OverlayDataAsset.OverlayType.Normal)
            {
                switch (source.slotData.asset.material.channels[textureType].channelType)
                {
                case UMAMaterial.ChannelType.NormalMap:
                    textureMergeRect.mat.shader = normalShader;
                    break;

                case UMAMaterial.ChannelType.Texture:
                    textureMergeRect.mat.shader = dataShader;
                    break;

                case UMAMaterial.ChannelType.DiffuseTexture:
                    textureMergeRect.mat.shader = diffuseShader;
                    break;
                }
                textureMergeRect.mat.SetTexture("_MainTex", source.overlays[i2].textureList[textureType]);
                textureMergeRect.mat.SetTexture("_ExtraTex", source.overlays[i2].alphaTexture);
                textureMergeRect.mat.SetColor("_Color", source.GetMultiplier(i2 + 1, textureType));
                textureMergeRect.mat.SetColor("_AdditiveColor", source.GetAdditive(i2 + 1, textureType));
            }
            else
            {
                textureMergeRect.mat.shader = cutoutShader;
            }
        }
Esempio n. 3
0
        private void SetupMaterial(ref TextureMergeRect textureMergeRect, UMAData.MaterialFragment source, int textureType)
        {
            textureMergeRect.tex = source.baseOverlay.textureList[textureType];

            switch (source.slotData.asset.material.channels[textureType].channelType)
            {
            case UMAMaterial.ChannelType.NormalMap:
                textureMergeRect.mat.shader = normalShader;
                foreach (UMAPostProcess process in normalPostProcesses)
                {
                    process.enabled = true;
                }
                break;

            case UMAMaterial.ChannelType.Texture:
                textureMergeRect.mat.shader = dataShader;
                foreach (UMAPostProcess process in dataPostProcesses)
                {
                    process.enabled = true;
                }
                break;

            case UMAMaterial.ChannelType.DiffuseTexture:
                textureMergeRect.mat.shader = diffuseShader;
                foreach (UMAPostProcess process in diffusePostProcesses)
                {
                    process.enabled = true;
                }
                break;
            }
            textureMergeRect.mat.SetTexture("_MainTex", source.baseOverlay.textureList[textureType]);
            textureMergeRect.mat.SetTexture("_ExtraTex", source.baseOverlay.alphaTexture);
            textureMergeRect.mat.SetColor("_Color", source.GetMultiplier(0, textureType));
            textureMergeRect.mat.SetColor("_AdditiveColor", source.GetAdditive(0, textureType));
        }
        private void SetupMaterial(ref TextureMergeRect textureMergeRect, UMAData.MaterialFragment source, int textureType)
        {
            camBackgroundColor   = source.GetMultiplier(0, textureType);
            camBackgroundColor.a = 0.0f;

            textureMergeRect.tex = source.baseOverlay.textureList[textureType];

            switch (source.slotData.asset.material.channels[textureType].channelType)
            {
            case UMAMaterial.ChannelType.NormalMap:
                textureMergeRect.mat.shader = normalShader;
                break;

            case UMAMaterial.ChannelType.Texture:
                textureMergeRect.mat.shader = dataShader;
                break;

            case UMAMaterial.ChannelType.DiffuseTexture:
                textureMergeRect.mat.shader = diffuseShader;
                break;

            case UMAMaterial.ChannelType.DetailNormalMap:
                textureMergeRect.mat.shader = detailNormalShader;
                break;
            }
            textureMergeRect.mat.SetTexture("_MainTex", source.baseOverlay.textureList[textureType]);
            textureMergeRect.mat.SetTexture("_ExtraTex", source.baseOverlay.alphaTexture);
            textureMergeRect.mat.SetColor("_Color", source.GetMultiplier(0, textureType));
            textureMergeRect.mat.SetColor("_AdditiveColor", source.GetAdditive(0, textureType));
        }
Esempio n. 5
0
 public void SetupModule(UMAData.MaterialFragment source, int textureType)
 {
     textureMergeRects[textureMergeRectCount].rect   = source.atlasRegion;
     textureMergeRects[textureMergeRectCount].rect.y = height - textureMergeRects[textureMergeRectCount].rect.y - textureMergeRects[textureMergeRectCount].rect.height;
     atlasRect = textureMergeRects[textureMergeRectCount].rect;
     SetupMaterial(ref textureMergeRects[textureMergeRectCount], source, textureType);
     textureMergeRectCount++;
 }
Esempio n. 6
0
 private void SetupMaterial(ref TextureMergeRect textureMergeRect, UMAData.MaterialFragment source, int textureType)
 {
     textureMergeRect.tex        = source.baseTexture[textureType];
     textureMergeRect.mat.shader = (textureType == 1)? normalShader : diffuseShader;
     textureMergeRect.mat.SetTexture("_MainTex", source.baseTexture[textureType]);
     textureMergeRect.mat.SetTexture("_ExtraTex", source.baseTexture[0]);
     textureMergeRect.mat.SetColor("_Color", source.GetMultiplier(0, textureType));
     textureMergeRect.mat.SetColor("_AdditiveColor", source.GetAdditive(0, textureType));
 }
Esempio n. 7
0
 private void SetupMaterial(ref TextureMergeRect textureMergeRect, UMAData.MaterialFragment source, int i2, ref Rect overlayRect, int textureType)
 {
     textureMergeRect.rect       = overlayRect;
     textureMergeRect.tex        = source.overlays[i2].textureList[textureType];
     textureMergeRect.mat.shader = (source.slotData.asset.material.channels[textureType].channelType == UMAMaterial.ChannelType.NormalMap) ? normalShader : diffuseShader;
     textureMergeRect.mat.SetTexture("_MainTex", source.overlays[i2].textureList[textureType]);
     textureMergeRect.mat.SetTexture("_ExtraTex", source.overlays[i2].textureList[0]);
     textureMergeRect.mat.SetColor("_Color", source.GetMultiplier(i2 + 1, textureType));
     textureMergeRect.mat.SetColor("_AdditiveColor", source.GetAdditive(i2 + 1, textureType));
 }
Esempio n. 8
0
        private void SetupOverlay(UMAData.MaterialFragment source, int OverlayIndex, int textureType)
        {
            if (source.overlays[OverlayIndex] == null)
            {
                return;
            }
            if (source.overlays[OverlayIndex].textureList[textureType] == null)
            {
                return;
            }
            if (source.isNoTextures)
            {
                return;
            }

            Rect overlayRect;

            if (source.rects[OverlayIndex].width != 0)
            {
                overlayRect = new Rect(atlasRect.xMin + source.rects[OverlayIndex].x * resolutionScale.x, atlasRect.yMax - source.rects[OverlayIndex].y * resolutionScale.y - source.rects[OverlayIndex].height * resolutionScale.y, source.rects[OverlayIndex].width * resolutionScale.x, source.rects[OverlayIndex].height * resolutionScale.y);
            }
            else
            {
                overlayRect = atlasRect;
            }

            SetupMaterial(ref textureMergeRects[textureMergeRectCount], source, OverlayIndex, ref overlayRect, textureType);

            // for some reason, the overlayData is stored on the next textureMergeRect.
            // Check the generator. There must be a reason, but I just can't fathom it.
            if (source.overlayData[OverlayIndex + 1].instanceTransformed)
            {
                OverlayData od = source.overlayData[OverlayIndex + 1];
                textureMergeRects[textureMergeRectCount].transform = true;
                textureMergeRects[textureMergeRectCount].rotation  = od.Rotation;
                textureMergeRects[textureMergeRectCount].scale     = od.Scale;
            }
            else
            {
                textureMergeRects[textureMergeRectCount].transform = false;
            }
            textureMergeRectCount++;
        }
        protected override void Start()
        {
            if (generatedMaterialLookup == null)
            {
                generatedMaterialLookup = new Dictionary <GeneratedMaterialLookupKey, UMAData.GeneratedMaterial>(20);
            }
            else
            {
                generatedMaterialLookup.Clear();
            }
            backUpTexture = umaData.backUpTextures();
            umaData.CleanTextures();
            generatedMaterials = new List <UMAData.GeneratedMaterial>(20);
            atlassedMaterials.Clear();
            uniqueRenderers.Clear();

            SlotData[] slots = umaData.umaRecipe.slotDataList;

            for (int i = 0; i < slots.Length; i++)
            {
                SlotData slot = slots[i];
                if (slot == null)
                {
                    continue;
                }
                if (slot.Suppressed)
                {
                    continue;
                }

                //Keep a running list of unique RendererHashes from our slots
                //Null rendererAsset gets added, which is good, it is the default renderer.
                if (!uniqueRenderers.Contains(slot.rendererAsset))
                {
                    uniqueRenderers.Add(slot.rendererAsset);
                }

                // Let's only add the default overlay if the slot has meshData and NO overlays
                // This should be able to be removed if default overlay/textures are ever added to uma materials...
                if ((slot.asset.meshData != null) && (slot.OverlayCount == 0))
                {
                    if (umaGenerator.defaultOverlaydata != null)
                    {
                        slot.AddOverlay(umaGenerator.defaultOverlaydata);
                    }
                }

                OverlayData overlay0 = slot.GetOverlay(0);
                if ((slot.asset.material != null) && (overlay0 != null))
                {
                    GeneratedMaterialLookupKey lookupKey = new GeneratedMaterialLookupKey
                    {
                        overlayList   = slot.GetOverlayList(),
                        rendererAsset = slot.rendererAsset
                    };

                    UMAData.GeneratedMaterial generatedMaterial;
                    if (!generatedMaterialLookup.TryGetValue(lookupKey, out generatedMaterial))
                    {
                        generatedMaterial = FindOrCreateGeneratedMaterial(slot.asset.material, slot.rendererAsset);
                        generatedMaterialLookup.Add(lookupKey, generatedMaterial);
                    }

                    int validOverlayCount = 0;
                    for (int j = 0; j < slot.OverlayCount; j++)
                    {
                        var overlay = slot.GetOverlay(j);
                        if (overlay != null)
                        {
                            validOverlayCount++;
#if (UNITY_STANDALONE || UNITY_IOS || UNITY_ANDROID || UNITY_PS4 || UNITY_XBOXONE) && !UNITY_2017_3_OR_NEWER //supported platforms for procedural materials
                            if (overlay.isProcedural)
                            {
                                overlay.GenerateProceduralTextures();
                            }
#endif
                        }
                    }

                    UMAData.MaterialFragment tempMaterialDefinition = new UMAData.MaterialFragment();
                    tempMaterialDefinition.baseOverlay              = new UMAData.textureData();
                    tempMaterialDefinition.baseOverlay.textureList  = overlay0.textureArray;
                    tempMaterialDefinition.baseOverlay.alphaTexture = overlay0.alphaMask;
                    tempMaterialDefinition.baseOverlay.overlayType  = overlay0.overlayType;

                    tempMaterialDefinition.umaMaterial = slot.asset.material;
                    tempMaterialDefinition.baseColor   = overlay0.colorData.color;
                    tempMaterialDefinition.size        = overlay0.pixelCount;

                    tempMaterialDefinition.overlays               = new UMAData.textureData[validOverlayCount - 1];
                    tempMaterialDefinition.overlayColors          = new Color32[validOverlayCount - 1];
                    tempMaterialDefinition.rects                  = new Rect[validOverlayCount - 1];
                    tempMaterialDefinition.overlayData            = new OverlayData[validOverlayCount];
                    tempMaterialDefinition.channelMask            = new Color[validOverlayCount][];
                    tempMaterialDefinition.channelAdditiveMask    = new Color[validOverlayCount][];
                    tempMaterialDefinition.overlayData[0]         = slot.GetOverlay(0);
                    tempMaterialDefinition.channelMask[0]         = slot.GetOverlay(0).colorData.channelMask;
                    tempMaterialDefinition.channelAdditiveMask[0] = slot.GetOverlay(0).colorData.channelAdditiveMask;
                    tempMaterialDefinition.slotData               = slot;

                    int overlayID = 0;
                    for (int j = 1; j < slot.OverlayCount; j++)
                    {
                        OverlayData overlay = slot.GetOverlay(j);
                        if (overlay == null)
                        {
                            continue;
                        }

                        if (IsUVCoordinates(overlay.rect))
                        {
                            tempMaterialDefinition.rects[overlayID] = ScaleToBase(overlay.rect, overlay0.textureArray[0]);
                        }
                        else
                        {
                            tempMaterialDefinition.rects[overlayID] = overlay.rect;                             // JRRM: Convert here into base overlay coordinates?
                        }
                        tempMaterialDefinition.overlays[overlayID]              = new UMAData.textureData();
                        tempMaterialDefinition.overlays[overlayID].textureList  = overlay.textureArray;
                        tempMaterialDefinition.overlays[overlayID].alphaTexture = overlay.alphaMask;
                        tempMaterialDefinition.overlays[overlayID].overlayType  = overlay.overlayType;
                        tempMaterialDefinition.overlayColors[overlayID]         = overlay.colorData.color;

                        overlayID++;
                        tempMaterialDefinition.overlayData[overlayID]         = overlay;
                        tempMaterialDefinition.channelMask[overlayID]         = overlay.colorData.channelMask;
                        tempMaterialDefinition.channelAdditiveMask[overlayID] = overlay.colorData.channelAdditiveMask;
                    }

                    tempMaterialDefinition.overlayList  = lookupKey.overlayList;
                    tempMaterialDefinition.isRectShared = false;
                    for (int j = 0; j < generatedMaterial.materialFragments.Count; j++)
                    {
                        if (tempMaterialDefinition.overlayList == generatedMaterial.materialFragments[j].overlayList)
                        {
                            tempMaterialDefinition.isRectShared = true;
                            tempMaterialDefinition.rectFragment = generatedMaterial.materialFragments[j];
                            break;
                        }
                    }
                    generatedMaterial.materialFragments.Add(tempMaterialDefinition);
                }
            }

            //****************************************************
            //* Set parameters based on shader parameter mapping
            //****************************************************
            for (int i = 0; i < generatedMaterials.Count; i++)
            {
                UMAData.GeneratedMaterial ugm = generatedMaterials[i];
                if (ugm.umaMaterial.shaderParms != null)
                {
                    for (int j = 0; j < ugm.umaMaterial.shaderParms.Length; j++)
                    {
                        UMAMaterial.ShaderParms parm = ugm.umaMaterial.shaderParms[j];
                        if (ugm.material.HasProperty(parm.ParameterName))
                        {
                            foreach (OverlayColorData ocd in umaData.umaRecipe.sharedColors)
                            {
                                if (ocd.name == parm.ColorName)
                                {
                                    ugm.material.SetColor(parm.ParameterName, ocd.color);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            packTexture = new MaxRectsBinPack(umaGenerator.atlasResolution, umaGenerator.atlasResolution, false);
        }
Esempio n. 10
0
        protected override void Start()
        {
            if (generatedMaterialLookup == null)
            {
                generatedMaterialLookup = new Dictionary <List <OverlayData>, UMAData.GeneratedMaterial>(20);
            }
            else
            {
                generatedMaterialLookup.Clear();
            }
            backUpTexture = umaData.backUpTextures();
            umaData.CleanTextures();
            generatedMaterials = new List <UMAData.GeneratedMaterial>(20);
            atlassedMaterials.Clear();

            SlotData[] slots = umaData.umaRecipe.slotDataList;
            for (int i = 0; i < slots.Length; i++)
            {
                var slot = slots[i];
                if (slot == null)
                {
                    continue;
                }
                if (slot.asset.material != null && slot.GetOverlay(0) != null)
                {
                    var overlayList = slot.GetOverlayList();
                    UMAData.GeneratedMaterial generatedMaterial;
                    if (!generatedMaterialLookup.TryGetValue(overlayList, out generatedMaterial))
                    {
                        generatedMaterial = FindOrCreateGeneratedMaterial(slots[i].asset.material);
                        generatedMaterialLookup.Add(overlayList, generatedMaterial);
                    }
                    var tempMaterialDefinition = new UMAData.MaterialFragment();
                    tempMaterialDefinition.baseTexture = slots[i].GetOverlay(0).asset.textureList;
                    tempMaterialDefinition.size        = tempMaterialDefinition.baseTexture[0].width * tempMaterialDefinition.baseTexture[0].height;
                    tempMaterialDefinition.baseColor   = slots[i].GetOverlay(0).colorData.color;
                    tempMaterialDefinition.umaMaterial = slots[i].asset.material;
                    int overlays = 0;
                    for (int overlayCounter = 0; overlayCounter < slots[i].OverlayCount; overlayCounter++)
                    {
                        var overlay = slots[i].GetOverlay(overlayCounter);
                        if (overlay != null)
                        {
                            overlays++;
                        }
                    }

                    tempMaterialDefinition.overlays               = new UMAData.textureData[overlays - 1];
                    tempMaterialDefinition.overlayColors          = new Color32[overlays - 1];
                    tempMaterialDefinition.rects                  = new Rect[overlays - 1];
                    tempMaterialDefinition.overlayData            = new OverlayData[overlays];
                    tempMaterialDefinition.channelMask            = new Color[overlays][];
                    tempMaterialDefinition.channelAdditiveMask    = new Color[overlays][];
                    tempMaterialDefinition.overlayData[0]         = slots[i].GetOverlay(0);
                    tempMaterialDefinition.channelMask[0]         = slots[i].GetOverlay(0).colorData.channelMask;
                    tempMaterialDefinition.channelAdditiveMask[0] = slots[i].GetOverlay(0).colorData.channelAdditiveMask;
                    tempMaterialDefinition.slotData               = slots[i];

                    int overlayID = 0;
                    for (int overlayCounter = 0; overlayCounter < slots[i].OverlayCount - 1; overlayCounter++)
                    {
                        var overlay = slots[i].GetOverlay(overlayCounter + 1);
                        if (overlay == null)
                        {
                            continue;
                        }
                        tempMaterialDefinition.overlays[overlayID]                = new UMAData.textureData();
                        tempMaterialDefinition.rects[overlayID]                   = overlay.rect;
                        tempMaterialDefinition.overlays[overlayID].textureList    = overlay.asset.textureList;
                        tempMaterialDefinition.overlayColors[overlayID]           = overlay.colorData.color;
                        tempMaterialDefinition.channelMask[overlayID + 1]         = overlay.colorData.channelMask;
                        tempMaterialDefinition.channelAdditiveMask[overlayID + 1] = overlay.colorData.channelAdditiveMask;
                        tempMaterialDefinition.overlayData[overlayID + 1]         = overlay;
                        overlayID++;
                    }

                    tempMaterialDefinition.overlayList  = slots[i].GetOverlayList();
                    tempMaterialDefinition.isRectShared = false;
                    for (int j = 0; j < generatedMaterial.materialFragments.Count; j++)
                    {
                        if (generatedMaterial.materialFragments[j].overlayList == tempMaterialDefinition.overlayList)
                        {
                            tempMaterialDefinition.isRectShared = true;
                            tempMaterialDefinition.rectFragment = generatedMaterial.materialFragments[j];
                            break;
                        }
                    }
                    generatedMaterial.materialFragments.Add(tempMaterialDefinition);
                }
            }

            packTexture = new MaxRectsBinPack(umaGenerator.atlasResolution, umaGenerator.atlasResolution, false);
        }
        protected override void Start()
        {
            if (generatedMaterialLookup == null)
            {
                generatedMaterialLookup = new Dictionary <List <OverlayData>, UMAData.GeneratedMaterial>(20);
            }
            else
            {
                generatedMaterialLookup.Clear();
            }
            backUpTexture = umaData.backUpTextures();
            umaData.CleanTextures();
            generatedMaterials = new List <UMAData.GeneratedMaterial>(20);
            atlassedMaterials.Clear();
            rendererCount = 0;

            SlotData[] slots = umaData.umaRecipe.slotDataList;

            for (int i = 0; i < slots.Length; i++)
            {
                var slot = slots[i];
                if (slot == null)
                {
                    continue;
                }

                if ((slot.asset.material != null) && (slot.GetOverlay(0) != null))
                {
                    if (!slot.asset.material.RequireSeperateRenderer)
                    {
                        // At least one slot that doesn't require a seperate renderer, so we reserve renderer 0 for those.
                        rendererCount = 1;
                        break;
                    }
                }
            }

            for (int i = 0; i < slots.Length; i++)
            {
                SlotData slot = slots[i];
                if (slot == null)
                {
                    continue;
                }

                // Let's only add the default overlay if the slot has overlays and NO meshData
                if ((slot.asset.meshData != null) && (slot.OverlayCount == 0))
                {
                    if (umaGenerator.defaultOverlaydata != null)
                    {
                        slot.AddOverlay(umaGenerator.defaultOverlaydata);
                    }
                }

                OverlayData overlay0 = slot.GetOverlay(0);
                if ((slot.asset.material != null) && (overlay0 != null))
                {
                    List <OverlayData>        overlayList = slot.GetOverlayList();
                    UMAData.GeneratedMaterial generatedMaterial;
                    if (!generatedMaterialLookup.TryGetValue(overlayList, out generatedMaterial))
                    {
                        generatedMaterial = FindOrCreateGeneratedMaterial(slot.asset.material);
                        generatedMaterialLookup.Add(overlayList, generatedMaterial);
                    }

                    int validOverlayCount = 0;
                    for (int j = 0; j < slot.OverlayCount; j++)
                    {
                        var overlay = slot.GetOverlay(j);
                        if (overlay != null)
                        {
                            validOverlayCount++;
                            #if UNITY_STANDALONE || UNITY_IOS || UNITY_ANDROID || UNITY_PS4 || UNITY_XBOXONE //supported platforms for procedural materials
                            if (overlay.isProcedural)
                            {
                                overlay.GenerateProceduralTextures();
                            }
                            #endif
                        }
                    }

                    UMAData.MaterialFragment tempMaterialDefinition = new UMAData.MaterialFragment();
                    tempMaterialDefinition.baseOverlay              = new UMAData.textureData();
                    tempMaterialDefinition.baseOverlay.textureList  = overlay0.textureArray;
                    tempMaterialDefinition.baseOverlay.alphaTexture = overlay0.alphaMask;
                    tempMaterialDefinition.baseOverlay.overlayType  = overlay0.overlayType;

                    tempMaterialDefinition.umaMaterial = slot.asset.material;
                    tempMaterialDefinition.baseColor   = overlay0.colorData.color;
                    tempMaterialDefinition.size        = overlay0.pixelCount;

                    tempMaterialDefinition.overlays               = new UMAData.textureData[validOverlayCount - 1];
                    tempMaterialDefinition.overlayColors          = new Color32[validOverlayCount - 1];
                    tempMaterialDefinition.rects                  = new Rect[validOverlayCount - 1];
                    tempMaterialDefinition.overlayData            = new OverlayData[validOverlayCount];
                    tempMaterialDefinition.channelMask            = new Color[validOverlayCount][];
                    tempMaterialDefinition.channelAdditiveMask    = new Color[validOverlayCount][];
                    tempMaterialDefinition.overlayData[0]         = slot.GetOverlay(0);
                    tempMaterialDefinition.channelMask[0]         = slot.GetOverlay(0).colorData.channelMask;
                    tempMaterialDefinition.channelAdditiveMask[0] = slot.GetOverlay(0).colorData.channelAdditiveMask;
                    tempMaterialDefinition.slotData               = slot;

                    int overlayID = 0;
                    for (int j = 1; j < slot.OverlayCount; j++)
                    {
                        OverlayData overlay = slot.GetOverlay(j);
                        if (overlay == null)
                        {
                            continue;
                        }

                        tempMaterialDefinition.rects[overlayID]                 = overlay.rect;
                        tempMaterialDefinition.overlays[overlayID]              = new UMAData.textureData();
                        tempMaterialDefinition.overlays[overlayID].textureList  = overlay.textureArray;
                        tempMaterialDefinition.overlays[overlayID].alphaTexture = overlay.alphaMask;
                        tempMaterialDefinition.overlays[overlayID].overlayType  = overlay.overlayType;
                        tempMaterialDefinition.overlayColors[overlayID]         = overlay.colorData.color;

                        overlayID++;
                        tempMaterialDefinition.overlayData[overlayID]         = overlay;
                        tempMaterialDefinition.channelMask[overlayID]         = overlay.colorData.channelMask;
                        tempMaterialDefinition.channelAdditiveMask[overlayID] = overlay.colorData.channelAdditiveMask;
                    }

                    tempMaterialDefinition.overlayList  = overlayList;
                    tempMaterialDefinition.isRectShared = false;
                    for (int j = 0; j < generatedMaterial.materialFragments.Count; j++)
                    {
                        if (tempMaterialDefinition.overlayList == generatedMaterial.materialFragments[j].overlayList)
                        {
                            tempMaterialDefinition.isRectShared = true;
                            tempMaterialDefinition.rectFragment = generatedMaterial.materialFragments[j];
                            break;
                        }
                    }
                    generatedMaterial.materialFragments.Add(tempMaterialDefinition);
                }
            }

            packTexture = new MaxRectsBinPack(umaGenerator.atlasResolution, umaGenerator.atlasResolution, false);
        }