近來每日見VP在各處談笑風聲,深覺自己文筆欠佳,開始嘗試一些技術寫作的練習,也用於日後備忘。

演講者開篇自我介紹的時候提了一下自己因為天生基因缺陷,只有50%的視力。不知是諷刺也好,機緣巧合巧合,又對遊戲尤其是美麗的畫面無比熱愛,將圖形程式作為自己的終身的職業追求。

The Rendering and Art of '11-11 Memories Retold'

11-11 Memories Retold是一款背景設定於二戰期間的敘事遊戲。開發成員來自於世界各地。引擎使用的使用的是Unity2017。3, 由於當時SRP還沒有成熟,使用的是自行修改的unity legacy的延時渲染 (此處的Legacy是相對於unity新的hdrp而言)

遊戲開發歷經6個月的pre production以及10個月的production。因為遊戲需要在點題的11月11日發售,對團隊而言任何延誤是無法接受的,也因此產生了許多有意思的小插曲。

The Rendering and Art of '11-11 Memories Retold'

遊戲使用了濃厚的油畫感的風格化渲染,正如演講的題目Live Painting所言。

The Rendering and Art of '11-11 Memories Retold'

演講者提到,在尋找一些渲染技術相關的論文的時候,時常會發現一些年代久遠的論文,這些技術可能由於種種原因在當時沒有實現商用。日後重拾,或由於硬體效能提升得以涅槃,或與渲染管線難以融合繼續沉寂。演講者在嘗試油畫風格化渲染時,找到了以上兩篇使用粒子來模擬油畫筆觸的文章,為日後的風格化渲染埋下了種子。前者生效於物體空間中,後者是一個全屏後處理。

The Rendering and Art of '11-11 Memories Retold'

從左到右依次為預設渲染,發射粒子模擬筆觸,最終融合。

The Rendering and Art of '11-11 Memories Retold'

作者參考的另一個GDC講座

The Rendering and Art of '11-11 Memories Retold'

美術可以控制筆觸的大小,是否流動,是否馬上消失(boil)。例如一個火車上的場景,美術希望可以透過筆觸的流動來表現運動感,此時便需要調節筆觸的方向以及速度。

The Rendering and Art of '11-11 Memories Retold'

The Rendering and Art of '11-11 Memories Retold'

使筆觸與物體表面對齊是一個挑戰。筆觸需要考慮到物體本身的位置,與透視變形。演講者在PS中傳入了world position, tangent, cotangent, 以此來生成一個offset point。並將其傳入螢幕空間獲得一個direction vector,normalize 後作為radiant/radius?儲存。

The Rendering and Art of '11-11 Memories Retold'

The Rendering and Art of '11-11 Memories Retold'

隨機數生成一開始使用的是一張噪聲貼圖,生成的效果不好,同時效能也令人堪憂。後來嘗試了WangHash來生成噪聲,易於實現的同時效果也很好。

The Rendering and Art of '11-11 Memories Retold'

The Rendering and Art of '11-11 Memories Retold'

生成的筆觸隨著鏡頭的移動會有頻閃的現象,為了解決這個問題,演講者讓筆觸隨著運動向量移動。

The Rendering and Art of '11-11 Memories Retold'

透過BOX與BOX的碰撞檢測,將筆觸的index儲存於每個tile的buffer中

The Rendering and Art of '11-11 Memories Retold'

使用computer shader來進行更精細的culling以及粒子排序(bitonic)

The Rendering and Art of '11-11 Memories Retold'

實現方式與原論文的有很多不一樣的地方。

將粒子資料讀進Local Data Storage。

清空顏色,遍歷粒子,透過UV計算畫素是否在筆觸的包圍盒中。繪製。

因為alpha blending是自己實現的,所以可以從前到後渲染,當該畫素畫的足夠濃密時,即alpha超過閾值,則提前中斷。

將該RT疊回背景,alpha值取之前設定的筆刷範圍。

The Rendering and Art of '11-11 Memories Retold'

。。。。。真的是筆刷

The Rendering and Art of '11-11 Memories Retold'

開發者最崩潰的時候,如果不能解決模糊的問題,最終只能放棄這種渲染風格。

The Rendering and Art of '11-11 Memories Retold'

造成模糊的罪魁禍首便是粒子與物體的穿插。加入early depth test以後情況得以改善,最後加入了背景模糊以掩蓋一些瑕疵。背景模糊使用的是kawase filter。

The Rendering and Art of '11-11 Memories Retold'

使用kawase filter是因為其計算量比起普通的filter效率高很多。

The Rendering and Art of '11-11 Memories Retold'

筆觸大小會根據深度自適應。

The Rendering and Art of '11-11 Memories Retold'

The Rendering and Art of '11-11 Memories Retold'

Unity自帶的motion vector有一點類似於噪聲的問題,即使沒有在移動鏡頭,實際motion vector也在略微漂移。解決方法是給motion vector加一個閾值。

The Rendering and Art of '11-11 Memories Retold'

人在繪畫的時候每一筆的筆觸其實都會有略微的不同,為了接近人手繪的效果,演講者給筆觸的顏色以及角度添加了一些隨機。

The Rendering and Art of '11-11 Memories Retold'

一開始顏色的隨機使用了hsv,但是遇到了一些頻閃的問題。作者發現其實RGB顏色在方塊上的分佈和HSV也差不多,便嘗試了在黑白向量採隨機向量的辦法。也避免了HSV顏色轉換的計算。

The Rendering and Art of '11-11 Memories Retold'

粒子實現的方式有2種

1:Alpha cutout, 直接將貼圖疊到已有的strike buffer中,因為可以新增光照/自發光,也被用於實現光源。

2:unity內建的粒子系統,但是因為使用unity的延時渲染管線,很多光照資訊無法獲取到,讓粒子和場景融洽需要美術手動調節。

The Rendering and Art of '11-11 Memories Retold'

The Rendering and Art of '11-11 Memories Retold'

太真實了

不過因為pre-productoin時間足夠,演講者在pre-production期間得以做出主美滿意的結果。

The Rendering and Art of '11-11 Memories Retold'

全域性:筆觸大小,生命週期等

材質:Override

Texel: 每畫素的調節

The Rendering and Art of '11-11 Memories Retold'

SD: 快速生產衍生貼圖。實時預覽。

The Rendering and Art of '11-11 Memories Retold'

SD材質匯入UNITY實時調節引數的例子。

The Rendering and Art of '11-11 Memories Retold'

各種問題。。希望新的整合會更好。

The Rendering and Art of '11-11 Memories Retold'

Noise的調節

The Rendering and Art of '11-11 Memories Retold'

角色用SP手繪,場景資源等展好UV以後丟進SD

The Rendering and Art of '11-11 Memories Retold'

這麼風格化的模型居然用的是PBR貼圖也是沒有想到。

The Rendering and Art of '11-11 Memories Retold'

自定義貼圖

The Rendering and Art of '11-11 Memories Retold'

使用環境光計算的邊緣光,與場景融合更好。

The Rendering and Art of '11-11 Memories Retold'

The Rendering and Art of '11-11 Memories Retold'

目標平臺

給自己的筆記:多看GCN架構相關的東西,現在和未來的主機還是將基於這個架構。

The Rendering and Art of '11-11 Memories Retold'

GPU Razor, PS4效能分析神器

The Rendering and Art of '11-11 Memories Retold'

如果使用一些grphics類的呼叫,很可能造成渲染執行緒對主執行緒的依賴。

解決方案:用Command Buffer。

The Rendering and Art of '11-11 Memories Retold'

HACK

The Rendering and Art of '11-11 Memories Retold'

一些特殊forward物體使用指令碼調cmd buffer繪製。SRP下加個pass即可

The Rendering and Art of '11-11 Memories Retold'

The Rendering and Art of '11-11 Memories Retold'

The Rendering and Art of '11-11 Memories Retold'

ALU最佳化參考資料

The Rendering and Art of '11-11 Memories Retold'

實時檢視做的最佳化是否可以減少指令。

The Rendering and Art of '11-11 Memories Retold'

Structure of Arrays對cache更友好

The Rendering and Art of '11-11 Memories Retold'

The Rendering and Art of '11-11 Memories Retold'

和卡通渲染一樣,頂點色也被用來做一些細微調整。這裡調節了一些筆刷分佈與走向。

The Rendering and Art of '11-11 Memories Retold'

The Rendering and Art of '11-11 Memories Retold'

左邊原畫,右邊實現。

感謝。