- 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 - 影
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
- GBuffer.DiffuseColor
- GBuffer.SpecularColor
- LightColor
SurfaceShading
↓
LightAccumulator_Add
SurfaceLighting †
| float3 SurfaceLighting = SurfaceShading(GBuffer, LobeRoughness, LobeEnergy, L, V, N, Random);
|
- 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) );
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 );
return Diffuse * LobeEnergy[2] + (D * Vis) * F;
}
|
- Diffuse * LobeEnergy[2] = x
* =
- (D * Vis) * F = y
( * ) * =
- x + y = return
+ =
- Diffuse * LobeEnergy[2] = x
* =
- (D * Vis) * F = y
( * ) * =
- x + y = return
+ =
- マテリアルのBaseColorを調整してみるとSurface Lightingにスペキュラが入っているのが確認できる
ライトカラーとの合成 †
| LightAccumulator_Add(LightAccumulator, SurfaceLighting, (1.0/PI), LightColor * (NoL * SurfaceAttenuation), bNeedsSeparateSubsurfaceLightAccumulation);
|
- (NoL * SurfaceAttenuation) =
* =
- LightColor * (NoL * SurfaceAttenuation) = x
* =
- SurfaceLighting * x =
* =
- SurfaceLighting * x =
* =
|