遮罩图和Spine导出时的主贴图分辨率相同,似乎主贴图会在程序运行期间被增加一些或修改一些内容,我该怎么保证我的遮罩图是跟着主贴图的变化也做出改变啊?
在UnityShader里的遮罩图与主贴图的uv无法对应
- Изменено
似乎您在代码中使用了 AtlasUtilities Skin.GetRepackedSkin()
创建新的Atlas纹理。
It seems that you are using AtlasUtilities Skin.GetRepackedSkin()
in your code to create new atlas textures.
如果我正确理解了您的问题,那么您只需要像您的主要纹理一样重新包装口罩图集即可。 这可以通过Skin.GetRepackedSkin()
处的附加参数 additionalTexturePropertyIDsToCopy
和additionalOutputTextures
来实现,请参阅文档此处。
If I understand your question correctly, then you only need to repack the mask atlas like your main texture. This can be achieved by the additional parameters additionalTexturePropertyIDsToCopy
and additionalOutputTextures
at Skin.GetRepackedSkin()
, see documentation here.
然后,您将在additionalOutputTextures
处传递参数new int[] { Shader.PropertyToID("_SfxMaskTex") }
,以创建蒙版纹理的打包图集。
You would then pass the parameter new int[] { Shader.PropertyToID("_SfxMaskTex") }
at additionalOutputTextures
to also create a packed atlas of your mask textures.
Harald написал
非常感谢解答!但我们使用的是spine的3.6.53版本,尝试把unity中的运行库升级到了3.8,但并不能支持旧版本的动画文件。有时间我会先尝试下在shader里根据新贴图与旧贴图的像素数的差来偏移uv坐标... 如果您能提供其他解决方案的话就更好了!!
您是否考虑过使用Spine 3.8重新导出所有骨架资产? 有一个命令行界面可用于通过脚本导出所有资产:
Export - Spine User Guide: Command line
例如,这是一个脚本,用于导出所有Spine示例项目并创建纹理地图集:
spine-runtimes/export.sh at 3.8
Have you considered re-exporting all skeleton assets with Spine 3.8? There is a command line interface available to export all assets via script:
Export - Spine User Guide: Command line
For example, here is a script we use to export all the Spine example projects and to create texture atlases:
spine-runtimes/export.sh at 3.8
如果这不是一个选择,我建议您在3.6 spine-unity运行时(AtlasUtilities.cs)中应用此提交所做的更改:
https://github.com/EsotericSoftware/spine-runtimes/commit/fc0a5df0db99916286047ab2577da7332be47bb4
更改可以手动应用,因为它们不会太多。
至少这比编写着色器映射逻辑要容易。
If this is not an option, I would rather suggest you to apply this commit's changes in your 3.6 spine-unity runtime (AtlasUtilities.cs
):
https://github.com/EsotericSoftware/spine-runtimes/commit/fc0a5df0db99916286047ab2577da7332be47bb4
The changes could be applied manually, as they are not too many.
At least this should be easier than writing the shader mapping logic.