Notes of precomputed lighting scenerios and level streaming
Level streaming
- http://historia.co.jp/archives/4153/
- https://docs.unrealengine.com/latest/INT/Engine/LevelStreaming/WorldBrowser/index.html
- https://docs.unrealengine.com/latest/INT/Engine/LevelStreaming/Overview/index.html
- https://docs.unrealengine.com/latest/INT/Engine/LevelStreaming/StreamingVolumes/index.html
- http://monsho.blog63.fc2.com/blog-entry-123.html
- https://qiita.com/donbutsu17/items/ca8fbf19c1c43b3c465d
Input latency
Notes of DBuffer
- https://docs.unrealengine.com/latest/INT/Resources/ContentExamples/Decals/index.html
- http://monsho.blog63.fc2.com/blog-entry-139.html
- https://answers.unrealengine.com/questions/450855/
- http://miyahuji111.hatenablog.com/entry/2016/10/16/154037
- マテリアル本, CEDEC2016
- DepthFade : https://docs.unrealengine.com/latest/JPN/Engine/Rendering/Materials/ExpressionReference/Depth/index.html
Notes of Separate Traslucency
- http://darakemonodarake.hatenablog.jp/entry/2014/12/23/000034
- http://monsho.blog63.fc2.com/blog-entry-137.html
- https://docs.unrealengine.com/latest/INT/Resources/ContentExamples/MaterialProperties/1_6/
- https://answers.unrealengine.com/questions/169883/separate-translucency-and-blendables.html
- https://answers.unrealengine.com/questions/149139/gaussian-dof-on-translucent-material.html
- https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/HowTo/Transparency/
メモ
- DeferredDecal : 平面投影, MaterialDomain=Deferred Decal
- DecalBLendMode
- Translucent - Can use Diffuse, Metallic, Specular, Roughness, Emissive, Opacity, and Normal.
- Stain - Is a modulate type blend with Diffuse and Opacity.
- Normal - Uses the Opacity and Normal channels and only affects the Normal map layer it is projecting on.
- Emissive - Uses Emissive and Opacity only.
- Volumetric Distance Function - Use the output of signed distance in Opacity depending on Light Vector.
- DBuffer
- 先に紹介した4種類のブレンド方法では、例えばカラーのみ、法線とラフネスのみといったブレンドは不可能です。
- これはGBufferに複数の情報がエンコードされて格納されているためで、通常のブレンド方法ではこの辺をうまく選択して対応することができません。
- 1.不透明オブジェクトのZ Pre-pass描画(深度バッファのみ描画)
- 2.DBufferへのデカール描画(深度バッファを利用指定座標を求める)
- 3.不透明オブジェクト描画(GBufferへの描画、DBufferの内容をブレンドする)
- 4.デカールのGBuffer描画
- 5.ライティング
- DBuffer を使わないと, ライトマップを使っている地形のライトマップが黒くなる
- DBuffer Translucent Color, Normal, Roughness - This is non-metallic and will use the Color, Opacity, Roughness, and Normal to work with baked lighting.
- DBuffer Translucent Color - This is non-metallic and will use only the Color and Opacity to work with baked lighting.
- DBuffer Translucent Color, Normal - This is non-metallic and will use the Color and Normal to work with baked lighting.
- DBuffer Translucent Color, Roughness - This is non-metallic and will use the Color and Roughness to work with baked lighting.
- DBuffer Translucent Normal - This will only use the Opacity and Normal channels to work with baked lighting.
- DBuffer Translucent Normal, Roughness - This will only use the Roughness, Opacity, and Normal to work with baked lighting.
- DBuffer Translucent Roughness - This will only use the Roughness and Opacity to work with baked lighting.
- Using Mesh Decals
- MeshDecals
メモ
- 半透明はデプスがないので SSR の対象外
- ライティングのライトグリッドで行われる
- DOFは通常、半透明マテリアルには影響を与えません。
- "Separate Translucency"が設定された半透明マテリアルにはDOFがかかりません。
- DOFを有効にするにはDetailsタブの[Translucency] -> [Enable Separate Translucency] をOFF, 但しデプスは奥のデプス
- By default, everything that is added to a level has a Translucency Sort Priority of 0.
- If you want something that is transparent to always draw over the top of everything else that is transparent, use positive numbers. 正の値で上に描画
- If you want something that is transparent to always draw behind everything else that is transparent, use negative numbers. 負の値で奥に描画
- Separate Translucencyを使わない場合
- 不透明,半透明(No Depth), DOF
- 半透明とDOFの描画の流れ(Separate Translucencyを使う場合)
- 不透明描画
- 別バッファに SeparateTraslucency
- DOF
- 合成
- 別の方法”ぼける距離にあるパーティクルのマテリアルは、(デプスを書き込む)Maskedに設定する。” LOD を使う
- Custom Depth / Stencilにチェックを入れたオブジェクトは、もう一度オブジェクトがGPUに投入されて計算されます。
Notes of UE4 .ini
- [SystemSettings] r.TranslucentLightingVolume=0 r.FinishCurrentFrame=0 r.CustomDepth=0 r.HZBOcclusion=0 r.LightShaftDownSampleFactor=4 r.OcclusionQueryLocation=1
[/Script/Engine.RendererSettings] r.DefaultFeature.AmbientOcclusion=False r.DefaultFeature.AmbientOcclusionStaticFraction=False r.EarlyZPass=1 r.EarlyZPassMovable=True r.BasePassOutputsVelocity=False
Notes of UE4 C++
- https://wiki.unrealengine.com/Blueprints,_Creating_C%2B%2B_Functions_as_new_Blueprint_Nodes
- http://unrealengine.hatenablog.com/entry/2014/09/10/202645
- https://docs.unrealengine.com/latest/INT/Programming/Development/CodingStandard/
- https://docs.unrealengine.com/latest/INT/Programming/UnrealBuildSystem/index.html
Notes of Capsule Shadow in UE4
コマンド
- r.CapsuleShadows : Default 1
- Whether to allow capsule shadowing on skinned components with bCastCapsuleDirectShadow or bCastCapsuleIndirectShadow enabled.
- カプセルシャドウを有効・無効にする
- r.CapsuleShadowsFullResolution : Default 0
- Whether to compute capsule shadows at full resolution.
- フル解像度でカプセルシャドウを計算するかどうか ?
- r.CapsuleMaxDirectOcclusionDistance : Default 400.0
- Maximum cast distance for direct shadows from capsules. This has a big impact on performance.
- カプセルの Direct Shadow の最大のキャストの距離, 処理に大きく影響する
- r.CapsuleMaxIndirectOcclusionDistance : Default 200.0
- Maximum cast distance for indirect shadows from capsules. This has a big impact on performance.
- カプセルの Indirect Shadow の最大のキャストの距離, 処理に大きく影響する
- r.CapsuleShadowFadeAngleFromVertical : Default 1.047198
- Angle from vertical up to start fading out the indirect shadow, to avoid self shadowing artifacts.
- Indirect Shadow のフェードを開始する真上の垂直方向の角度, セルフシャドウのアーティファクトの回避用
- r.CapsuleMinSkyAngle : Default 15.0
- Minimum light source angle derived from the precomputed unoccluded sky vector (stationary skylight present)
- Stationary のスカイライトがある状態で, 事前計算した空の Bent Normal からライトの角度(立体角?)を求める際の最小値
- r.CapsuleSkyAngleScale : Default 0.6
- Scales the light source angle derived from the precomputed unoccluded sky vector (stationary skylight present)
- Stationary のスカイライトがある状態で, 事前計算した空の Bent Normal から計算したライトの角度(立体角?)のスケール
- r.CapsuleIndirectConeAngle : Default 0.392699
- Light source angle used when the indirect shadow direction is derived from precomputed indirect lighting (no stationary skylight present)
- Stationary のスカイライトがない状態で, 事前計算の間接光を使って Indirect Shadow を求めるときのライトの光源の角度
その他
- スケルタルメッシュ側での設定
- デプスシャドウがじゃまなときには, ディレクショナルライトの Cascaded Shadow Maps の Num Dynamic Shadow Cascades を 0 にする
- カプセルシャドウに使う Physics Assets はスケルタルメッシュの「Lighting」に設定する
描画パスについて
- Direct Shadow と Indirect Shadow で描画パスの場所が違う
- Direct Shadow が有効のときにはディレクショナルライトのパスの中でカプセルシャドウの処理をする
- Lights -> ShadowedLights -> ShadowProjectionOnOpaque -> CapsuleShadows
- Indirect Shadow が有効のときには, IndirectCapsuleShadow という別のパスができる
負荷の簡易比較
ディレクショナルライトのデプスシャドウなし, カプセルシャドウなし
ディレクショナルライトのデプスシャドウなし, カプセルシャドウ(Direct Shadow 有効, Indirect Shadow 無効)
ディレクショナルライトのデプスシャドウあり, カプセルシャドウなし
Notes of UE4 Shader dev
Matt hoffmanさんの UE4 のシェーダのブログのメモ
Part1
- https://medium.com/@lordned/unreal-engine-4-rendering-overview-part-1-c47f2da65346
- HLSL tools for Visual Studio : Tools -> Text Editor -> File Extensions
- r.ShaderDevelopmentMode=1 : シェーダノビルドエラーのときに Editor の再起動が不要
- RenderDoc でデバッグする場合 : r.Shaders.Optimize=0 and r.Shaders.KeepDebugInfo=1
- シェーダの並列コンパイル : BaseEngine.ini の [DevOptions.Shaders]
の bAllowCompilingThroughWorker=True, and bAllowAsynchronousShaderCompiling=True
- シェーダのフルコンパイル: 125 の組み込みシェーダ, ~10000 の組み合わせ, 10 分ぐらい
Part2
- https://medium.com/@lordned/unreal-engine-4-rendering-part-2-shaders-and-vertex-data-80317e1ae5f3
- FShader : 親クラス, FShaderResource で GPU リソースを持つ
- FGlobalShader : 1 インスタンスのみ, インスタンスごとのパラメータを持てない, 特殊なコマンドを実行しないと Editor の再起動までリコンパイルしない
- FMaterialShader, FMeshMaterialShader(メッシュ描画前にパラメータを設定可能) : GPU resource をインスタンスごとに持てる
- FShader::ShouldCache() : マテリアル変更時にシェーダバリエーションを作るかどうか ?
- FShader::ModifyComplicationEnvironment() : プラットフォームによってプリプロセッサを書き換えたい場合
- UPrimitiveComponent : ゲームスレッド用の処理
- FPrimitiveSceneProxy : レンダースレッド用の処理
Part3, Part4
- https://medium.com/@lordned/unreal-engine-4-rendering-part-3-drawing-policies-89bb1a3c641b
- https://medium.com/@lordned/unreal-engine-4-rendering-part-4-the-deferred-shading-pipeline-389fc0175789
- Policy : どのシェーダバリエーションを使うか? デプスプレパスではデプスだけを書き込むシェーダ
- FVertexFactoryInput : シェーダごとに再定義
- WRITES_CUSTOMDATA_TO_GBUFFER : 自分のカスタムシェーディングモデルの追加のときに修正
- ScreenShadowMaskTexture : シャドウ結果をここに書く, バウンディングボックスを描画してデプスをサンプルしてシャドウかどうかを判定しているらしい
Part5
- 変更されたシェーダだけリコンパイル(グローバルシェーダも含む) : recompileshaders changed
- グローバルシェーダを全リコンパイル : recompileshaders global
- シェーダを全てリコンパイル : recompileshaders all
- 指定したパスのシェーダをコンパイル : recompileshaders /Engine/Private/BasePassPixelShaders.usf や recompileshaders /Engine/Private/DeferredLightingPixelShaders.usf とやる
- 最初に見つかるマテリアルをコンパイル : recompileshaders material マテリアル名
- ConsoleVariables.ini に r.ForceDebugViewModes=2 を追加すると, 可視化が使えないけどバリエーションが減る
- Quality や Static switches でシェーダバリエーションが増える
- シェーダによる最適化をスキップしたい場合 : ShaderCompiler.cpp でInput.Environment.CompilerFlags.Add(CFLAG_StandardOptimization);
UE4 レベル遷移
UE4 HLOD
UE4 の Movable/Stationary のデプスシャドウの違い
Movable
- デプスシャドウのパスでは、カスケードごとに影を落とす形状を書き込む
- デプスシャドウのマスクを作るためにLights->DirectLighting->ShadowedLights->ShadowProjectionOnOpaque でスクリーンスペースでデプスシャドウを参照して作り, それを参照してライトをマスクする
Stationary
- デプスシャドウのパスでは, Movable な Actor のメッシュをアトラス上に重ならないように書き込む
- デプスシャドウのマスクを作るために、バウンディングボックス形状を塗って 上のアトラス or LightMass で作成したシャドウマスクを参照して書き込みを行う
Notes of UE4 split screen
- https://docs.unrealengine.com/latest/INT/Engine/Rendering/ParticleSystems/Optimization/SplitScreen/
- https://docs.unrealengine.com/latest/INT/Engine/Rendering/ParticleSystems/Optimization/Results/index.html
- https://answers.unrealengine.com/questions/240300/how-do-i-create-a-split-screen-game.html
- https://answers.unrealengine.com/questions/498350/enabling-bloom-in-splitscreen.html
- https://forums.unrealengine.com/development-discussion/c-gameplay-programming/43641-post-processing-in-split-screen
- https://docs.unrealengine.com/latest/INT/Engine/Rendering/PostProcessEffects/Blendables/
*Notes of UE4 instances
- [終了] (動画チュートリアル関連) クラスとインスタンスの関係
- What is CDO?
- Get Default Object of Class
- Objects
- Custom node マテリアルエディタのCustomノードあれこれ
- Real Unreal Engine C++ 2017-12 (part-1/5)
Notes of UE4 Renderdoc debugging
- C:\Program Files\Epic Games\UE_4.18\Engine\Config\ConsoleVariables.ini
[Startup]
; Uncomment to get detailed logs on shader compiles and the opportunity to retry on errors
r.ShaderDevelopmentMode=1
; Uncomment to dump shaders in the Saved folder
; Warning: leaving this on for a while will fill your hard drive with many small files and folders
r.DumpShaderDebugInfo=1
; When this is enabled, dumped shader paths will get collapsed (in the cases where paths are longer than the OS's max)
r.DumpShaderDebugShortNames=1
; When this is enabled, when dumping shaders an additional file to use with ShaderCompilerWorker -direct mode will be generated
;r.DumpShaderDebugWorkerCommandLine=1
; Uncomment to enable parallel rendering at startup
;r.RHICmdBypass=0
; Uncomment to enable XGE shader compilation.
;r.XGEShaderCompile = 1
; Uncomment when running with a graphical debugger (but not when profiling)
r.Shaders.Optimize=0
r.Shaders.KeepDebugInfo=1
- UE4Editor.exe MY.uproject -d3ddebug