Unity 在标准资源包中包含几个水预制件(包括必要的着色器、脚本和艺术资源)。提供了单独的日间和夜间水预制件。
请注意,本文档中描述的水反射在 VR 中不适用。
将一个现有的水预制件放入场景中。确保已安装标准资源:
预制件对水使用椭圆形网格。如果需要使用其他不同的网格,请在水游戏对象的__网格过滤器 (Mesh Filter)__ 中进行更改:
简单的水需要将脚本附加到类似平面的网格并使用水着色器:
反射/折射水在从头开始设置时需要类似的步骤:
这些属性用在__反射 (Reflective)__ 和__折射 (Refractive)__ 水着色器中。它们中的大多数也用于__简单 (Simple)__ 水着色器。
属性: | 功能: |
---|---|
Wave scale | 缩放水波法线贴图。该值越小,水波越大。 |
Reflection/refraction distort | 水波法线贴图会扭曲多少反射/折射。 |
Refraction color | 额外的折射色调。 |
Environment reflection/refraction | 实时反射和折射的渲染纹理。 |
Normalmap | 定义水波的形状。通过组合这两个法线贴图产生最终水波(每个法线贴图以不同的方向、比例和速度滚动)。第二个法线贴图的大小是第一个法线贴图的一半。 |
Wave speed | 第一个法线贴图(第一和第二个数字)和第二个法线贴图(第三和第四个数字)的滚动速度。 |
Fresnel | 该纹理具有控制菲涅耳效应(根据视角可以看到多少反射与折射)的 Alpha 通道。 |
__反射__和__折射__着色器不使用其余属性,但仍然需要设置这些属性以防用户的显卡不支持该着色器而必须回退到更简单的着色器:
属性: | 功能: |
---|---|
Reflective color/cube and fresnel | 该纹理根据视角定义水颜色 (RGB) 和菲涅耳效应 (A)。 |
Horizon color | 水在地平线上的颜色。此属性仅用于__简单__水着色器。 |
Fallback 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.