vault backup: 2025-03-25 00:13:21

This commit is contained in:
BlueRose 2025-03-25 00:13:22 +08:00
parent 5d45822c38
commit 4485f5a3de
2 changed files with 72 additions and 8 deletions

View File

@ -1 +1 @@
{"Deprecated":{"Deprecated":{"internalLink":{"count":1,"lastUpdated":1740405714148}}},"PS.需要Shader添加FSceneTextureShaderParameters":{"PS.需要Shader添加FSceneTextureShaderParameters":{"currentFile":{"count":1,"lastUpdated":1740983366427}}},"和blender共同制作山脉为":{"和blender共同制作山脉为":{"currentFile":{"count":1,"lastUpdated":1741610747166}}},"BlueprintCosmetic":{"BlueprintCosmetic":{"internalLink":{"count":1,"lastUpdated":1741951657866}}},"ReflectionsColor":{"ReflectionsColor":{"currentFile":{"count":1,"lastUpdated":1742739458164}}}} {"Deprecated":{"Deprecated":{"internalLink":{"count":1,"lastUpdated":1740405714148}}},"PS.需要Shader添加FSceneTextureShaderParameters":{"PS.需要Shader添加FSceneTextureShaderParameters":{"currentFile":{"count":1,"lastUpdated":1740983366427}}},"和blender共同制作山脉为":{"和blender共同制作山脉为":{"currentFile":{"count":1,"lastUpdated":1741610747166}}},"BlueprintCosmetic":{"BlueprintCosmetic":{"internalLink":{"count":1,"lastUpdated":1741951657866}}},"ReflectionsColor":{"ReflectionsColor":{"currentFile":{"count":1,"lastUpdated":1742739458164}}},"主要执行了:":{"主要执行了:":{"currentFile":{"count":1,"lastUpdated":1742830096172}}}}

View File

@ -12,6 +12,7 @@ rating: ⭐
- LumenReflections - LumenReflections
- [[#DiffuseIndirectComposite]] - [[#DiffuseIndirectComposite]]
PS. DiffuseIndirectAndAO Pass会根据 ViewPipelineState.DiffuseIndirectMethod是否为Lumen出现在Light Pass之前GI方法为Lumen或者之后GI方法为非Lumen
## ReflectionEnvironmentAndSky ## ReflectionEnvironmentAndSky
位于IndirectLightRendering.cpp的RenderDeferredReflectionsAndSkyLighting() => `AddSkyReflectionPass()` 位于IndirectLightRendering.cpp的RenderDeferredReflectionsAndSkyLighting() => `AddSkyReflectionPass()`
@ -289,6 +290,7 @@ float3 ReflectionEnvironment(FGBufferData GBuffer, float AmbientOcclusion, float
``` ```
### GatherRadiance() ### GatherRadiance()
GatherRadiance()主要计算了SkyLightTexture天空盒贴图以及ReflectionCaptureBox、Sphere反射球最终根据之前计算的Color.a进行合成。
```c++ ```c++
float3 GatherRadiance(float CompositeAlpha, float3 TranslatedWorldPosition, float3 RayDirection, float Roughness, float3 BentNormal, float IndirectIrradiance, uint ShadingModelID, uint NumCulledReflectionCaptures, uint CaptureDataStartIndex) float3 GatherRadiance(float CompositeAlpha, float3 TranslatedWorldPosition, float3 RayDirection, float Roughness, float3 BentNormal, float IndirectIrradiance, uint ShadingModelID, uint NumCulledReflectionCaptures, uint CaptureDataStartIndex)
{ {
@ -319,7 +321,7 @@ float3 GatherRadiance(float CompositeAlpha, float3 TranslatedWorldPosition, floa
} }
``` ```
主要逻辑位于CompositeReflectionCapturesAndSkylightTWS():
```c++ ```c++
float3 CompositeReflectionCapturesAndSkylightTWS( float3 CompositeReflectionCapturesAndSkylightTWS(
float CompositeAlpha, float CompositeAlpha,
@ -341,20 +343,22 @@ float3 CompositeReflectionCapturesAndSkylightTWS(
#if REFLECTION_COMPOSITE_USE_BLENDED_REFLECTION_CAPTURES #if REFLECTION_COMPOSITE_USE_BLENDED_REFLECTION_CAPTURES
// Accumulate reflections from captures affecting this tile, applying largest captures first so that the smallest ones display on top // Accumulate reflections from captures affecting this tile, applying largest captures first so that the smallest ones display on top
//ReflectionCapture Blend其顺序为大范围在前
LOOP LOOP
for (uint TileCaptureIndex = 0; TileCaptureIndex < NumCapturesAffectingTile; TileCaptureIndex++) for (uint TileCaptureIndex = 0; TileCaptureIndex < NumCapturesAffectingTile; TileCaptureIndex++)
{ {
BRANCH BRANCH
if (ImageBasedReflections.a < 0.001) if (ImageBasedReflections.a < 0.001)//如果Alpha小于0.001则停止循环结束合成计算
{ {
break; break;
} }
//计算CaptureIndex
uint CaptureIndex = 0; uint CaptureIndex = 0;
#ifdef REFLECTION_COMPOSITE_NO_CULLING_DATA #ifdef REFLECTION_COMPOSITE_NO_CULLING_DATA
CaptureIndex = TileCaptureIndex; // Go from 0 to NumCapturesAffectingTile as absolute index in capture array CaptureIndex = TileCaptureIndex; // Go from 0 to NumCapturesAffectingTile as absolute index in capture array
#else #else
#if (INSTANCED_STEREO || MOBILE_MULTI_VIEW) #if (INSTANCED_STEREO || MOBILE_MULTI_VIEW)//VR或者移动端多View
BRANCH BRANCH
if (EyeIndex == 0) if (EyeIndex == 0)
{ {
@ -382,7 +386,7 @@ float3 CompositeReflectionCapturesAndSkylightTWS(
float NormalizedDistanceToCapture = saturate(CaptureVectorLength / CaptureRadius); float NormalizedDistanceToCapture = saturate(CaptureVectorLength / CaptureRadius);
BRANCH BRANCH
if (CaptureVectorLength < CaptureRadius) if (CaptureVectorLength < CaptureRadius)//当前像素处于ReflectionCapture范围内
{ {
float3 ProjectedCaptureVector = RayDirection; float3 ProjectedCaptureVector = RayDirection;
float4 CaptureOffsetAndAverageBrightness = GetReflectionCaptureOffsetAndAverageBrightness(CaptureIndex); float4 CaptureOffsetAndAverageBrightness = GetReflectionCaptureOffsetAndAverageBrightness(CaptureIndex);
@ -392,6 +396,7 @@ float3 CompositeReflectionCapturesAndSkylightTWS(
#define PROJECT_ONTO_SHAPE 1 #define PROJECT_ONTO_SHAPE 1
#if PROJECT_ONTO_SHAPE #if PROJECT_ONTO_SHAPE
//盒形反射球
#if REFLECTION_COMPOSITE_HAS_BOX_CAPTURES #if REFLECTION_COMPOSITE_HAS_BOX_CAPTURES
#if REFLECTION_COMPOSITE_HAS_SPHERE_CAPTURES #if REFLECTION_COMPOSITE_HAS_SPHERE_CAPTURES
// Box // Box
@ -403,6 +408,7 @@ float3 CompositeReflectionCapturesAndSkylightTWS(
} }
#endif #endif
//球形反射球
#if REFLECTION_COMPOSITE_HAS_SPHERE_CAPTURES #if REFLECTION_COMPOSITE_HAS_SPHERE_CAPTURES
// Sphere // Sphere
#if REFLECTION_COMPOSITE_HAS_BOX_CAPTURES #if REFLECTION_COMPOSITE_HAS_BOX_CAPTURES
@ -419,6 +425,7 @@ float3 CompositeReflectionCapturesAndSkylightTWS(
float CaptureArrayIndex = CaptureProperties.g; float CaptureArrayIndex = CaptureProperties.g;
{ {
//采样对应的ReflectionCubeMapSample.a为根据距离计算的Alpha。最后结果累加到ImageBasedReflections中。
float4 Sample = ReflectionStruct.ReflectionCubemap.SampleLevel(ReflectionStruct.ReflectionCubemapSampler, float4(ProjectedCaptureVector, CaptureArrayIndex), Mip); float4 Sample = ReflectionStruct.ReflectionCubemap.SampleLevel(ReflectionStruct.ReflectionCubemapSampler, float4(ProjectedCaptureVector, CaptureArrayIndex), Mip);
Sample.rgb *= CaptureProperties.r; Sample.rgb *= CaptureProperties.r;
@ -436,7 +443,7 @@ float3 CompositeReflectionCapturesAndSkylightTWS(
} }
#else #else
//非ReflectionCapture Blend
float3 ProjectedCaptureVector = RayDirection; float3 ProjectedCaptureVector = RayDirection;
FLWCVector3 SingleCaptureWorldPosition = MakeLWCVector3(GetReflectionTilePosition(SingleCaptureIndex).xyz, GetReflectionPositionAndRadius(SingleCaptureIndex).xyz); FLWCVector3 SingleCaptureWorldPosition = MakeLWCVector3(GetReflectionTilePosition(SingleCaptureIndex).xyz, GetReflectionPositionAndRadius(SingleCaptureIndex).xyz);
@ -483,6 +490,7 @@ float3 CompositeReflectionCapturesAndSkylightTWS(
{ {
float SkyAverageBrightness = 1.0f; float SkyAverageBrightness = 1.0f;
// 不支持Blend的结果大致为SkyLightCubeMap * View.SkyLightColor。支持Blend的lerp(Reflection, BlendDestinationReflection * View.SkyLightColor.rgb, ReflectionStruct.SkyLightParameters.w);
#if REFLECTION_COMPOSITE_SUPPORT_SKYLIGHT_BLEND #if REFLECTION_COMPOSITE_SUPPORT_SKYLIGHT_BLEND
float3 SkyLighting = GetSkyLightReflectionSupportingBlend(RayDirection, Roughness, SkyAverageBrightness); float3 SkyLighting = GetSkyLightReflectionSupportingBlend(RayDirection, Roughness, SkyAverageBrightness);
#else #else
@ -518,3 +526,59 @@ float3 CompositeReflectionCapturesAndSkylightTWS(
## DiffuseIndirectComposite ## DiffuseIndirectComposite
位于IndirectLightRendering.cpp的`RenderDiffuseIndirectAndAmbientOcclusion()` 位于IndirectLightRendering.cpp的`RenderDiffuseIndirectAndAmbientOcclusion()`
`RenderDiffuseIndirectAndAmbientOcclusion()`主要执行了:
1. 进行判断是否跳过当前View的计算。主要是判断是否开启Lumen以及传入的bCompositeRegularLumenOnly变量
2. SetupCommonDiffuseIndirectParameters()
3. 计算GI
- ScreenSpaceGI
- RTGI
- Lumen
- Lumen Reflection输出结果到OutTextures.Textures[3]。
- SSR输出结果到OutTextures.Textures[3]。
- 其他Reflection结果输出为黑色。
4. 使用降噪器对SSGI与RTGI进行降噪
5. 渲染AO
- 禁用
- RTAO
- SSAO
- 其他没有实现的会谈报错提醒
6. 将渲染的AO结果赋予SceneTextures.ScreenSpaceAO
7. RenderHairStrandsAmbientOcclusion()
8.
位于IndirectLightRendering.cpp的RenderDeferredReflectionsAndSkyLighting() => `AddSkyReflectionPass()`
`DiffuseIndirectMethod = EDiffuseIndirectMethod::Lumen`也就是开启Lumen GI如果反射方法为Lumen或者SSR则不会执行后续逻辑。
不开启Lumen GI反射方法为
- Lumen`RenderLumenReflections()`
- RT Reflection`RenderRayTracingReflections()`
- SSR`ScreenSpaceRayTracing::RenderScreenSpaceReflections()`
`RenderDeferredReflectionsAndSkyLighting()`主要执行了:
1. SkyLightDiffuse
1. RenderDistanceFieldLighting()
1. RenderDistanceFieldAOScreenGrid()渲染距离场AO。
2. RenderCapsuleShadowsForMovableSkylight():渲染胶囊阴影。
2. ReflectionIndirect
- RenderLumenReflections()
- RenderRayTracingReflections()
- RenderScreenSpaceReflections()
3. Denoise
- DenoiserIScreenSpaceDenoiser::DenoiseReflections()
- TemporalFilterAddTemporalAAPass()
4. RenderDeferredPlanarReflections():合成平面反射结果。
5. AddSkyReflectionPass()
几种反射方式的大致执行逻辑:
- LumenReflection
1. 输出FRDGTextureRef ReflectionsColor。
- SSR与RT
1. 输出结果到IScreenSpaceDenoiser::FReflectionsInputs DenoiserInputs的FRDGTextureRef Color。
2. 执行对应的降噪算法。
3. 结果赋予给FRDGTextureRef ReflectionsColor。
- 执行完上述反射方法后,最后执行`AddSkyReflectionPass()`
FReflectionEnvironmentSkyLightingPS位于/Engine/Private/ReflectionEnvironmentPixelShader.usf的`ReflectionEnvironmentSkyLighting()`