先上效果图

 

然后对水Water.cs以及shader FX/Water进行解析

1.tex2D与tex2Dproj的区别

float4 uv1 = i.ref; uv1.xy += bump * _ReflDistort;
//half4 refl = tex2Dproj( _ReflectionTex, UNITY_PROJ_COORD(uv1) );
half4 refl = tex2D(_ReflectionTex, uv1/uv1.w);

2.shader中的Tags标签可以在cs脚本中获得,标签名字可以自定义

Subshader {
Tags { "WaterMode"="Refractive" "RenderType"="Opaque" }
Pass {

string mode = mat.GetTag("WATERMODE", false);

 

3.禁用,开启逐像素光照

// Optionally disable pixel lights for reflection/refraction
int oldPixelLightCount = QualitySettings.pixelLightCount;

QualitySettings.pixelLightCount = 0;

 

4.斜裁剪矩阵推导解析

https://blog.csdn.net/mobilebbki399/article/details/79491863

http://aras-p.info/texts/obliqueortho.html