前篇:unity3d 制造自己的水体water effect(一)
曲面细分:Unity3d 使用DX11的曲面细分
PBR:
讲求基本算法
Unity3d 基于物理渲染Physically-Based Rendering之specular BRDF
plus篇
Unity3d 基于物理渲染Physically-Based Rendering之实现
最终篇
Unity3d 基于物理渲染Physically-Based Rendering之最终篇
之前一直在用unity4.6写shader,终于下定决心换unity5,然后发现,unity5的渲染比4强太多,
博主整共合了4个波
关键代码如下:
<span style="font-size:14px;"> vv = sqrt(_G * _Lambda / (2 * _PIE)); psi = 2 * _PIE / _Lambda *(dot(v.vertex.xyz, _K.xyz) + vv*_Time.y); s = lerp(-cos(psi), sin(psi), _A)*0.05; p.y += s; vv = sqrt(_G * _Lambda2 / (2 * _PIE)); psi = 2 * _PIE / _Lambda2 *(dot(v.vertex.xyz, _K2.xyz) + vv*_Time.y); s = lerp(-cos(psi), sin(psi), _A2)*0.05; p.y += s; vv = sqrt(_G * _Lambda3 / (2 * _PIE)); psi = 2 * _PIE / _Lambda3 *(dot(v.vertex.xyz, _K3.xyz) + vv*_Time.y); s = lerp(-cos(psi), sin(psi), _A3)*0.1; p.y += s; vv = sqrt(_G * _Lambda4 / (2 * _PIE)); psi = 2 * _PIE / _Lambda4 *(dot(v.vertex.xyz, _K4.xyz) + vv*_Time.y); s = lerp(-cos(psi), sin(psi), _A4)*0.1; p.y += s; v.vertex.xyz = p.xyz;</span>
关键代码如下:
<span style="font-size:14px;"> float wave(float x, float z, float timer) { float y = 0; float oct = _OCT; float fac = _FAC; float d = sqrt(x * x + z * z);// length(float2(x, z)); for (oct; oct>0; oct--) { y -= fac * cos(timer * _SP + (1 / fac) * x * z * _WS); fac /= 2; } return 2 * _VS * d * y; } </span>
-------- by wolf96 http://blog.csdn.net/wolf96
版权声明:本文为博主原创文章,未经博主允许不得转载。
unity3d 制造自己的水体water effect(二)
原文地址:http://blog.csdn.net/wolf96/article/details/48434497