2019年5月13日 星期一

Next step

前一陣子已經花了蠻長的時間閱讀以前保存的技術文件
主要已 Unity engine為核心去探索較新的 game develop技術
也差不多該是準備動手做的時機了吧
該看的其實看的差不多了
不親自下海練練身手, 讀再多也只是看故事久了就忘了

這裡先整理一些重要的 references
已經深入研讀的主題包含
Unity :
------------------------------------------------------
Standard Shader
http://unitytaiwan.blogspot.com/2017/03/unity_14.html
http://geekfaner.com/unity/blog16_UnityStandardShader.html

Global Illumination*
https://lmhpoly.com/unity-5-tutorial-lighting-and-post-processing-low-poly-scene/

Post Processing*
http://geekfaner.com/unity/blog11_PostProcessStackV2.html

Scriptable render pipeline
https://blogs.unity3d.com/2018/01/31/srp-overview/
https://blogs.unity3d.com/2018/02/21/the-lightweight-render-pipeline-optimizing-real-time-performance/
https://blogs.unity3d.com/2018/09/24/the-high-definition-render-pipeline-getting-started-guide-for-artists/
https://blogs.unity3d.com/2019/02/08/we-have-you-covered-with-the-measured-materials-library/?fbclid=IwAR3VNDyX5HPbY4XI93za-2POUEpti4rFA-ZxQIjda75Z1O82RPTj4xJLR7o
http://geekfaner.com/unity/blog13_SRP.html
https://makedreamvsogre.blogspot.com/2019/03/lwrp.html?fbclid=IwAR0X2g8DoCw3GfM7Q2yUE2lSQ6QnnrenurmvmqPtFqYJ3TkVQf01EJu-y10
https://blogs.unity3d.com/2019/02/28/srp-batcher-speed-up-your-rendering/?fbclid=IwAR3m9z59QaaTWsrYrw3BKjeTIRsRgOZpHzO9Vc4Sr-LsrzF2dkQMwHZfCY4

Shader Graph
https://blogs.unity3d.com/2018/12/19/unity-2018-3-shader-graph-update-lit-master-node/?fbclid=IwAR2wx5tyhU9MbwVJldqrKNBRZmWcsEBDuwcIGxkIHVuDqoSflZAqmFS8oM4

Unity test runner
https://docs.unity3d.com/Manual/testing-editortestsrunner.html

Assembly definitions
https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html

Augment Reality
https://blogs.unity3d.com/2018/12/18/unitys-handheld-ar-ecosystem-ar-foundation-arcore-and-arkit/?fbclid=IwAR1q8iBdWVHIaaklZli0wsCd6kaErGEtmS6p-n5P5CJ7xqXgi1ZPK0zF7_I
------------------------------------------------------

Graphics :
------------------------------------------------------
Forward+ rendering / Deferred rendering*
https://zhuanlan.zhihu.com/p/54694743?fbclid=IwAR24BiJ-JoBOH5s2Ar0IUYKhEKWd-erl1poCx--aiRUMuueJX4-LfH5ioxs

Screen space reflection
https://bartwronski.com/2014/01/25/the-future-of-screenspace-reflections/
https://www.gamasutra.com/blogs/DavidArppe/20170405/295240/How_to_get_Stunning_Graphics_with_Raymarching_in_Games.php

Physically based shading
http://geekfaner.com/unity/blog5_PBR.html

High dynamic range rendering
http://geekfaner.com/unity/blog1_gamma.html
------------------------------------------------------

Allen大神的指引永遠都像金玉良言
https://www.ptt.cc/bbs/GameDesign/M.1556422552.A.4CE.html


2019年5月7日 星期二

Tests in Unity

過去幾年接觸過 TDD (Test-Driven Dev)的概念後
就一直想要在自己的專案中實現 unit test實作
但礙於時間不夠充足之類的前提讓我一直沒有動工

最近工作上的專案算是比較有空下來的時間
所以針對 Unity 官方提出的 test環境進行一番研究與探索
算是準備的差不多可以執行自己的 test programming了吧

當然也歸功於 Unity官方準備的開發環境與說明文件真的很方便
所以感覺要實現 TDD概念開發這點也不是那麼難了

幾個關鍵可先參考官方文件
Unity Test Runner
https://docs.unity3d.com/Manual/testing-editortestsrunner.html
https://docs.unity3d.com/Manual/PlaymodeTestFramework.html
這份則是比較舊版的官方中文翻譯文件
https://docs.unity3d.com/Manual/PlaymodeTestFramework.html

基本上簡易的unit test script可說是無痛實現
照著官方說明操作就可以建好完整的 test環境
但事情總是不會只有這麼簡單
像我目前的專案經過長期粗暴醜陋的"封裝"
我想進行測試的大部分內容已經牽涉到 internal / private / protected封裝
所以在 [Test]函式中是無法存取到該內容的

這一點算是老問題了, 所以 .NET官方早有解法
[assembly: InternalsVisibleTo(“UnitTests”)]
http://anthonygiretti.com/2018/06/27/how-to-unit-test-internal-classes-in-net-core-applications/

但在 Unity Test Runner環境下要如何實現這一點呢?
我首先必須把 assembly正確區分出來, 這個屬性才能派上用法
因此查過官方文件後, 我該做的就是針對所有 scripts設定正確的 assembly definition asset
https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html

好啦, 問題來了, 誠如官方文件所說, 如下圖
Predefined versus manually defined assemblies
手動設定的 assembly (.dll)都無法參考到預設的 Assembly-CSharp.dll
因此如果我想要為專案正確設定 assembly definitions,
等於要將整個專案所有的 scripts做一次完整重構了吧
是說這一步驟也是該做, 只是當初一開始只想著輕鬆實現 unit test開發環境
沒想到還是得先經過大規模的重構才有可能完成有意義的 unit test

如上所述如果整個專案都正確區分成正確的 assemblies,
應該就會有個對應的 test assemblies (Tests.dll)去參考想測試的部分 (如 Main.dll, Stuff.dll, ...)
然後在 Tests.dll中實現 unit tests

當然總是還是有更偷懶的做法
準備一個 Editor資料夾, 在其中建立 test scripts
如此一來 test scripts便會被加入預設的 Assembly-CSharp-Editor.dll
因此整個專案仍然維持最原始單純的 Assembly-CSharp.dll 與 Assembly-CSharp-Editor.dll
因此接下來只要在某個想被測試的 script file中,
設定上面提到的 InvernalsVisibltTo attribute
我自己測試都是在 namespace外側設定該 attribute, 如下所示

using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Assembly-CSharp-Editor")]
namespace MYWORK
{ ... }

如此做後, Assembly-CSharp-Editor.dll 中所有 scripts
都可以看到 Assembly-CSharp.dll裡面所有的 internal內容,
至於 private/protected內容的話則可以透過 Reflection手段取得
之後我有深入玩過的話再另外分享一篇吧
我知道這招很髒, 不過偷懶嘛, 只是為了先求快
之後真的要實現完整的 unit test, scripting結構重構還是逃不了的