View.SkyLightColor does not work in my custom shading model

I made a custom shading model along this link. However, the shadows of all objects using Toon shading are displayed in black.


Turning off the shadows shows the shading I want, but only the shadows seem to show in black.

//DeferredLightingCommon.ush
//
FLightAccumulator AccumulateDynamicToonLighting(
float3 TranslatedWorldPosition, half3 CameraVector, FGBufferData GBuffer, half AmbientOcclusion, uint ShadingModelID,
FDeferredLightData LightData, half4 LightAttenuation, float Dither, uint2 SVPos,
inout float SurfaceShadow)
{
FLightAccumulator LightAccumulator = (FLightAccumulator) 0;
//
half3 V = -CameraVector;
half3 N = GBuffer.WorldNormal;
//
float3 L = LightData.Direction; // Already normalized
float3 ToLight = L;
float3 MaskedLightColor = LightData.Color;
float LightMask = 1;
if (LightData.bRadialLight)
{
LightMask = GetLocalLightAttenuation(TranslatedWorldPosition, LightData, ToLight, L);
MaskedLightColor *= LightMask;
}
//
LightAccumulator.EstimatedCost += 0.3f; // running the PixelShader at all has a cost
//
BRANCH
if (LightMask <= 0)
{
return LightAccumulator;
}
//
FShadowTerms Shadow;
Shadow.SurfaceShadow = AmbientOcclusion;
Shadow.TransmissionShadow = 1;
Shadow.TransmissionThickness = 1;
Shadow.HairTransmittance.OpaqueVisibility = 1;
const float ContactShadowOpacity = GBuffer.CustomData.a;
GetShadowTerms(GBuffer.Depth, GBuffer.PrecomputedShadowFactors, GBuffer.ShadingModelID, ContactShadowOpacity, LightData, TranslatedWorldPosition, L, LightAttenuation, Dither, Shadow);
SurfaceShadow = Shadow.SurfaceShadow;
//
LightAccumulator.EstimatedCost += 0.3f; // add the cost of getting the shadow terms
//
FDirectLighting Lighting;
//
if (LightData.bRectLight)
{
FRect Rect = GetRect(ToLight, LightData);
const FRectTexture SourceTexture = ConvertToRectTexture(LightData);
Lighting = IntegrateBxDF(GBuffer, N, V, Rect, Shadow, SourceTexture); // not support ‘REFERENCE_QUALITY’
}
else
{
FCapsuleLight Capsule = GetCapsule(ToLight, LightData);
Lighting = IntegrateBxDF(GBuffer, N, V, Capsule, Shadow, LightData.bInverseSquared); // not support ‘REFERENCE_QUALITY’
}
//
Lighting.Specular *= LightData.SpecularScale;
//
// else: 追加ライトの場合は正規化なし&スカイライトカラーを加算しない
BRANCH if (LightData.bSpotLight == false && LightData.bRectLight == false)
{
const float SqrtThree = 1.73205080756888; // length((float3)1.0)) > sqrt(3.0)
//
// Affect LightColor
float MainLightAttenuation = saturate(SqrtThree / length(MaskedLightColor));
MaskedLightColor *= MainLightAttenuation;
//
// Affect SkyLightColor
float SkyLightAttenuation = saturate(SqrtThree / length(View.SkyLightColor.rgb));
MaskedLightColor += View.SkyLightColor.rgb * SkyLightAttenuation;
//
// Clamp to approx 0.0 … 1.0
MaskedLightColor *= saturate(SqrtThree / length(MaskedLightColor));
}
//
LightAccumulator_AddSplit(LightAccumulator, Lighting.Diffuse, Lighting.Specular, 0.0, MaskedLightColor, false);
//
LightAccumulator.EstimatedCost += 0.4f; // add the cost of the lighting computations (should sum up to 1 form one light)
//
return LightAccumulator;}

In this code, I did this to use Skylight

BRANCH if (LightData.bSpotLight == false && LightData.bRectLight == false)
{
const float SqrtThree = 1.73205080756888; // length((float3)1.0)) > sqrt(3.0)
//
// Affect LightColor
float MainLightAttenuation = saturate(SqrtThree / length(MaskedLightColor));
MaskedLightColor *= MainLightAttenuation;
//
// Affect SkyLightColor
float SkyLightAttenuation = saturate(SqrtThree / length(View.SkyLightColor.rgb));
MaskedLightColor += View.SkyLightColor.rgb * SkyLightAttenuation;
//
// Clamp to approx 0.0 … 1.0
MaskedLightColor *= saturate(SqrtThree / length(MaskedLightColor));
}
//
LightAccumulator_AddSplit(LightAccumulator, Lighting.Diffuse, Lighting.Specular, 0.0, MaskedLightColor, false);
//
LightAccumulator.EstimatedCost += 0.4f; // add the cost of the lighting computations (should sum up to 1 form one light)
//
return LightAccumulator;

In my opinion, from version 5.4 “View.SkyLightColor.rgb” doesn’t seem to work.
If not, is there any other reason why shadows come out black?

This topic has been moved from International to Rendering.

When posting, please review the categories to ensure your topic is posted in the most relevant space.