diff --git a/03-UnrealEngine/卡通渲染相关资料/渲染功能/其他参考/其他游戏与软件参考/鸣潮_女主_皮肤.png b/03-UnrealEngine/卡通渲染相关资料/渲染功能/其他参考/其他游戏与软件参考/鸣潮_女主_皮肤.png new file mode 100644 index 0000000..826ee1c --- /dev/null +++ b/03-UnrealEngine/卡通渲染相关资料/渲染功能/其他参考/其他游戏与软件参考/鸣潮_女主_皮肤.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e4f9f533ecf956176b62814d03d443ce7c51b027d1d100f24a3d6c8f247bb9d9 +size 1509308 diff --git a/03-UnrealEngine/卡通渲染相关资料/渲染功能/阴影控制/ToonShadow.md b/03-UnrealEngine/卡通渲染相关资料/渲染功能/阴影控制/ToonShadow.md index f645b36..70946d1 100644 --- a/03-UnrealEngine/卡通渲染相关资料/渲染功能/阴影控制/ToonShadow.md +++ b/03-UnrealEngine/卡通渲染相关资料/渲染功能/阴影控制/ToonShadow.md @@ -387,6 +387,58 @@ void SetupShadowDepthPassUniformBuffer( } ``` +## FShadowDepthPassMeshProcessor +CullMode:双面物体会使用CM_None,其余的使用 CM_CW或者CM_CCW。 + +```c++ +bool FShadowDepthPassMeshProcessor::TryAddMeshBatch(const FMeshBatch& RESTRICT MeshBatch, + uint64 BatchElementMask, + const FPrimitiveSceneProxy* RESTRICT PrimitiveSceneProxy, + int32 StaticMeshId, + const FMaterialRenderProxy& MaterialRenderProxy, + const FMaterial& Material) +{ + const bool bShouldCastShadow = Material.ShouldCastDynamicShadows(); + + const FMeshDrawingPolicyOverrideSettings OverrideSettings = ComputeMeshOverrideSettings(MeshBatch); + const ERasterizerFillMode MeshFillMode = ComputeMeshFillMode(Material, OverrideSettings); + + const ERasterizerCullMode MeshCullMode = FMeshPassProcessor::ComputeMeshCullMode(Material, OverrideSettings); + ERasterizerCullMode FinalCullMode = SetupShadowCullMode(FeatureLevel, MeshPassTargetType, ShadowDepthType, Material, MeshCullMode, PrimitiveSceneProxy->CastsShadowAsTwoSided()); + + //判断是否投射动态阴影 && 是否在MainPass中渲染 && 是否会走OpaquePass + bool bResult = true; + if (bShouldCastShadow + && ShouldIncludeDomainInMeshPass(Material.GetMaterialDomain()) + && ShouldIncludeMaterialInDefaultOpaquePass(Material) + && EnumHasAnyFlags(MeshSelectionMask, MeshBatch.VertexFactory->SupportsGPUScene(FeatureLevel) ? EShadowMeshSelection::VSM : EShadowMeshSelection::SM)) + { + const FMaterialRenderProxy* EffectiveMaterialRenderProxy = &MaterialRenderProxy; + const FMaterial* EffectiveMaterial = &Material; + const bool bVFTypeSupportsNullPixelShader = MeshBatch.VertexFactory->SupportsNullPixelShader(); + const bool bEvaluateWPO = Material.MaterialModifiesMeshPosition_RenderThread() + && (!ShouldOptimizedWPOAffectNonNaniteShaderSelection() || PrimitiveSceneProxy->EvaluateWorldPositionOffset()); + + //取得NullPixelShader以及计算材质中的WPO,之后如果对没有Pixel进行写入且没有改变WPO使用默认材质渲染;否则则采用当前模型的材质。 + if (UseDefaultMaterialForShadowDepth(Material, bVFTypeSupportsNullPixelShader, bEvaluateWPO)) + { + const FMaterialRenderProxy* DefaultProxy = UMaterial::GetDefaultMaterial(MD_Surface)->GetRenderProxy(); + const FMaterial* DefaultMaterialResource = DefaultProxy->GetMaterialNoFallback(FeatureLevel); + check(DefaultMaterialResource); + + // Override with the default material for opaque materials that don't modify mesh position. + EffectiveMaterialRenderProxy = DefaultProxy; + EffectiveMaterial = DefaultMaterialResource; + } + + bResult = Process(MeshBatch, BatchElementMask, StaticMeshId, PrimitiveSceneProxy, *EffectiveMaterialRenderProxy, *EffectiveMaterial, MeshFillMode, FinalCullMode); + } + + return bResult; +} +``` + + # Lights ### Shader ShadowProjectionPixelShader.usf