您可以将 Streaming Virtual Texturing (SVT) 与您在 Shader Graph 中创建的着色器一同使用。在开始之前,您必须在您的项目中启用虚拟纹理。内置的高清渲染管线着色器(例如 Lit 和 Unlit)不支持 SVT。
要使用 SVT 流式传输纹理,您必须将纹理添加到虚拟纹理属性。虚拟纹理属性定义了一组相关纹理。要对这些纹理进行采样,请将虚拟纹理属性连接到 Sample Virtual Texture 节点。Sample Virtual Texture 节点将一个 UV 坐标作为输入,并使用该 UV 坐标对所有纹理进行采样。
您应该尽可能将纹理组合到同一个虚拟纹理属性中。这是因为对属于同一虚拟纹理属性的多个纹理进行采样比对多个虚拟纹理属性进行采样更有效。
当您在片元阶段使用 Sample Virtual Texture 节点时,SVT 会根据其采样的 UV 自动流式传输纹理图块。为此,Sample Virtual Texture 节点将其读取的图块 ID 输出到渲染目标中。要关闭此功能,请打开节点设置并禁用 Automatic Streaming。有关更多信息,请参阅 Streaming Virtual Texturing 的工作原理。
要在顶点阶段使用 Sample Virtual Texture 节点,首先需要在 Sample Virtual Texture 节点上禁用 Automatic Streaming,然后选择 Lod Level 模式。然后,您必须使用脚本手动请求 SVT 加载图块。为此,请使用 VirtualTexturing.Streaming.RequestRegion
方法,如下所示:
VirtualTexturing.Streaming.RequestRegion(Material, Stack ID, Rect, mipmap, numMips)
您可以使用此方法加载任何尚不可见的图块,这允许您实现诸如构建预取系统之类的功能。您需要在每一帧中调用此方法,否则系统会假定不再需要这些图块,并可能在流式传输其他图块时将它们清除。
您必须在 Shader Graph 中分配虚拟纹理属性的所有纹理字段。
对于您分配给虚拟纹理属性的每个唯一纹理组合,SVT 将其复制到流式虚拟纹理的唯一部分。因此,如果您在虚拟纹理属性中使用许多不同的纹理组合,可能会增加您的项目构建大小,因为每个组合都是单独存储的。
在 Shader Graph 中使用 Sample Virtual Texture 节点时存在一些限制。
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.