#include #include #include #include "Components/CameraComponent.h" #include "Rendering/Execution/CameraFramePlan.h" #include "Rendering/Shadow/DirectionalShadowData.h" namespace XCEngine { namespace Rendering { namespace { Resources::ShaderKeywordSet BuildDefaultSceneGlobalShaderKeywords( const RenderSceneData& sceneData) { Resources::ShaderKeywordSet keywords = {}; if (sceneData.lighting.HasMainDirectionalShadow()) { keywords.enabledKeywords.PushBack("XC_MAIN_LIGHT_SHADOWS"); } Resources::NormalizeShaderKeywordSetInPlace(keywords); return keywords; } RenderEnvironmentData BuildDefaultEnvironmentData(const CameraFramePlan& plan) { RenderEnvironmentData environment = {}; const RenderSurface& mainSceneSurface = plan.GetMainSceneSurface(); if (plan.request.camera == nullptr || mainSceneSurface.GetDepthAttachment() == nullptr || !HasRenderClearFlag(plan.request.clearFlags, RenderClearFlags::Color) || !plan.request.camera->IsSkyboxEnabled() || plan.request.camera->GetProjectionType() != Components::CameraProjectionType::Perspective) { return environment; } if (const Resources::Material* skyboxMaterial = plan.request.camera->GetSkyboxMaterial()) { environment.mode = RenderEnvironmentMode::MaterialSkybox; environment.materialSkybox.material = skyboxMaterial; return environment; } environment.mode = RenderEnvironmentMode::ProceduralSkybox; environment.skybox.topColor = plan.request.camera->GetSkyboxTopColor(); environment.skybox.horizonColor = plan.request.camera->GetSkyboxHorizonColor(); environment.skybox.bottomColor = plan.request.camera->GetSkyboxBottomColor(); return environment; } } // namespace void RenderPipeline::ConfigureRenderSceneData( const CameraFramePlan& plan, RenderSceneData& sceneData) const { sceneData.globalShaderKeywords = BuildDefaultSceneGlobalShaderKeywords(sceneData); sceneData.environment = BuildDefaultEnvironmentData(plan); } void ApplyDefaultRenderPipelineDirectionalShadowExecutionPolicy( const CameraFramePlan& plan, const DirectionalShadowSurfaceAllocation& shadowAllocation, DirectionalShadowExecutionState& shadowState) { shadowState.shadowCasterRequest.surface = shadowAllocation.surface; shadowState.shadowCasterRequest.clearFlags = RenderClearFlags::Depth; if (!shadowState.shadowCasterRequest.hasCameraDataOverride) { shadowState.shadowCasterRequest.hasCameraDataOverride = true; shadowState.shadowCasterRequest.cameraDataOverride = plan.directionalShadow.cameraData; } shadowState.shadowData = BuildRenderDirectionalShadowData( plan.directionalShadow, shadowAllocation.depthShaderView); } bool RenderPipeline::ConfigureDirectionalShadowExecutionState( const CameraFramePlan& plan, const DirectionalShadowSurfaceAllocation& shadowAllocation, DirectionalShadowExecutionState& shadowState) const { ApplyDefaultRenderPipelineDirectionalShadowExecutionPolicy( plan, shadowAllocation, shadowState); return shadowState.shadowCasterRequest.IsValid() && shadowState.shadowData.IsValid(); } } // namespace Rendering } // namespace XCEngine