• GBufferへの書き込み
    MainPS (PixelShaderOutputCommon.usf)
     FPixelShaderInOut_MainPS (BasePassPixelShader.usf)
    • Indirect Light、Sky Lightの計算
      GetPrecomputedIndirectLightingAndSkyLight (BasePassPixelShader.usf)
      • Sky Lightの計算
        GetSkyLighting (BasePassPixelShader.usf)
  • Gバッファからシェーディング
    DirectionalPixelMain (DeferredLightPixelShaders.usf)
    • 動的ライトの計算
      GetDynamicLighting (DeferredLightingCommon.usf)
  • 動的影付け
    Main (ShadowProjectionPixelShader.usf)
    Shadow変数が影の強さ。0.0 - 影
    →FadedShadow変数フェード付き
    →OutColor変数に最終出力。
    OutColor.r値のみ参照されているっぽい。
    MODULATED_SHADOWSがmobile時のみ使える?
    Engine\Source\Runtime\Renderer\Private\ShadowRendering.cpp

描画元
FDeferredShadingSceneRenderer::RenderLights (Engine\Source\Runtime\Renderer\Private\LightRendering.cpp)
 FDeferredShadingSceneRenderer::RenderShadowProjections (Engine\Source\Runtime\Renderer\Private\ShadowRendering.cpp)
  FSceneRenderer::RenderShadowProjections (Engine\Source\Runtime\Renderer\Private\ShadowRendering.cpp)

  • モバイル用
    FMobileSceneRenderer::Render (Engine\Source\Runtime\Renderer\Private\MobileShadingRenderer.cpp)
     FMobileSceneRenderer::RenderModulatedShadowProjections (Engine\Source\Runtime\Renderer\Private\ShadowRendering.cpp)
      FSceneRenderer::RenderShadowProjections (Engine\Source\Runtime\Renderer\Private\ShadowRendering.cpp)

GetPrecomputedIndirectLightingAndSkyLight

GBufferのMRT[0]に書き出される

GetDynamicLighting

記述が無い場合は下記設定でスクリーンショット

  • マテリアル
    • BaseColor : 1.0, 1.0, 1.0
    • Metalic : 0.0
    • Roughtness 1.0
    • Specular : 0.5
  • ライト
    • ディフューズライト1灯のみ
    • Intencity : 6.0
    • Color : 0.0, 1.0, 0.0

基本パラメーター

  • Default Lit
    Rendering-DefaultLit.png
  • GBuffer.DiffuseColor
    Rendering-GBuffer.DeffuseColor.png
  • GBuffer.SpecularColor
    Rendering-GBuffer.SpecularColor.png
  • LightColor
    Rendering-LightColor.png

ライティングフロー

SurfaceShading
 ↓
LightAccumulator_Add

SurfaceLighting

 
float3 SurfaceLighting = SurfaceShading(GBuffer, LobeRoughness, LobeEnergy, L, V, N, Random);

Rendering-SurfaceLighting.png

  • SurfaceShadingの中身
     
    -
    |
    |
    |
    |
    |
    |
    |
    |
    |
    |
    |
    |
    |
    |
    |
    |
    !
    
    float3 StandardShading( float3 DiffuseColor, float3 SpecularColor, float3 LobeRoughness, float3 LobeEnergy, float3 L, float3 V, half3 N )
    {
        float3 H = normalize(V + L);
        float NoL = saturate( dot(N, L) );
        float NoV = saturate( abs( dot(N, V) ) + 1e-5 );
        float NoH = saturate( dot(N, H) );
        float VoH = saturate( dot(V, H) );
        
        // Generalized microfacet specular
        float D = D_GGX( LobeRoughness[1], NoH ) * LobeEnergy[1];
        float Vis = Vis_SmithJointApprox( LobeRoughness[1], NoV, NoL );
        float3 F = F_Schlick( SpecularColor, VoH );
     
        float3 Diffuse = Diffuse_Lambert( DiffuseColor );
        //float3 Diffuse = Diffuse_Burley( DiffuseColor, LobeRoughness[1], NoV, NoL, VoH );
        //float3 Diffuse = Diffuse_OrenNayar( DiffuseColor, LobeRoughness[1], NoV, NoL, VoH );
     
        return Diffuse * LobeEnergy[2] + (D * Vis) * F;
    }
    1. Diffuse * LobeEnergy[2] = x
      Rendering-SurfaceLighting-Diffuse.png * Rendering-SurfaceLighting-LobeEnegy[2].png = Rendering-SurfaceLighting-Diffuse-x-LobeEnegy[2].png
    2. (D * Vis) * F = y
      (Rendering-SurfaceLighting-D(Roughness_1.0).png * Rendering-SurfaceLighting-Vis(Roughness_1.0).png ) * Rendering-SurfaceLighting-F.png = Rendering-SurfaceLighting-(D-x-Vis)-x-F.png
    3. x + y = return
      Rendering-SurfaceLighting-Diffuse-x-LobeEnegy[2].png + Rendering-SurfaceLighting-(D-x-Vis)-x-F.png = Rendering-SurfaceLighting.png

  • Roughness = 0.0の時
  1. Diffuse * LobeEnergy[2] = x
    Rendering-SurfaceLighting-Diffuse.png * Rendering-SurfaceLighting-LobeEnegy[2](Roughness_0.0).png = Rendering-SurfaceLighting-Diffuse-x-LobeEnegy[2](Roughness_0.0).png
  2. (D * Vis) * F = y
    (Rendering-SurfaceLighting-D(Roughness_0.0).png * Rendering-SurfaceLighting-Vis(Roughness_0.0).png ) * Rendering-SurfaceLighting-F.png = Rendering-SurfaceLighting-(D-x-Vis)-x-F(Roughtness_0.0).png
  3. x + y = return
    Rendering-SurfaceLighting-Diffuse-x-LobeEnegy[2](Roughness_0.0).png + Rendering-SurfaceLighting-(D-x-Vis)-x-F(Roughtness_0.0).png = Rendering-SurfaceLighting(Roughness_0.0).png
  • マテリアルのBaseColorを調整してみるとSurface Lightingにスペキュラが入っているのが確認できる
    Rendering-SurfaceLighting-Roughness_0.0_Adjust.png

ライトカラーとの合成

 
LightAccumulator_Add(LightAccumulator, SurfaceLighting, (1.0/PI), LightColor * (NoL * SurfaceAttenuation), bNeedsSeparateSubsurfaceLightAccumulation);
  • (NoL * SurfaceAttenuation) =
    Rendering-NoL.png * Rendering-SurfaceAttenuation.png = Rendering-NoL-x-SurfaceAttenuation.png
  • LightColor * (NoL * SurfaceAttenuation) = x
    Rendering-LightColor.png * Rendering-NoL-x-SurfaceAttenuation.png = Rendering-LightColor-x-(NoL-x-SurfaceAttenuation).png
  • SurfaceLighting * x =
    Rendering-SurfaceLighting.png * Rendering-LightColor-x-(NoL-x-SurfaceAttenuation).png = Rendering-GetDynamicLighting.png

  • Roughness = 0.0の時
  1. SurfaceLighting * x =
    Rendering-SurfaceLighting(Roughness_0.0).png * Rendering-LightColor-x-(NoL-x-SurfaceAttenuation).png = Rendering-GetDynamicLighting(Roughness_0.0).png

    ホーム 一覧 単語検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS