From 6a24cc4470cfa24896162f0473543df5d66bc8d3 Mon Sep 17 00:00:00 2001 From: BlueRose <378100977@qq.com> Date: Thu, 19 Dec 2024 15:13:04 +0800 Subject: [PATCH] vault backup: 2024-12-19 15:13:04 --- .../various-complements/histories.json | 2 +- .../RenderingPipeline/Lighting/Shadow.md | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.obsidian/plugins/various-complements/histories.json b/.obsidian/plugins/various-complements/histories.json index 4c6818d..0e6b9ae 100644 --- a/.obsidian/plugins/various-complements/histories.json +++ b/.obsidian/plugins/various-complements/histories.json @@ -1 +1 @@ -{"SequoiaCamShotEvalTemplate":{"SequoiaCamShotEvalTemplate":{"currentFile":{"count":1,"lastUpdated":1732609264076}}},"c++内存泄漏分析工具":{"c++内存泄漏分析工具":{"internalLink":{"count":1,"lastUpdated":1733137754779}}},"Lights":{"Lights":{"currentFile":{"count":1,"lastUpdated":1733637911876}}},"FShadowProjectionNoTransformVS(ShadowProjectionNoTransformVS)、FShadowVolumeBoundProjectionVS(ShadowVolumeBoundProjectionVS)":{"FShadowProjectionNoTransformVS(ShadowProjectionNoTransformVS)、FShadowVolumeBoundProjectionVS(ShadowVolumeBoundProjectionVS)":{"currentFile":{"count":1,"lastUpdated":1734345863513}}},"DecodeLightAttenuation":{"DecodeLightAttenuation":{"currentFile":{"count":1,"lastUpdated":1734406452310}}}} \ No newline at end of file +{"SequoiaCamShotEvalTemplate":{"SequoiaCamShotEvalTemplate":{"currentFile":{"count":1,"lastUpdated":1732609264076}}},"c++内存泄漏分析工具":{"c++内存泄漏分析工具":{"internalLink":{"count":1,"lastUpdated":1733137754779}}},"Lights":{"Lights":{"currentFile":{"count":1,"lastUpdated":1733637911876}}},"FShadowProjectionNoTransformVS(ShadowProjectionNoTransformVS)、FShadowVolumeBoundProjectionVS(ShadowVolumeBoundProjectionVS)":{"FShadowProjectionNoTransformVS(ShadowProjectionNoTransformVS)、FShadowVolumeBoundProjectionVS(ShadowVolumeBoundProjectionVS)":{"currentFile":{"count":1,"lastUpdated":1734345863513}}},"DecodeLightAttenuation":{"DecodeLightAttenuation":{"currentFile":{"count":1,"lastUpdated":1734406452310}}},"clamped":{"clamped":{"currentFile":{"count":1,"lastUpdated":1734590559877}}}} \ No newline at end of file diff --git a/03-UnrealEngine/Rendering/RenderingPipeline/Lighting/Shadow.md b/03-UnrealEngine/Rendering/RenderingPipeline/Lighting/Shadow.md index 7e6ec60..1259292 100644 --- a/03-UnrealEngine/Rendering/RenderingPipeline/Lighting/Shadow.md +++ b/03-UnrealEngine/Rendering/RenderingPipeline/Lighting/Shadow.md @@ -436,6 +436,29 @@ bool FShadowDepthPassMeshProcessor::TryAddMeshBatch(const FMeshBatch& RESTRICT M } ``` +## ShaderDepthBias +相关计算位于FProjectedShadowInfo::UpdateShaderDepthBias()。 +起效条件:勾选Dynamic Inset Shadow +CMD: CVarPerObjectDirectionalShadowDepthBias => r.Shadow.PerObjectDirectionalDepthBias +```c++ +// per object shadows (the whole-scene are taken care of above) +if(bDirectionalLight) +{ + // we use CSMShadowDepthBias cvar but this is per object shadows, maybe we want to use different settings + + // the z range is adjusted to we need to adjust here as well + DepthBias = CVarPerObjectDirectionalShadowDepthBias.GetValueOnRenderThread() / (MaxSubjectZ - MinSubjectZ); + + float WorldSpaceTexelScale = ShadowBounds.W / FMath::Max(ResolutionX, ResolutionY); + + DepthBias *= WorldSpaceTexelScale; + DepthBias *= 0.5f; // avg GetUserShadowBias, in that case we don't want this adjustable + + SlopeScaleDepthBias = CVarPerObjectDirectionalShadowSlopeScaleDepthBias.GetValueOnRenderThread(); + SlopeScaleDepthBias *= LightSceneInfo->Proxy->GetUserShadowSlopeBias(); +} +``` + ## Shader VertexShader为:ShadowDepthVertexShader.usf,有4种变体: - IMPLEMENT_SHADOW_DEPTH_SHADERMODE_SHADERS(VertexShadowDepth_PerspectiveCorrect);