Init
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
---
|
||||
title: Lighting阶段的ShadowMap逻辑
|
||||
date: 2023-04-10 14:45:45
|
||||
excerpt:
|
||||
tags:
|
||||
rating: ⭐
|
||||
---
|
||||
|
||||
## PS Parameter
|
||||
`FDeferredLightPS::FParameters GetDeferredLightPSParameters()`
|
||||
|
||||
- LightAttenuationTexture = ShadowMaskTexture ? ShadowMaskTexture : WhiteDummy;
|
||||
- One pass projection
|
||||
- VirtualShadowMap = VirtualShadowMapUniformBuffer;
|
||||
- VirtualShadowMapId = VirtualShadowMapId;
|
||||
- ShadowMaskBits = ShadowMaskBits ? ShadowMaskBits : GSystemTextures.GetZeroUIntDummy(GraphBuilder);
|
||||
|
||||
最后输出
|
||||
- SceneColorTexture
|
||||
- SceneDepthTexture
|
||||
|
||||
## Lighting阶段中VSM 渲染函数
|
||||
RenderDeferredShadowProjections(),输出`ScreenShadowMaskTexture`。
|
||||
|
||||
## 问题所在
|
||||
LightAttenuation
|
||||
- x:整个场景的方向光阴影。
|
||||
- y:整个场景的方向光SSS阴影。
|
||||
- z:Light function + per-object shadows
|
||||
- w:per-object SSS shadowing in w
|
||||
|
||||
zw用于非方向光或者移动端渲染路径。
|
||||
```c++
|
||||
if (LightData.bRadialLight || SHADING_PATH_MOBILE)
|
||||
{
|
||||
// Remapping the light attenuation buffer (see ShadowRendering.cpp)
|
||||
|
||||
Shadow.SurfaceShadow = LightAttenuation.z * StaticShadowing;
|
||||
// SSS uses a separate shadowing term that allows light to penetrate the surface
|
||||
//@todo - how to do static shadowing of SSS correctly? Shadow.TransmissionShadow = LightAttenuation.w * StaticShadowing;
|
||||
|
||||
Shadow.TransmissionThickness = LightAttenuation.w;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remapping the light attenuation buffer (see ShadowRendering.cpp)
|
||||
// Also fix up the fade between dynamic and static shadows // to work with plane splits rather than spheres.
|
||||
float DynamicShadowFraction = DistanceFromCameraFade(SceneDepth, LightData);
|
||||
// For a directional light, fade between static shadowing and the whole scene dynamic shadowing based on distance + per object shadows
|
||||
Shadow.SurfaceShadow = lerp(LightAttenuation.x, StaticShadowing, DynamicShadowFraction);
|
||||
// Fade between SSS dynamic shadowing and static shadowing based on distance
|
||||
Shadow.TransmissionShadow = min(lerp(LightAttenuation.y, StaticShadowing, DynamicShadowFraction), LightAttenuation.w);
|
||||
|
||||
Shadow.SurfaceShadow *= LightAttenuation.z;
|
||||
Shadow.TransmissionShadow *= LightAttenuation.z;
|
||||
|
||||
// Need this min or backscattering will leak when in shadow which cast by non perobject shadow(Only for directional light)
|
||||
Shadow.TransmissionThickness = min(LightAttenuation.y, LightAttenuation.w);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
**DeferredLightingCommon.ush**与**DeferredLightPixelShaders.usf**中的**LightAttenuation**即为ShadowMap数据。具体可以参考**GetLightAttenuationFromShadow()**,可以看得出EPIC之后打算通过抖动来消除VSM的阴影锯齿。
|
||||
|
||||
主要的阴影效果由**LightAttenuation**与ShadingModels.ush中的NoL提供。我们只需要调整自阴影也就是z通道,其他的整个场景的阴影。
|
@@ -0,0 +1,44 @@
|
||||
---
|
||||
title: RenderLights
|
||||
date: 2023-04-09 10:23:21
|
||||
excerpt:
|
||||
tags:
|
||||
rating: ⭐
|
||||
---
|
||||
# 关键函数
|
||||
取得所有ShadowMap的投影信息
|
||||
```c++
|
||||
const FVisibleLightInfo& VisibleLightInfo = VisibleLightInfos[LightSceneInfo->Id];
|
||||
const TArray<FProjectedShadowInfo*, SceneRenderingAllocator>& ShadowMaps = VisibleLightInfo.ShadowsToProject;
|
||||
for (int32 ShadowIndex = 0; ShadowIndex < ShadowMaps.Num(); ShadowIndex++)
|
||||
{
|
||||
const FProjectedShadowInfo* ProjectedShadowInfo = ShadowMaps[ShadowIndex];
|
||||
}
|
||||
```
|
||||
|
||||
# 透明体积图元渲染
|
||||
## InjectSimpleTranslucencyLightingVolumeArray
|
||||
插入简单透明体积物体渲染。应该是根据3D贴图渲染体积效果。默认状态下不运行。
|
||||
- InjectSimpleLightsTranslucentLighting
|
||||
- InjectSimpleTranslucentLightArray
|
||||
|
||||
## InjectTranslucencyLightingVolume
|
||||
在收集用于渲染透明体积的灯光代理信息后进行渲染,主要用于云的渲染。
|
||||
- InjectTranslucencyLightingVolume
|
||||
|
||||
# 直接光照
|
||||
## RenderVirtualShadowMapProjectionMaskBits
|
||||
- VirtualShadowMapProjectionMaskBits
|
||||
- VirtualShadowMapProjection(RayCount:%u(%s),SamplesPerRay:%u,Input:%s%s)
|
||||
|
||||
输出到名为`Shadow.Virtual.MaskBits`与`Shadow.Virtual.MaskBits(HairStrands)`的UAV。
|
||||
|
||||
## AddClusteredDeferredShadingPass
|
||||
|
||||
## RenderSimpleLightsStandardDeferred
|
||||
|
||||
## RenderLight
|
||||
针对每个灯在ShadowProjectionOnOpaque渲染ShadowMask
|
||||
- VirualShadowMapProjection
|
||||
- CompositeVirtualShadowMapMask
|
||||
|
Reference in New Issue
Block a user