• RuntimesUnity
  • Repacking skins not getting Blend Mode Materials

Hi, anyone knows how to get the "GetRepackedSkin()" to make blend mode materials?
I'm using the GetRepackedSkin() function but when I use this method on my skin that has "Screen" Blend Mode on some parts, the screen material gets lost in the process and the parts that use this blend mode stay black due to the setup of this piece on spine.
Using my character without the repack skins method gives the right result, but there are too many skins so it would be way too heavy to mantain all atlases without repacking. Can anyone help me with that? The only thing I found on the manual about other properties than the actual texture is about Normal maps.

Related Discussions
...
  • Изменено

To include blend mode materials when using the GetRepackedSkin() function, you will need to modify the method to handle the creation and assignment of materials with the desired blend modes. The standard GetRepackedSkin() method focuses on repacking textures into a new atlas and does not inherently manage different material properties, such as blend modes, beyond the primary texture.

For handling materials with specific blend modes like "Screen," you would typically need to ensure that the repacking process is aware of these materials and applies them appropriately to the new attachments. This might involve extending the functionality of GetRepackedSkin() to include additional parameters for blend modes or to manually adjust the materials after repacking.

Repacking with normal maps is related, suggesting to modify the method to include additional texture properties. You might consider a similar approach for blend modes by identifying which attachments use special materials and ensuring those materials are recreated and applied to the corresponding attachments in the repacked skin.

If the current Spine runtime does not support this functionality out of the box, you may need to customize the GetRepackedSkin() method or post-process the repacked skins to assign the correct materials with the desired blend modes. This could involve tracking which attachments require special materials and applying those materials after the repacking process.

Harald Can I make a new material with the newly created repacked material texture at runtime? Just like Spine creates blend mode materials for imported textures? It could be useful in that case.

@Arigher Yes, there is nothing preventing you from creating new Materials and assign the repacked skin's texture there.

  • Arigher ответили на это сообщение.

    Harald I'm actualy not a programmer, can you show me any way to do that? I've been looking on the GetRepackedSkins() code but could not figure out how could I generate a new material from that repacked skin, only the standard .PrimaryMaterial that the script generates.

    @Arigher In your script you could e.g. access the SkeletonDataAsset's blend mode materials and create a material copy based on that:

    var additiveMaterials = skeletonAnimation.SkeletonDataAsset.blendModeMaterials.additiveMaterials;
    if (additiveMaterials.Count > 0) {
    	Material originalMaterial = additiveMaterials[0].material;
    	Material copiedMaterial = new Material(originalMaterial);
    	copiedMaterial.mainTexture = repackedTexture;
    	...
    }
    // same like ".additiveMaterials" applies with ".multiplyMaterials" and ".screenMaterials"