-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/uber lit shader #32
Conversation
# Conflicts: # Assets/Nova/Editor/Core/Scripts/MaterialEditorUtility.cs # Assets/Nova/Editor/Core/Scripts/MaterialPropertyNames.cs # Assets/Nova/Editor/Core/Scripts/ParticlesUberLitGUI.cs # Assets/Nova/Editor/Core/Scripts/Shaders/Particles.hlsl # Assets/Nova/Editor/Core/Scripts/Shaders/ParticlesUber.hlsl # Assets/Nova/Editor/Core/Scripts/Shaders/ParticlesUberLit.shader # Assets/Nova/Editor/Core/Scripts/Shaders/ParticlesUberLit.shader.meta # Assets/Nova/Editor/Core/Scripts/Shaders/ParticlesUberLitEditor.hlsl # Assets/Nova/Editor/Core/Scripts/Shaders/ParticlesUberLitEditor.hlsl.meta # Assets/Nova/Editor/Core/Scripts/Shaders/ParticlesUberLitForward.hlsl # Assets/Nova/Editor/Core/Scripts/Shaders/ParticlesUberLitForward.hlsl.meta
To use the writing process for depth values and normals in the Lit version as well.
*/ | ||
struct AttributesLit | ||
{ | ||
Attributes attributesUnlit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こんな使い方ができるんですね 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
できるんです!
#include "ParticlesUberUnLit.hlsl" | ||
#include "ParticlesUberLit.hlsl" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
あっても困らないですが、 ParticlesUberLit.hlsl
の中で ParticlesUberUnLit.hlsl
をインクルードしているので、ここで ParticlesUberUnLit.hlsl
は不要そうです。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
96eab88 で削除しました。
Testフォルダは、Demoフォルダを整理してそちらにまとめてしまっていいと思います!(特に分けている理由がなければ |
79fad49 fca73df |
これ上がってないかも?です。(ProjectVersion.txtが上がってない) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
バージョンの件以外は問題ないのでApproveします
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1つだけ些細なところが気になりましたが、基本approveです
@@ -5,7 +5,13 @@ EditorBuildSettings: | |||
m_ObjectHideFlags: 0 | |||
serializedVersion: 2 | |||
m_Scenes: | |||
- enabled: 1 | |||
- enabled: 0 | |||
path: Assets/Demo/Demo.unity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このファイルが無くなっているので、disabledとはいえ移動先に書き換えた方が良さそうな気がしています
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この修正は次に出す予定の最適化のPRに含まれているため、次回の対応とさせてください。
NovaShaderのLit版の仕様が全入りしました。
かなり変更点が多くなっているので、いったんPRを出させていただきます。
各種端末での詳細なテストは別ブランチで行います。
1. 実装概要
Lit版の実装方針としては、Unlit版のフラグメントシェーダーで計算されるカラーをアルベドカラーとして考えて、そのカラーをUniversalFragmentPBRの入力値としています。そのため、Unlit版のカラーの計算処理を共通で使えるような実装に変更しています。
法線、スペキュラ、メタリックなどの入力値はLit専用のGUIからの設定に基づいて入力しています。
それ以外のパラメータはURPのLit版の実装を参考にして、同じ値を入れるようにしています。
Unlit版に影響を与えないように実装していきましたが、共通化する際に多少コードを変更しています。
2.URPのLit版とのクォリティ面での差異
URPのLit版と下記の差異があります。
(どの差異もクォリティ面ではポジティブな違いです)
SSAOが適用されている
Lit版の実装による影響ではないのですが、URPのパーティクルのシェーダーは法線を書き込んでいないため、SSAOによる陰影が生まれていません。ですが、Novaシェーダーが版ではSSAOを有効にすると陰影が生まれます。
分かりにくいですが、地面とティーポットが設置している箇所にうっすらと影が生まれています。
SSAOあり(Nova)
SSAOなし(URP)
URP版で法線を書き込んでいないのはパフォーマンス的なことを考慮しているのかと思いますが、SSAOを有効にすると地面との設置感が生まれることと、今後SSRなどを有効にした際に、エフェクトの反射なども起こせるようになるので、法線は書き込むままにしております。
法線マップが貼られていないときのライティング
法線マップが貼られていない場合、URPでは頂点シェーダーでの法線の正規化が高速化のためにスキップされており、ライティングの結果のクオリティが下がっています。ただ、NovaShaderのUnlit版の処理でそもそも法線が正規化されている点と、クオリティ面がかなり違っていたため、そのままにしています。
法線マップなしライティング(NOVA)
法線マップなしライティング(URP)
バンプスケール
バンプスケールは法線マップの起伏を大きくするためのパラメータで、URPのLit版にも存在しています。
バンプスケール 1.0倍
バンプスケール 3.0倍
URPのLit版にも存在しているのですが、URP版はモバイルに持っていくと高速化のためにバンプスケールが無効になっています。ですが、URP版のコードを読んでみると、法線のxy要素に乗算しているだけの処理なので、パフォーマンスに大きな影響はなさそうでした。
バンプスケールにカスタムコードを使うように改造すれば、ひび割れが生まれてきたり、壁がへこむような演出も作れそうなのでNOVA版では有効のままにしています。
これが不要なようでしたら削除します。
3. テスト用のシーンの追加
Lit版の実装にあたり、テスト用のシーンを下記の二つ追加しています。
これらのテストを行って、正しく動作していることを確認しています。
テストは手持ちのPixel 6 Proで行いました。
下記のテスト動画では、3本のディレクショナルライトとカメラを回しています。
エフェクトにライトの影響と視線の移動よる鏡面反射が起きていることを確認できます。
Assets/Test/TestUberLit_00( URP版とNova版の差異を調べるテスト )
https://user-images.githubusercontent.com/106138524/182510421-5259dcef-282b-469d-a577-ef062d96c4bc.mp4
Assets/Test/TestUberLit_01( Nova版のLitに各種機能テスト。Flowmap、Tintmap、Emissionmapなど)
https://user-images.githubusercontent.com/106138524/182508779-d8c2da05-38ba-4f2a-985d-5093bb079c9f.mp4