unity 程序纹理_Unity中的程序随机纹理

unity 程序纹理_Unity中的程序随机纹理

unity 程序纹理

Have you ever tried using tileable textures to cover large surfaces or add fine-scale detail to your meshes? If so, you’re probably familiar with the visible repetition pattern that quickly emerges with higher tiling values. At Unity Labs, we have developed a new texturing technique that avoids this issue, Procedural Stochastic Texturing.

您是否尝试过使用可平铺的纹理覆盖大表面或向网格添加精细比例的细节? 如果是这样,您可能会熟悉可见的重复模式,该模式会随着较高的平铺值而Swift出现。 在Unity Labs,我们开发了一种避免这种问题的新纹理化技术,即过程随机纹理化。

Tileable textures are a useful tool to add detail to your 3D scenes. However, whenever you want to texture large areas or achieve highly detailed surfaces using tileable textures and detail maps, tiling patterns become visible. This effect is illustrated on the left-hand side of the following picture. Typically, reducing repetition patterns requires bigger textures or hiding the visible repetition with additional objects. In this blog post, we provide a plugin that solves this problem for textures with stochastic appearances, such as rust, moss, bark, etc. Its impact is shown on the right-hand side of the following picture.

花木纹理是将细节添加到3D场景的有用工具。 但是,每当您要使用可平铺的纹理和局部贴图对大面积进行纹理化或获得高度精细的表面时,平铺模式都将变得可见。 下图的左侧说明了这种效果。 通常,减少重复图案需要较大的纹理或使用其他对象隐藏可见的重复。 在此博客文章中,我们提供了一个插件,该插件可解决具有随机外观的纹理(例如锈,苔藓,树皮等)的此问题。其影响显示在下图的右侧。

unity 程序纹理_Unity中的程序随机纹理

Rusted metal material with regular texturing (left) and our technique (right).

具有规则纹理的生锈金属材料(左)和我们的技术(右)。

Download the plugin here.

此处下载插件。

Given an input texture, the plugin will procedurally generate an infinite texture that matches the appearance of the input. We do so by leveraging a state-of-the-art texture blending function that operates on a modified version of the input texture, which only requires three texture samples per fragment, and by fetching a small lookup-table. Since the plugin avoids the need for tiling, it makes it possible to cover larger surfaces with smaller textures and higher levels of detail without any repetition artifacts.

给定输入纹理后,插件将在程序上生成与输入外观匹配的无限纹理。 我们通过利用对输入纹理的修改版本进行操作的最先进的纹理混合功能(每个片段仅需要三个纹理样本)并获取一个小的查找表来做到这一点。 由于该插件避免了平铺的需要,因此可以使用较小的纹理和较高的细节覆盖较大的表面,而不会出现重复的伪像。

使用StandardStochastic着色器 (Using the StandardStochastic shader)

The plugin provides a variant of the Standard shader, which is included in a Unity package. Once you have imported the package, select the StandardStochastic shader for your material. The interface is the same as that of the Standard shader, with the addition of two new controls at the top, corresponding to the two required setup steps:

该插件提供了标准着色器的变体,它包含在Unity软件包中。 导入包后,为您的材质选择StandardStochastic着色器。 该界面与标准着色器的界面相同,在顶部添加了两个新控件,分别对应于两个必需的设置步骤:

unity 程序纹理_Unity中的程序随机纹理
unity 程序纹理_Unity中的程序随机纹理
  1. The Stochastic Inputs menu allows you to specify on which of the input textures you wish to enable our technique (it can be set to Everything, or specific textures, e.g., albedo and/or normal map).

    随机输入菜单允许您指定要在哪种输入纹理上启用我们的技术(可以将其设置为全部,或设置为特定纹理,例如反照率和/或法线贴图)。

  2. The Apply button pre-computes data for the selected stochastic inputs and updates the material, finishing the process. For each input texture, this step generates two intermediate textures located in the same folder.

    应用”按钮可为选定的随机输入预先计算数据并更新材料,从而完成过程。 对于每个输入纹理,此步骤生成位于同一文件夹中的两个中间纹理。

A few additional remarks:

一些补充说明:

  • Because existing intermediate textures are loaded when they are found to skip generation times, any modification to the original texture requires deleting them both before hitting the Apply button again to force their regeneration.

    由于发现现有的中间纹理会跳过生成时间时会加载它们,因此对原始纹理的任何修改都需要先删除它们,然后再再次单击“应用”按钮以强制其再生。
  • When switching between the Standard and StandardStochastic shaders, parameters are transferred back and forth.

    在Standard和StandardStochastic着色器之间切换时,参数会来回传递。
  • A StandardStochastic (Specular setup) shader is also provided for materials using the Specular workflow.

    还使用“镜面反射”工作流为材质提供了StandardStochastic(“镜面反射”设置)着色器。

The following examples show the prototype working with different materials using small (256²) input textures.

以下示例显示了使用小(256²)输入纹理处理不同材质的原型。

unity 程序纹理_Unity中的程序随机纹理

Wood detail maps with albedo, normal and occlusion textures

具有反照率,法线和遮挡纹理的木质细节图

unity 程序纹理_Unity中的程序随机纹理

Rock material with albedo, normal, occlusion and height textures

具有反照率,法线,遮挡和高度纹理的岩石材料

unity 程序纹理_Unity中的程序随机纹理

Iron material with albedo, normal, and metallic/smoothness textures

具有反照率,普通和金属/光滑度纹理的铁材料

局限性 (Limitations)

This technique is only compatible with tileable stochastic and near-stochastic textures, such as textures resembling random noise when viewed from a distance and typically natural-looking materials without precise geometric shapes.

此技术仅与可贴砖的随机和近乎随机纹理兼容,例如从远处观察时类似于随机噪声的纹理以及通常具有自然外观且没有精确几何形状的材料

unity 程序纹理_Unity中的程序随机纹理

反馈 (Feedback)

This is a research prototype; it is not under active development. As such, we don’t guarantee maintenance or support but feel free to ask any question and offer feedback on this Unity Forum thread. We are currently working on a ShaderGraph implementation for custom shaders and compatibility with the new rendering pipelines. Look out for updates on the forum thread!

这是一个研究原型; 它没有得到积极发展。 因此,我们不保证会提供任何维护或支持,但随时可以提出任何问题并提供有关Unity论坛主题的反馈。 我们目前正在开发ShaderGraph实现,以实现自定义着色器并与新的渲染管道兼容。 寻找有关论坛主题的更新!

进一步阅读 (Further reading)

Curious about how the plugin works? Check out our two recently published research papers on the subject, which our plugin builds upon:

对插件的工作方式感到好奇吗? 查看我们最近发表的有关该主题的两篇研究论文,我们的插件基于这些论文:

The code delivered with the plugin features comments referring to specific sections of the technical chapter.

插件随附的代码具有注释,这些注释指的是技术章节的特定部分。

翻译自: https://blogs.unity3d.com/2019/02/14/procedural-stochastic-texturing-in-unity/

unity 程序纹理