bool ShouldRenderRayTracingEffect(bool bEffectEnabled)
{
if (!IsRayTracingEnabled())
{
return false;
}
static auto CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RayTracing.ForceAllRayTracingEffects"));
const int32 OverrideMode = CVar != nullptr ? CVar->GetInt() : -1;
if (OverrideMode >= 0)
{
return OverrideMode > 0;
}
else
{
return bEffectEnabled;
}
}
bool ShouldRenderRayTracingShadows()
{
return ShouldRenderRayTracingEffect(CVarRayTracingOcclusion.GetValueOnRenderThread() > 0);
}
bool ShouldRenderRayTracingShadowsForLight(const FLightSceneProxy& LightProxy)
{
return ShouldRenderRayTracingShadows() && LightProxy.CastsRaytracedShadow()
&& ShouldRenderRayTracingShadowsForLightType((ELightComponentType)LightProxy.GetLightType());
}
bool ShouldRenderRayTracingShadowsForLight(const FLightSceneInfoCompact& LightInfo)
{
return ShouldRenderRayTracingShadows() && LightInfo.bCastRaytracedShadow
&& ShouldRenderRayTracingShadowsForLightType((ELightComponentType)LightInfo.LightType);
}
阴影cmd:
static TAutoConsoleVariable<int32> CVarRayTracingOcclusion(
TEXT("r.RayTracing.Shadows"),
1,
TEXT("0: use traditional rasterized shadow map\n")
TEXT("1: use ray tracing shadows (default)"),
ECVF_RenderThreadSafe);
static int32 GShadowRayTracingSamplesPerPixel = 1;
static FAutoConsoleVariableRef CVarShadowRayTracingSamplesPerPixel(
TEXT("r.RayTracing.Shadow.SamplesPerPixel"),
GShadowRayTracingSamplesPerPixel,
TEXT("Sets the samples-per-pixel for directional light occlusion (default = 1)"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarShadowUseDenoiser(
TEXT("r.Shadow.Denoiser"), //DenoiserMode
2,
TEXT("Choose the denoising algorithm.\n")
TEXT(" 0: Disabled (default);\n")
TEXT(" 1: Forces the default denoiser of the renderer;\n")
TEXT(" 2: GScreenSpaceDenoiser witch may be overriden by a third party plugin.\n"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarMaxShadowDenoisingBatchSize(
TEXT("r.Shadow.Denoiser.MaxBatchSize"), 4,
TEXT("Maximum number of shadow to denoise at the same time."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarMaxShadowRayTracingBatchSize(
TEXT("r.RayTracing.Shadow.MaxBatchSize"), 8,
TEXT("Maximum number of shadows to trace at the same time."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarAllowClearLightSceneExtentsOnly(
TEXT("r.AllowClearLightSceneExtentsOnly"), 1,
TEXT(""),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarRayTracingShadowsDirectionalLight(
TEXT("r.RayTracing.Shadows.Lights.Directional"),
1,
TEXT("Enables ray tracing shadows for directional lights (default = 1)"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarRayTracingShadowsPointLight(
TEXT("r.RayTracing.Shadows.Lights.Point"),
1,
TEXT("Enables ray tracing shadows for point lights (default = 1)"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarRayTracingShadowsSpotLight(
TEXT("r.RayTracing.Shadows.Lights.Spot"),
1,
TEXT("Enables ray tracing shadows for spot lights (default = 1)"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarRayTracingShadowsRectLight(
TEXT("r.RayTracing.Shadows.Lights.Rect"),
1,
TEXT("Enables ray tracing shadows for rect light (default = 1)"),
ECVF_RenderThreadSafe);
static bool LightRequiresDenosier(const FLightSceneInfo& LightSceneInfo)
{
ELightComponentType LightType = ELightComponentType(LightSceneInfo.Proxy->GetLightType());
if (LightType == LightType_Directional)
{
return LightSceneInfo.Proxy->GetLightSourceAngle() > 0;
}
else if (LightType == LightType_Point || LightType == LightType_Spot)
{
return LightSceneInfo.Proxy->GetSourceRadius() > 0;
}
else if (LightType == LightType_Rect)
{
return true;
}
else
{
check(0);
}
return false;
}