Fix scene selection outline mask path
This commit is contained in:
@@ -226,7 +226,8 @@ inline bool TryBuildBuiltinPassDefaultResourceBindings(
|
||||
|
||||
if (ShaderPassMatchesBuiltinPass(shaderPass, BuiltinMaterialPass::Unlit) ||
|
||||
ShaderPassMatchesBuiltinPass(shaderPass, BuiltinMaterialPass::DepthOnly) ||
|
||||
ShaderPassMatchesBuiltinPass(shaderPass, BuiltinMaterialPass::ShadowCaster)) {
|
||||
ShaderPassMatchesBuiltinPass(shaderPass, BuiltinMaterialPass::ShadowCaster) ||
|
||||
ShaderPassMatchesBuiltinPass(shaderPass, BuiltinMaterialPass::SelectionMask)) {
|
||||
AppendBuiltinPassResourceBinding(
|
||||
outBindings,
|
||||
"PerObjectConstants",
|
||||
@@ -318,10 +319,17 @@ inline bool TryBuildBuiltinPassDefaultResourceBindings(
|
||||
"PerObject");
|
||||
AppendBuiltinPassResourceBinding(
|
||||
outBindings,
|
||||
"MaterialConstants",
|
||||
"LightingConstants",
|
||||
Resources::ShaderResourceType::ConstantBuffer,
|
||||
1u,
|
||||
0u,
|
||||
"Lighting");
|
||||
AppendBuiltinPassResourceBinding(
|
||||
outBindings,
|
||||
"MaterialConstants",
|
||||
Resources::ShaderResourceType::ConstantBuffer,
|
||||
2u,
|
||||
0u,
|
||||
"Material");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ inline const char* GetBuiltinPassCanonicalName(BuiltinMaterialPass pass) {
|
||||
return "shadowcaster";
|
||||
case BuiltinMaterialPass::ObjectId:
|
||||
return "objectid";
|
||||
case BuiltinMaterialPass::SelectionMask:
|
||||
return "selectionmask";
|
||||
case BuiltinMaterialPass::Skybox:
|
||||
return "skybox";
|
||||
case BuiltinMaterialPass::Volumetric:
|
||||
|
||||
@@ -18,6 +18,7 @@ enum class BuiltinMaterialPass : Core::uint32 {
|
||||
DepthOnly,
|
||||
ShadowCaster,
|
||||
ObjectId,
|
||||
SelectionMask,
|
||||
Skybox,
|
||||
Volumetric,
|
||||
PostProcess,
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/Rendering/Passes/BuiltinDepthStylePassBase.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Rendering {
|
||||
|
||||
struct RenderSceneData;
|
||||
struct VisibleRenderItem;
|
||||
|
||||
namespace Passes {
|
||||
|
||||
class BuiltinSelectionMaskPass final : public BuiltinDepthStylePassBase {
|
||||
public:
|
||||
BuiltinSelectionMaskPass();
|
||||
~BuiltinSelectionMaskPass() override = default;
|
||||
|
||||
static RHI::InputLayoutDesc BuildInputLayout();
|
||||
|
||||
const char* GetName() const override;
|
||||
|
||||
bool Render(
|
||||
const RenderContext& context,
|
||||
const RenderSurface& surface,
|
||||
const RenderSceneData& sceneData,
|
||||
const std::vector<uint64_t>& selectedObjectIds);
|
||||
|
||||
protected:
|
||||
bool ShouldRenderVisibleItem(const VisibleRenderItem& visibleItem) const override;
|
||||
|
||||
private:
|
||||
std::vector<uint64_t> m_selectedObjectIds = {};
|
||||
};
|
||||
|
||||
} // namespace Passes
|
||||
} // namespace Rendering
|
||||
} // namespace XCEngine
|
||||
@@ -0,0 +1,79 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/Core/Asset/ResourceHandle.h>
|
||||
#include <XCEngine/Core/Containers/String.h>
|
||||
#include <XCEngine/Core/Math/Color.h>
|
||||
#include <XCEngine/Core/Math/Vector4.h>
|
||||
#include <XCEngine/Rendering/RenderContext.h>
|
||||
#include <XCEngine/Rendering/RenderSurface.h>
|
||||
|
||||
#include <XCEngine/RHI/RHIDescriptorPool.h>
|
||||
#include <XCEngine/RHI/RHIDescriptorSet.h>
|
||||
#include <XCEngine/RHI/RHIEnums.h>
|
||||
#include <XCEngine/RHI/RHIPipelineLayout.h>
|
||||
#include <XCEngine/RHI/RHIPipelineState.h>
|
||||
#include <XCEngine/RHI/RHIResourceView.h>
|
||||
#include <XCEngine/Resources/Shader/Shader.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Rendering {
|
||||
namespace Passes {
|
||||
|
||||
struct SelectionOutlineStyle {
|
||||
Math::Color outlineColor = Math::Color(1.0f, 0.4f, 0.0f, 1.0f);
|
||||
float outlineWidthPixels = 2.0f;
|
||||
bool debugSelectionMask = false;
|
||||
};
|
||||
|
||||
class BuiltinSelectionOutlinePass {
|
||||
public:
|
||||
explicit BuiltinSelectionOutlinePass(Containers::String shaderPath = Containers::String());
|
||||
~BuiltinSelectionOutlinePass() = default;
|
||||
BuiltinSelectionOutlinePass(const BuiltinSelectionOutlinePass&) = delete;
|
||||
BuiltinSelectionOutlinePass& operator=(const BuiltinSelectionOutlinePass&) = delete;
|
||||
BuiltinSelectionOutlinePass(BuiltinSelectionOutlinePass&&) = delete;
|
||||
BuiltinSelectionOutlinePass& operator=(BuiltinSelectionOutlinePass&&) = delete;
|
||||
|
||||
void SetShaderPath(const Containers::String& shaderPath);
|
||||
const Containers::String& GetShaderPath() const;
|
||||
|
||||
void Shutdown();
|
||||
|
||||
bool Render(
|
||||
const RenderContext& renderContext,
|
||||
const RenderSurface& surface,
|
||||
RHI::RHIResourceView* selectionMaskTextureView,
|
||||
RHI::RHIResourceView* depthTextureView,
|
||||
const SelectionOutlineStyle& style = {});
|
||||
|
||||
private:
|
||||
struct OutlineConstants {
|
||||
Math::Vector4 viewportSizeAndTexelSize = Math::Vector4::Zero();
|
||||
Math::Vector4 outlineColor = Math::Vector4::Zero();
|
||||
Math::Vector4 outlineInfo = Math::Vector4::Zero();
|
||||
Math::Vector4 depthParams = Math::Vector4::Zero();
|
||||
};
|
||||
|
||||
bool EnsureInitialized(const RenderContext& renderContext);
|
||||
bool CreateResources(const RenderContext& renderContext);
|
||||
void DestroyResources();
|
||||
bool HasCreatedResources() const;
|
||||
void ResetState();
|
||||
|
||||
RHI::RHIDevice* m_device = nullptr;
|
||||
RHI::RHIType m_backendType = RHI::RHIType::D3D12;
|
||||
RHI::RHIPipelineLayout* m_pipelineLayout = nullptr;
|
||||
RHI::RHIPipelineState* m_pipelineState = nullptr;
|
||||
RHI::RHIDescriptorPool* m_constantPool = nullptr;
|
||||
RHI::RHIDescriptorSet* m_constantSet = nullptr;
|
||||
RHI::RHIDescriptorPool* m_texturePool = nullptr;
|
||||
RHI::RHIDescriptorSet* m_textureSet = nullptr;
|
||||
Containers::String m_shaderPath;
|
||||
std::optional<Resources::ResourceHandle<Resources::Shader>> m_builtinSelectionOutlineShader;
|
||||
};
|
||||
|
||||
} // namespace Passes
|
||||
} // namespace Rendering
|
||||
} // namespace XCEngine
|
||||
@@ -35,6 +35,8 @@ Containers::String GetBuiltinDepthOnlyShaderPath();
|
||||
Containers::String GetBuiltinShadowCasterShaderPath();
|
||||
Containers::String GetBuiltinObjectIdShaderPath();
|
||||
Containers::String GetBuiltinObjectIdOutlineShaderPath();
|
||||
Containers::String GetBuiltinSelectionMaskShaderPath();
|
||||
Containers::String GetBuiltinSelectionOutlineShaderPath();
|
||||
Containers::String GetBuiltinSkyboxShaderPath();
|
||||
Containers::String GetBuiltinVolumetricShaderPath();
|
||||
Containers::String GetBuiltinColorScalePostProcessShaderPath();
|
||||
|
||||
Reference in New Issue
Block a user