在 Unity 编辑器中,您可以将纹理标记为仅由虚拟纹理使用。这样可以优化内存使用和场景加载时间,并减少了构建的大小。要将纹理标记为仅由虚拟纹理使用,请打开其纹理导入器并启用 Virtual Texture Only。
在实践中,当您使用虚拟纹理时,应将尽可能多的纹理标记为仅虚拟纹理将这些优势最大化。请注意,如果您将纹理标记为仅虚拟纹理,不能将它与项目中的常规纹理采样器一起使用。在编辑器中,您似乎可以将它与常规纹理采样器一起使用,因为会出现低分辨率预览,但如果您随后构建播放器,则会发生错误。
默认情况下,当您在 Unity 编辑器中加载场景时,编辑器会将所有引用的纹理加载到 CPU 和 GPU 内存中。Unity 编辑器无法将纹理从磁盘流式传输到 GPU 内存,但 SVT 可以将纹理从 CPU 内存流式传输。当您将纹理标记为仅虚拟纹理,这意味着在场景加载时,编辑器仅将其加载到 CPU 内存中,然后从该纹理中提取图块并按需将其流式传输到 GPU 内存中。
在具有许多高分辨率纹理的项目中,这会显着减少 Unity 编辑器中的 GPU 内存使用和场景加载时间。因此,最好将尽可能多的纹理标记为仅虚拟纹理, 以确保 Streaming Virtual Texturing (SVT) 系统将其仅从 CPU 流式传输。
如果您未将纹理标记为仅虚拟纹理,然后在播放器中将其与虚拟纹理一起使用,SVT 系统会在 CPU 和 GPU 内存中均保留纹理的副本。
默认情况下,Unity 将 Shader Graph 中采样的所有纹理作为标准纹理制件添加到构建中。此外,虚拟纹理将所有纹理堆栈纹理导入到平铺串流文件中,Unity 也将其包含在构建中。
请注意,如果您将纹理标记为仅虚拟纹理,但在播放器中将其用作标准纹理,则播放器构建失败。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.