Gregory Igehy

Dancing at hemisphere coordinate

Notes of precomputed lighting scenerios and level streaming

Notes of Separate Traslucency

メモ

  • 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 を使う

f:id:gregory-igehy:20180303133952j:plain

  • Custom Depth / Stencilにチェックを入れたオブジェクトは、もう一度オブジェクトがGPUに投入されて計算されます。

f:id:gregory-igehy:20180303135319j:plain

Notes of UE4 .ini

-
https://www.gamasutra.com/blogs/LeszekGodlewski/20160721/272886/The_Vanishing_of_Milliseconds_Optimizing_the_UE4_renderer_for_Ethan_Carter_VR.php

  • [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 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 を求めるときのライトの光源の角度

その他

  • スケルタルメッシュ側での設定

f:id:gregory-igehy:20180104022351j:plain

  • デプスシャドウがじゃまなときには, ディレクショナルライトの Cascaded Shadow Maps の Num Dynamic Shadow Cascades を 0 にする

f:id:gregory-igehy:20180104013258j:plain

  • カプセルシャドウに使う Physics Assets はスケルタルメッシュの「Lighting」に設定する

f:id:gregory-igehy:20180104013352j:plain

描画パスについて

  • Direct Shadow と Indirect Shadow で描画パスの場所が違う
  • Direct Shadow が有効のときにはディレクショナルライトのパスの中でカプセルシャドウの処理をする
    • Lights -> ShadowedLights -> ShadowProjectionOnOpaque -> CapsuleShadows

f:id:gregory-igehy:20180104014120j:plain

  • Indirect Shadow が有効のときには, IndirectCapsuleShadow という別のパスができる

f:id:gregory-igehy:20180104014542j:plain

負荷の簡易比較

ディレクショナルライトのデプスシャドウなし, カプセルシャドウなし

f:id:gregory-igehy:20180104024308j:plain

ディレクショナルライトのデプスシャドウなし, カプセルシャドウ(Direct Shadow 有効, Indirect Shadow 無効)

f:id:gregory-igehy:20180104024345j:plain

ディレクショナルライトのデプスシャドウあり, カプセルシャドウなし

f:id:gregory-igehy:20180104024409j:plain

2 体の場合

  • コンピュートシェーダなので, GPU 処理は増えるがドローコールが増えるわけではない
  • 下は順に Indirect shadow と Direct shadow の場合

f:id:gregory-igehy:20180104040331j:plain
f:id:gregory-igehy:20180104040319j:plain

Notes of UE4 Shader dev

  • マテリアルのシェーダコードを書き換えて, 適用をすればすぐに反映される
  • r.ShaderDevelopmentMode 0: Default, 1: Enable various shader development utilities, such as the ability to retry on failed shader compile, and extra logging as shaders are compiled. 有効にした方が、ログが出たりコンパイル失敗時に試しやすい
  • CTRL + SHIFT + ピリオド でフルコンパイル

Matt hoffmanさんの UE4 のシェーダのブログのメモ

Part1

f:id:gregory-igehy:20180108184246j:plain

  • 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

Part3, Part4

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 の Movable/Stationary のデプスシャドウの違い

Movable

  • デプスシャドウのパスでは、カスケードごとに影を落とす形状を書き込む

f:id:gregory-igehy:20180114220057j:plain

  • デプスシャドウのマスクを作るためにLights->DirectLighting->ShadowedLights->ShadowProjectionOnOpaque でスクリーンスペースでデプスシャドウを参照して作り, それを参照してライトをマスクする

f:id:gregory-igehy:20180114220336j:plain

Stationary

  • デプスシャドウのパスでは, Movable な Actor のメッシュをアトラス上に重ならないように書き込む

f:id:gregory-igehy:20180114220522j:plain

  • デプスシャドウのマスクを作るために、バウンディングボックス形状を塗って 上のアトラス or LightMass で作成したシャドウマスクを参照して書き込みを行う

f:id:gregory-igehy:20180114220628j:plain

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