精選文章

SmallBurger Asset Home

  SmallBurger

2017年12月11日 星期一

My new infinity GPU vertex animated ocean on mobile average fps 60 (Samsung 7)

其實這個系統做一半,因為專案趕進度的關係,就停下來了,最近比較有時間把它給順好。 總結一下Implement的過程:

Vertex program:
1.計算 projected(目的是為了無限大:參考了Habib's Water ShaderCeto Ocean System
2.計算 projected position
3.計算 Perlin noise on GPU(目的是為了加速計算大量的點位移-高度)
4.計算 Vertex Normal (之後會拿來當normal map的world space)
5.Animated UV(normal and foam map)

Fragment(Pixel)Program:
1.計算深度(高度及透視深度的混合,參考Ceto Ocean System,有點類似霧氣擴散的效果)
2.將Normal map轉換成World Space
3.計算diffuse
4.計算specular
5.計算distortion(refraction或reflection參數分開)
6.計算泡沫效果,並將其與refraction混合(只有岸邊淺水的地方才有邊緣泡沫)
7.計算水顏色,淺水、深水與refractoin依照深度及折射率進行混色,之後再依照反射率跟reflection進行混色,完成了所謂的SeaColor。
8.簡單模擬Fersnel Terms(依照一張Fersnel map,混合沒有考慮Diffuse及有考慮Diffuse的狀況,進行混色):
fixed3 SpecAndDiffuse = SeaColor * Diffuse + Specular;
fixed3 SpecNoDiffuse = SeaColor + Specular;
fixed4 OutColor = fixed4(lerp(SpecAndDiffuse, SpecNoDiffuse, FresnelRatio), 1.0);
9.再加上海浪模擬(依照Normal與Up軸的dot值,決定海浪貼圖顯示的強弱)
10.最後再加上fog的顏色,便大功告成
成果如下:



Dream continues in...

沒有留言:

張貼留言