Add procedural skybox scene coverage
This commit is contained in:
@@ -64,6 +64,18 @@ public:
|
||||
const Math::Color& GetClearColor() const { return m_clearColor; }
|
||||
void SetClearColor(const Math::Color& value) { m_clearColor = value; }
|
||||
|
||||
bool IsSkyboxEnabled() const { return m_skyboxEnabled; }
|
||||
void SetSkyboxEnabled(bool value) { m_skyboxEnabled = value; }
|
||||
|
||||
const Math::Color& GetSkyboxTopColor() const { return m_skyboxTopColor; }
|
||||
void SetSkyboxTopColor(const Math::Color& value) { m_skyboxTopColor = value; }
|
||||
|
||||
const Math::Color& GetSkyboxHorizonColor() const { return m_skyboxHorizonColor; }
|
||||
void SetSkyboxHorizonColor(const Math::Color& value) { m_skyboxHorizonColor = value; }
|
||||
|
||||
const Math::Color& GetSkyboxBottomColor() const { return m_skyboxBottomColor; }
|
||||
void SetSkyboxBottomColor(const Math::Color& value) { m_skyboxBottomColor = value; }
|
||||
|
||||
void Serialize(std::ostream& os) const override;
|
||||
void Deserialize(std::istream& is) override;
|
||||
|
||||
@@ -80,6 +92,10 @@ private:
|
||||
uint32_t m_cullingMask = 0xFFFFFFFFu;
|
||||
Math::Rect m_viewportRect = Math::Rect(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
Math::Color m_clearColor = Math::Color(0.192f, 0.302f, 0.475f, 1.0f);
|
||||
bool m_skyboxEnabled = false;
|
||||
Math::Color m_skyboxTopColor = Math::Color(0.18f, 0.36f, 0.74f, 1.0f);
|
||||
Math::Color m_skyboxHorizonColor = Math::Color(0.78f, 0.84f, 0.92f, 1.0f);
|
||||
Math::Color m_skyboxBottomColor = Math::Color(0.92f, 0.93f, 0.95f, 1.0f);
|
||||
};
|
||||
|
||||
} // namespace Components
|
||||
|
||||
@@ -35,8 +35,17 @@ struct RenderCameraData {
|
||||
Math::Matrix4x4 projection = Math::Matrix4x4::Identity();
|
||||
Math::Matrix4x4 viewProjection = Math::Matrix4x4::Identity();
|
||||
Math::Vector3 worldPosition = Math::Vector3::Zero();
|
||||
Math::Vector3 worldRight = Math::Vector3::Right();
|
||||
Math::Vector3 worldUp = Math::Vector3::Up();
|
||||
Math::Vector3 worldForward = Math::Vector3::Forward();
|
||||
Math::Color clearColor = Math::Color::Black();
|
||||
RenderClearFlags clearFlags = RenderClearFlags::All;
|
||||
bool perspectiveProjection = true;
|
||||
float verticalFovRadians = 60.0f * Math::DEG_TO_RAD;
|
||||
float orthographicSize = 5.0f;
|
||||
float aspectRatio = 1.0f;
|
||||
float nearClipPlane = 0.1f;
|
||||
float farClipPlane = 1000.0f;
|
||||
uint32_t viewportWidth = 0;
|
||||
uint32_t viewportHeight = 0;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/Core/Math/Color.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Rendering {
|
||||
|
||||
enum class RenderEnvironmentMode : uint32_t {
|
||||
None = 0,
|
||||
ProceduralSkybox
|
||||
};
|
||||
|
||||
struct ProceduralSkyboxData {
|
||||
Math::Color topColor = Math::Color(0.18f, 0.36f, 0.74f, 1.0f);
|
||||
Math::Color horizonColor = Math::Color(0.78f, 0.84f, 0.92f, 1.0f);
|
||||
Math::Color bottomColor = Math::Color(0.92f, 0.93f, 0.95f, 1.0f);
|
||||
};
|
||||
|
||||
struct RenderEnvironmentData {
|
||||
RenderEnvironmentMode mode = RenderEnvironmentMode::None;
|
||||
ProceduralSkyboxData skybox = {};
|
||||
|
||||
bool HasProceduralSkybox() const {
|
||||
return mode == RenderEnvironmentMode::ProceduralSkybox;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Rendering
|
||||
} // namespace XCEngine
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <XCEngine/Core/Math/Vector3.h>
|
||||
#include <XCEngine/Core/Math/Vector4.h>
|
||||
#include <XCEngine/Rendering/FrameData/RenderCameraData.h>
|
||||
#include <XCEngine/Rendering/FrameData/RenderEnvironmentData.h>
|
||||
#include <XCEngine/Rendering/FrameData/VisibleRenderItem.h>
|
||||
|
||||
#include <array>
|
||||
@@ -81,6 +82,7 @@ struct RenderLightingData {
|
||||
struct RenderSceneData {
|
||||
Components::CameraComponent* camera = nullptr;
|
||||
RenderCameraData cameraData;
|
||||
RenderEnvironmentData environment;
|
||||
RenderLightingData lighting;
|
||||
std::vector<VisibleRenderItem> visibleItems;
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ class RenderSurface;
|
||||
namespace Pipelines {
|
||||
namespace Detail {
|
||||
class BuiltinForwardOpaquePass;
|
||||
class BuiltinForwardSkyboxPass;
|
||||
class BuiltinForwardTransparentPass;
|
||||
} // namespace Detail
|
||||
|
||||
@@ -57,6 +58,7 @@ public:
|
||||
|
||||
private:
|
||||
friend class Detail::BuiltinForwardOpaquePass;
|
||||
friend class Detail::BuiltinForwardSkyboxPass;
|
||||
friend class Detail::BuiltinForwardTransparentPass;
|
||||
|
||||
struct OwnedDescriptorSet {
|
||||
@@ -98,6 +100,15 @@ private:
|
||||
Math::Vector4 baseColorFactor = Math::Vector4::One();
|
||||
};
|
||||
|
||||
struct SkyboxConstants {
|
||||
Math::Vector4 topColor = Math::Vector4::Zero();
|
||||
Math::Vector4 horizonColor = Math::Vector4::Zero();
|
||||
Math::Vector4 bottomColor = Math::Vector4::Zero();
|
||||
Math::Vector4 cameraRightAndTanHalfFov = Math::Vector4::Zero();
|
||||
Math::Vector4 cameraUpAndAspect = Math::Vector4::Zero();
|
||||
Math::Vector4 cameraForwardAndUnused = Math::Vector4::Zero();
|
||||
};
|
||||
|
||||
struct PassLayoutKey {
|
||||
const Resources::Shader* shader = nullptr;
|
||||
Containers::String passName;
|
||||
@@ -235,9 +246,11 @@ private:
|
||||
RHI::RHIResourceView* ResolveTextureView(const VisibleRenderItem& visibleItem);
|
||||
static LightingConstants BuildLightingConstants(const RenderLightingData& lightingData);
|
||||
static AdditionalLightConstants BuildAdditionalLightConstants(const RenderAdditionalLightData& lightData);
|
||||
bool HasProceduralSkybox(const RenderSceneData& sceneData) const;
|
||||
bool BeginForwardScenePass(const RenderPassContext& context);
|
||||
void EndForwardScenePass(const RenderPassContext& context);
|
||||
bool ExecuteForwardOpaquePass(const RenderPassContext& context);
|
||||
bool ExecuteForwardSkyboxPass(const RenderPassContext& context);
|
||||
bool ExecuteForwardTransparentPass(const RenderPassContext& context);
|
||||
bool DrawVisibleItems(
|
||||
const RenderContext& context,
|
||||
@@ -247,12 +260,16 @@ private:
|
||||
const RenderContext& context,
|
||||
const RenderSceneData& sceneData,
|
||||
const VisibleRenderItem& visibleItem);
|
||||
bool EnsureSkyboxResources(const RenderContext& context);
|
||||
bool CreateSkyboxResources(const RenderContext& context);
|
||||
void DestroySkyboxResources();
|
||||
|
||||
RHI::RHIDevice* m_device = nullptr;
|
||||
RHI::RHIType m_backendType = RHI::RHIType::D3D12;
|
||||
bool m_initialized = false;
|
||||
Resources::ResourceHandle<Resources::Shader> m_builtinForwardShader;
|
||||
Resources::ResourceHandle<Resources::Shader> m_builtinUnlitShader;
|
||||
Resources::ResourceHandle<Resources::Shader> m_builtinSkyboxShader;
|
||||
|
||||
RenderResourceCache m_resourceCache;
|
||||
|
||||
@@ -263,6 +280,10 @@ private:
|
||||
RHI::RHISampler* m_shadowSampler = nullptr;
|
||||
RHI::RHITexture* m_fallbackTexture = nullptr;
|
||||
RHI::RHIResourceView* m_fallbackTextureView = nullptr;
|
||||
RHI::RHIPipelineLayout* m_skyboxPipelineLayout = nullptr;
|
||||
RHI::RHIPipelineState* m_skyboxPipelineState = nullptr;
|
||||
RHI::RHIDescriptorPool* m_skyboxConstantPool = nullptr;
|
||||
RHI::RHIDescriptorSet* m_skyboxConstantSet = nullptr;
|
||||
RenderPassSequence m_passSequence;
|
||||
};
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ Containers::String GetBuiltinUnlitShaderPath();
|
||||
Containers::String GetBuiltinDepthOnlyShaderPath();
|
||||
Containers::String GetBuiltinShadowCasterShaderPath();
|
||||
Containers::String GetBuiltinObjectIdShaderPath();
|
||||
Containers::String GetBuiltinSkyboxShaderPath();
|
||||
Containers::String GetBuiltinDefaultPrimitiveTexturePath();
|
||||
|
||||
bool TryParseBuiltinPrimitiveType(const Containers::String& path, BuiltinPrimitiveType& outPrimitiveType);
|
||||
|
||||
Reference in New Issue
Block a user