2026-04-15 21:22:29 +08:00
|
|
|
#include <XCEngine/Rendering/RenderPipelineAsset.h>
|
|
|
|
|
|
|
|
|
|
#include "Components/CameraComponent.h"
|
2026-04-15 22:25:04 +08:00
|
|
|
#include "Components/LightComponent.h"
|
2026-04-15 21:22:29 +08:00
|
|
|
#include "Rendering/Execution/CameraFramePlan.h"
|
2026-04-15 22:25:04 +08:00
|
|
|
#include "Rendering/Extraction/RenderSceneUtility.h"
|
2026-04-15 21:22:29 +08:00
|
|
|
#include "Rendering/Planning/Internal/CameraFrameFullscreenStagePlanner.h"
|
2026-04-15 22:25:04 +08:00
|
|
|
#include "Rendering/Planning/Internal/DirectionalShadowPlanning.h"
|
|
|
|
|
#include "Rendering/Planning/CameraRenderRequest.h"
|
|
|
|
|
#include "Rendering/Planning/SceneRenderRequestPlanner.h"
|
2026-04-15 21:22:29 +08:00
|
|
|
|
|
|
|
|
namespace XCEngine {
|
|
|
|
|
namespace Rendering {
|
|
|
|
|
|
2026-04-15 22:25:04 +08:00
|
|
|
void ApplyDefaultRenderPipelineAssetCameraRenderRequestPolicy(
|
|
|
|
|
CameraRenderRequest& request,
|
|
|
|
|
size_t renderedBaseCameraCount,
|
|
|
|
|
size_t renderedRequestCount,
|
|
|
|
|
const DirectionalShadowPlanningSettings& directionalShadowSettings) {
|
|
|
|
|
if (request.scene == nullptr ||
|
|
|
|
|
request.camera == nullptr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Internal::ShouldPlanDirectionalShadowForCamera(
|
|
|
|
|
*request.camera,
|
|
|
|
|
renderedBaseCameraCount,
|
|
|
|
|
renderedRequestCount)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Components::LightComponent* const mainDirectionalLight =
|
|
|
|
|
FindMainDirectionalLight(
|
|
|
|
|
*request.scene,
|
|
|
|
|
request.camera->GetCullingMask());
|
|
|
|
|
if (mainDirectionalLight == nullptr ||
|
|
|
|
|
!mainDirectionalLight->GetCastsShadows()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DirectionalShadowPlanningSettings effectiveShadowSettings =
|
|
|
|
|
Internal::SanitizeDirectionalShadowPlanningSettings(
|
|
|
|
|
directionalShadowSettings);
|
|
|
|
|
if (mainDirectionalLight->GetOverridesDirectionalShadowSettings()) {
|
|
|
|
|
effectiveShadowSettings.sampling =
|
|
|
|
|
mainDirectionalLight->GetDirectionalShadowSamplingSettings();
|
|
|
|
|
effectiveShadowSettings.casterBias =
|
|
|
|
|
mainDirectionalLight->GetDirectionalShadowCasterBiasSettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const float viewportAspect = request.surface.GetRenderAreaHeight() > 0
|
|
|
|
|
? static_cast<float>(request.surface.GetRenderAreaWidth()) /
|
|
|
|
|
static_cast<float>(request.surface.GetRenderAreaHeight())
|
|
|
|
|
: 1.0f;
|
|
|
|
|
request.directionalShadow =
|
|
|
|
|
Internal::BuildDirectionalShadowRenderPlan(
|
|
|
|
|
*request.scene,
|
|
|
|
|
*request.camera,
|
|
|
|
|
*mainDirectionalLight,
|
|
|
|
|
effectiveShadowSettings,
|
|
|
|
|
viewportAspect);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-15 21:22:29 +08:00
|
|
|
void ApplyDefaultRenderPipelineAssetCameraFramePlanPolicy(
|
|
|
|
|
CameraFramePlan& plan,
|
|
|
|
|
const FinalColorSettings& pipelineDefaults) {
|
|
|
|
|
if (plan.request.camera != nullptr) {
|
|
|
|
|
plan.finalColorPolicy = ResolveFinalColorPolicy(
|
|
|
|
|
pipelineDefaults,
|
|
|
|
|
&plan.request.camera->GetFinalColorOverrides());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Internal::PlanCameraFrameFullscreenStages(plan);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-15 22:25:04 +08:00
|
|
|
void RenderPipelineAsset::ConfigureCameraRenderRequest(
|
|
|
|
|
CameraRenderRequest& request,
|
|
|
|
|
size_t renderedBaseCameraCount,
|
|
|
|
|
size_t renderedRequestCount,
|
|
|
|
|
const DirectionalShadowPlanningSettings& directionalShadowSettings) const {
|
|
|
|
|
ApplyDefaultRenderPipelineAssetCameraRenderRequestPolicy(
|
|
|
|
|
request,
|
|
|
|
|
renderedBaseCameraCount,
|
|
|
|
|
renderedRequestCount,
|
|
|
|
|
directionalShadowSettings);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-15 21:22:29 +08:00
|
|
|
void RenderPipelineAsset::ConfigureCameraFramePlan(CameraFramePlan& plan) const {
|
|
|
|
|
ApplyDefaultRenderPipelineAssetCameraFramePlanPolicy(
|
|
|
|
|
plan,
|
|
|
|
|
GetDefaultFinalColorSettings());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Rendering
|
|
|
|
|
} // namespace XCEngine
|