__地形__上可能有草丛和其他小对象(如岩石)覆盖在其表面上。Unity 使用纹理四边形或完整网格渲染这些对象,具体取决于您需要的细节级别和性能。草和其他细节当前仅在内置渲染管线和通用渲染管线 (URP) 中有效。
可启用纹理四边形的 Billboard 属性,使其自动面向摄像机。这是在游戏开发中实现良好草丛效果的常见方式。
对于细节网格,可以将 Render Mode 属性设置为 Vertex Lit 或 Grass。
要启用草和细节绘制,请选择工具栏上的 Paint Details 按钮。
最初,地形没有可用的草或细节。在 Inspector 中,单击 Edit Details 按钮可显示带有 Add Grass Texture 和 Add Detail Mesh 选项的菜单。单击任一选项将弹出一个窗口,在其中可以选择要添加到地形以便进行绘制的__资源__。
对于草,该窗口如下所示:
Detail Texture 是表示草的纹理。您可以从 Asset Store 下载纹理,也可以创建自己的纹理。纹理是一个小图像,图像中的空白区域的 Alpha 设置为零。请注意,这里的“草”(Grass) 是一个通用术语;纹理可以表示花朵或人造物体(如铁丝网)。
Min Width、Max Width、Min Height 和 Max Height 值可指定生成的草丛的大小上限和下限。为了创建逼真的外观,草是以随机“噪点”图案生成的,有裸露斑块散布在草地上。
Noise Spread 值控制着裸露与草丛斑块的近似大小,值越高表示给定区域内的变化越大。Unity 使用柏林噪声 (Perlin noise) 算法生成噪点;__Noise Spread__ 是指在地形上的 x、y 位置与噪点图像之间应用的缩放。通常认为,交替的草地斑块处于中心位置比处于边缘位置更“健康”,而 Healthy Color 和 Dry Color 中设置的颜色表示草丛的健康状态。
最后,当启用 Billboard 选项时,草的图像将旋转,因此它们将始终面向__摄像机__。当您希望显示密集的草地时,此选项很有用,因为草丛是二维的,不能从侧面看到。然而,对于稀疏的草,草丛个体的旋转对于观察者来说可能会变得很明显,产生奇怪的效果。
对于细节网格,例如岩石,窗口如下所示:
使用 Add Detail Mesh 可从项目中选择预制件。Unity 在 Min Width 和 Max Width 值以及 Min Height 和 Max Height 值之间对其随机缩放。Unity 对 x 轴和 z 轴使用宽度缩放,而对 y 轴使用高度缩放。Noise Spread、Healthy Color 和 Dry Color 值的作用与它们对草的作用相同。
可将 Render Mode 设置为 Vertex Lit 或 Grass。
2019–11–25 页面已修订
添加了关于渲染管线的信息
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.