Fix scene selection outline mask path
This commit is contained in:
@@ -360,7 +360,9 @@ BuiltinDepthStylePassBase::ResolvedShaderPass BuiltinDepthStylePassBase::Resolve
|
||||
return resolved;
|
||||
}
|
||||
|
||||
if (material != nullptr && IsTransparentRenderQueue(ResolveMaterialRenderQueue(material))) {
|
||||
if (material != nullptr &&
|
||||
IsTransparentRenderQueue(ResolveMaterialRenderQueue(material)) &&
|
||||
m_passType != BuiltinMaterialPass::SelectionMask) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
65
engine/src/Rendering/Passes/BuiltinSelectionMaskPass.cpp
Normal file
65
engine/src/Rendering/Passes/BuiltinSelectionMaskPass.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "Rendering/Passes/BuiltinSelectionMaskPass.h"
|
||||
|
||||
#include "Components/GameObject.h"
|
||||
#include "Resources/BuiltinResources.h"
|
||||
|
||||
#include <XCEngine/Rendering/FrameData/RenderSceneData.h>
|
||||
#include <XCEngine/Rendering/FrameData/VisibleRenderItem.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Rendering {
|
||||
namespace Passes {
|
||||
|
||||
BuiltinSelectionMaskPass::BuiltinSelectionMaskPass()
|
||||
: BuiltinDepthStylePassBase(
|
||||
BuiltinMaterialPass::SelectionMask,
|
||||
Resources::GetBuiltinSelectionMaskShaderPath()) {
|
||||
}
|
||||
|
||||
RHI::InputLayoutDesc BuiltinSelectionMaskPass::BuildInputLayout() {
|
||||
return BuildCommonInputLayout();
|
||||
}
|
||||
|
||||
const char* BuiltinSelectionMaskPass::GetName() const {
|
||||
return "BuiltinSelectionMaskPass";
|
||||
}
|
||||
|
||||
bool BuiltinSelectionMaskPass::Render(
|
||||
const RenderContext& context,
|
||||
const RenderSurface& surface,
|
||||
const RenderSceneData& sceneData,
|
||||
const std::vector<uint64_t>& selectedObjectIds) {
|
||||
m_selectedObjectIds = selectedObjectIds;
|
||||
if (m_selectedObjectIds.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RenderSceneData selectionMaskSceneData = sceneData;
|
||||
selectionMaskSceneData.cameraData.clearFlags = RenderClearFlags::Color;
|
||||
selectionMaskSceneData.cameraData.clearColor = Math::Color::Black();
|
||||
|
||||
const RenderPassContext passContext = {
|
||||
context,
|
||||
surface,
|
||||
selectionMaskSceneData,
|
||||
nullptr,
|
||||
nullptr
|
||||
};
|
||||
return Execute(passContext);
|
||||
}
|
||||
|
||||
bool BuiltinSelectionMaskPass::ShouldRenderVisibleItem(const VisibleRenderItem& visibleItem) const {
|
||||
if (visibleItem.gameObject == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const uint64_t objectId = visibleItem.gameObject->GetID();
|
||||
return std::find(m_selectedObjectIds.begin(), m_selectedObjectIds.end(), objectId) !=
|
||||
m_selectedObjectIds.end();
|
||||
}
|
||||
|
||||
} // namespace Passes
|
||||
} // namespace Rendering
|
||||
} // namespace XCEngine
|
||||
429
engine/src/Rendering/Passes/BuiltinSelectionOutlinePass.cpp
Normal file
429
engine/src/Rendering/Passes/BuiltinSelectionOutlinePass.cpp
Normal file
@@ -0,0 +1,429 @@
|
||||
#include "Rendering/Passes/BuiltinSelectionOutlinePass.h"
|
||||
|
||||
#include "Core/Asset/ResourceManager.h"
|
||||
#include "Debug/Logger.h"
|
||||
#include "Rendering/Detail/ShaderVariantUtils.h"
|
||||
#include "Rendering/Materials/RenderMaterialStateUtils.h"
|
||||
#include "RHI/RHICommandList.h"
|
||||
#include "RHI/RHIDevice.h"
|
||||
|
||||
#include <XCEngine/Resources/BuiltinResources.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Rendering {
|
||||
namespace Passes {
|
||||
|
||||
namespace {
|
||||
|
||||
const Resources::ShaderPass* FindSelectionOutlineCompatiblePass(
|
||||
const Resources::Shader& shader,
|
||||
Resources::ShaderBackend backend) {
|
||||
const Resources::ShaderPass* outlinePass = shader.FindPass("SelectionOutline");
|
||||
if (outlinePass != nullptr &&
|
||||
::XCEngine::Rendering::Detail::ShaderPassHasGraphicsVariants(shader, outlinePass->name, backend)) {
|
||||
return outlinePass;
|
||||
}
|
||||
|
||||
const Resources::ShaderPass* editorOutlinePass = shader.FindPass("EditorSelectionOutline");
|
||||
if (editorOutlinePass != nullptr &&
|
||||
::XCEngine::Rendering::Detail::ShaderPassHasGraphicsVariants(
|
||||
shader,
|
||||
editorOutlinePass->name,
|
||||
backend)) {
|
||||
return editorOutlinePass;
|
||||
}
|
||||
|
||||
if (shader.GetPassCount() > 0 &&
|
||||
::XCEngine::Rendering::Detail::ShaderPassHasGraphicsVariants(
|
||||
shader,
|
||||
shader.GetPasses()[0].name,
|
||||
backend)) {
|
||||
return &shader.GetPasses()[0];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RHI::GraphicsPipelineDesc CreatePipelineDesc(
|
||||
RHI::RHIType backendType,
|
||||
RHI::RHIPipelineLayout* pipelineLayout,
|
||||
const Resources::Shader& shader,
|
||||
const Containers::String& passName) {
|
||||
RHI::GraphicsPipelineDesc pipelineDesc = {};
|
||||
pipelineDesc.pipelineLayout = pipelineLayout;
|
||||
pipelineDesc.topologyType = static_cast<uint32_t>(RHI::PrimitiveTopologyType::Triangle);
|
||||
pipelineDesc.renderTargetCount = 1;
|
||||
pipelineDesc.renderTargetFormats[0] = static_cast<uint32_t>(RHI::Format::R8G8B8A8_UNorm);
|
||||
pipelineDesc.depthStencilFormat = static_cast<uint32_t>(RHI::Format::Unknown);
|
||||
pipelineDesc.sampleCount = 1;
|
||||
|
||||
const Resources::ShaderPass* shaderPass = shader.FindPass(passName);
|
||||
if (shaderPass != nullptr && shaderPass->hasFixedFunctionState) {
|
||||
::XCEngine::Rendering::ApplyRenderState(shaderPass->fixedFunctionState, pipelineDesc);
|
||||
} else {
|
||||
Resources::MaterialRenderState fallbackState = {};
|
||||
fallbackState.cullMode = Resources::MaterialCullMode::None;
|
||||
fallbackState.depthWriteEnable = false;
|
||||
fallbackState.depthTestEnable = false;
|
||||
fallbackState.depthFunc = Resources::MaterialComparisonFunc::Always;
|
||||
fallbackState.blendEnable = true;
|
||||
fallbackState.srcBlend = Resources::MaterialBlendFactor::SrcAlpha;
|
||||
fallbackState.dstBlend = Resources::MaterialBlendFactor::InvSrcAlpha;
|
||||
fallbackState.srcBlendAlpha = Resources::MaterialBlendFactor::One;
|
||||
fallbackState.dstBlendAlpha = Resources::MaterialBlendFactor::InvSrcAlpha;
|
||||
fallbackState.blendOp = Resources::MaterialBlendOp::Add;
|
||||
fallbackState.blendOpAlpha = Resources::MaterialBlendOp::Add;
|
||||
fallbackState.colorWriteMask = static_cast<uint8_t>(RHI::ColorWriteMask::All);
|
||||
::XCEngine::Rendering::ApplyRenderState(fallbackState, pipelineDesc);
|
||||
}
|
||||
|
||||
const Resources::ShaderBackend backend = ::XCEngine::Rendering::Detail::ToShaderBackend(backendType);
|
||||
if (const Resources::ShaderStageVariant* vertexVariant =
|
||||
shader.FindVariant(passName, Resources::ShaderType::Vertex, backend)) {
|
||||
if (shaderPass != nullptr) {
|
||||
::XCEngine::Rendering::Detail::ApplyShaderStageVariant(
|
||||
shader.GetPath(),
|
||||
*shaderPass,
|
||||
backend,
|
||||
*vertexVariant,
|
||||
pipelineDesc.vertexShader);
|
||||
}
|
||||
}
|
||||
if (const Resources::ShaderStageVariant* fragmentVariant =
|
||||
shader.FindVariant(passName, Resources::ShaderType::Fragment, backend)) {
|
||||
if (shaderPass != nullptr) {
|
||||
::XCEngine::Rendering::Detail::ApplyShaderStageVariant(
|
||||
shader.GetPath(),
|
||||
*shaderPass,
|
||||
backend,
|
||||
*fragmentVariant,
|
||||
pipelineDesc.fragmentShader);
|
||||
}
|
||||
}
|
||||
|
||||
return pipelineDesc;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
BuiltinSelectionOutlinePass::BuiltinSelectionOutlinePass(Containers::String shaderPath)
|
||||
: m_shaderPath(shaderPath.Empty() ? Resources::GetBuiltinSelectionOutlineShaderPath() : std::move(shaderPath)) {
|
||||
ResetState();
|
||||
}
|
||||
|
||||
void BuiltinSelectionOutlinePass::SetShaderPath(const Containers::String& shaderPath) {
|
||||
if (m_shaderPath == shaderPath) {
|
||||
return;
|
||||
}
|
||||
|
||||
DestroyResources();
|
||||
m_shaderPath = shaderPath;
|
||||
}
|
||||
|
||||
const Containers::String& BuiltinSelectionOutlinePass::GetShaderPath() const {
|
||||
return m_shaderPath;
|
||||
}
|
||||
|
||||
void BuiltinSelectionOutlinePass::Shutdown() {
|
||||
DestroyResources();
|
||||
}
|
||||
|
||||
bool BuiltinSelectionOutlinePass::Render(
|
||||
const RenderContext& renderContext,
|
||||
const RenderSurface& surface,
|
||||
RHI::RHIResourceView* selectionMaskTextureView,
|
||||
RHI::RHIResourceView* depthTextureView,
|
||||
const SelectionOutlineStyle& style) {
|
||||
if (!renderContext.IsValid() ||
|
||||
renderContext.backendType != RHI::RHIType::D3D12 ||
|
||||
selectionMaskTextureView == nullptr ||
|
||||
depthTextureView == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EnsureInitialized(renderContext)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::vector<RHI::RHIResourceView*>& colorAttachments = surface.GetColorAttachments();
|
||||
if (colorAttachments.empty() || colorAttachments[0] == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OutlineConstants constants = {};
|
||||
constants.viewportSizeAndTexelSize = Math::Vector4(
|
||||
static_cast<float>(surface.GetWidth()),
|
||||
static_cast<float>(surface.GetHeight()),
|
||||
surface.GetWidth() > 0 ? 1.0f / static_cast<float>(surface.GetWidth()) : 0.0f,
|
||||
surface.GetHeight() > 0 ? 1.0f / static_cast<float>(surface.GetHeight()) : 0.0f);
|
||||
constants.outlineColor = Math::Vector4(
|
||||
style.outlineColor.r,
|
||||
style.outlineColor.g,
|
||||
style.outlineColor.b,
|
||||
style.outlineColor.a);
|
||||
constants.outlineInfo = Math::Vector4(
|
||||
style.debugSelectionMask ? 1.0f : 0.0f,
|
||||
style.outlineWidthPixels,
|
||||
0.0f,
|
||||
0.0f);
|
||||
constants.depthParams = Math::Vector4(1.0e-5f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
m_constantSet->WriteConstant(0, &constants, sizeof(constants));
|
||||
m_textureSet->Update(0, selectionMaskTextureView);
|
||||
m_textureSet->Update(1, depthTextureView);
|
||||
|
||||
RHI::RHICommandList* commandList = renderContext.commandList;
|
||||
RHI::RHIResourceView* renderTarget = colorAttachments[0];
|
||||
commandList->TransitionBarrier(
|
||||
renderTarget,
|
||||
surface.GetColorStateAfter(),
|
||||
RHI::ResourceStates::RenderTarget);
|
||||
commandList->TransitionBarrier(
|
||||
depthTextureView,
|
||||
RHI::ResourceStates::DepthWrite,
|
||||
RHI::ResourceStates::PixelShaderResource);
|
||||
commandList->SetRenderTargets(1, &renderTarget, nullptr);
|
||||
|
||||
const Math::RectInt renderArea = surface.GetRenderArea();
|
||||
const RHI::Viewport viewport = {
|
||||
static_cast<float>(renderArea.x),
|
||||
static_cast<float>(renderArea.y),
|
||||
static_cast<float>(renderArea.width),
|
||||
static_cast<float>(renderArea.height),
|
||||
0.0f,
|
||||
1.0f
|
||||
};
|
||||
const RHI::Rect scissorRect = {
|
||||
renderArea.x,
|
||||
renderArea.y,
|
||||
renderArea.x + renderArea.width,
|
||||
renderArea.y + renderArea.height
|
||||
};
|
||||
|
||||
commandList->SetViewport(viewport);
|
||||
commandList->SetScissorRect(scissorRect);
|
||||
commandList->SetPrimitiveTopology(RHI::PrimitiveTopology::TriangleList);
|
||||
commandList->SetPipelineState(m_pipelineState);
|
||||
|
||||
RHI::RHIDescriptorSet* descriptorSets[] = { m_constantSet, m_textureSet };
|
||||
commandList->SetGraphicsDescriptorSets(0, 2, descriptorSets, m_pipelineLayout);
|
||||
commandList->Draw(3, 1, 0, 0);
|
||||
|
||||
commandList->TransitionBarrier(
|
||||
renderTarget,
|
||||
RHI::ResourceStates::RenderTarget,
|
||||
surface.GetColorStateAfter());
|
||||
commandList->TransitionBarrier(
|
||||
depthTextureView,
|
||||
RHI::ResourceStates::PixelShaderResource,
|
||||
RHI::ResourceStates::DepthWrite);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BuiltinSelectionOutlinePass::EnsureInitialized(const RenderContext& renderContext) {
|
||||
if (m_pipelineLayout != nullptr &&
|
||||
m_pipelineState != nullptr &&
|
||||
m_constantPool != nullptr &&
|
||||
m_constantSet != nullptr &&
|
||||
m_texturePool != nullptr &&
|
||||
m_textureSet != nullptr &&
|
||||
m_device == renderContext.device &&
|
||||
m_backendType == renderContext.backendType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (HasCreatedResources()) {
|
||||
DestroyResources();
|
||||
}
|
||||
return CreateResources(renderContext);
|
||||
}
|
||||
|
||||
bool BuiltinSelectionOutlinePass::CreateResources(const RenderContext& renderContext) {
|
||||
if (!renderContext.IsValid() || renderContext.backendType != RHI::RHIType::D3D12) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_shaderPath.Empty()) {
|
||||
Debug::Logger::Get().Error(
|
||||
Debug::LogCategory::Rendering,
|
||||
"BuiltinSelectionOutlinePass requires an injected shader path before resource creation");
|
||||
return false;
|
||||
}
|
||||
|
||||
Resources::ResourceHandle<Resources::Shader> shader = Resources::ResourceManager::Get().Load<Resources::Shader>(
|
||||
m_shaderPath);
|
||||
if (!shader.IsValid()) {
|
||||
Debug::Logger::Get().Error(
|
||||
Debug::LogCategory::Rendering,
|
||||
"BuiltinSelectionOutlinePass failed to load configured selection-outline shader resource");
|
||||
ResetState();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_device = renderContext.device;
|
||||
m_backendType = renderContext.backendType;
|
||||
m_builtinSelectionOutlineShader.emplace(std::move(shader));
|
||||
|
||||
const Resources::ShaderBackend backend = ::XCEngine::Rendering::Detail::ToShaderBackend(m_backendType);
|
||||
const Resources::ShaderPass* outlinePass =
|
||||
FindSelectionOutlineCompatiblePass(*m_builtinSelectionOutlineShader->Get(), backend);
|
||||
if (outlinePass == nullptr) {
|
||||
Debug::Logger::Get().Error(
|
||||
Debug::LogCategory::Rendering,
|
||||
"BuiltinSelectionOutlinePass could not resolve a valid SelectionOutline shader pass");
|
||||
DestroyResources();
|
||||
return false;
|
||||
}
|
||||
|
||||
RHI::DescriptorSetLayoutBinding constantBinding = {};
|
||||
constantBinding.binding = 0;
|
||||
constantBinding.type = static_cast<uint32_t>(RHI::DescriptorType::CBV);
|
||||
constantBinding.count = 1;
|
||||
|
||||
RHI::DescriptorSetLayoutBinding textureBindings[2] = {};
|
||||
textureBindings[0].binding = 0;
|
||||
textureBindings[0].type = static_cast<uint32_t>(RHI::DescriptorType::SRV);
|
||||
textureBindings[0].count = 1;
|
||||
textureBindings[1].binding = 1;
|
||||
textureBindings[1].type = static_cast<uint32_t>(RHI::DescriptorType::SRV);
|
||||
textureBindings[1].count = 1;
|
||||
|
||||
RHI::DescriptorSetLayoutDesc constantLayout = {};
|
||||
constantLayout.bindings = &constantBinding;
|
||||
constantLayout.bindingCount = 1;
|
||||
|
||||
RHI::DescriptorSetLayoutDesc textureLayout = {};
|
||||
textureLayout.bindings = textureBindings;
|
||||
textureLayout.bindingCount = 2;
|
||||
|
||||
RHI::DescriptorSetLayoutDesc setLayouts[2] = {};
|
||||
setLayouts[0] = constantLayout;
|
||||
setLayouts[1] = textureLayout;
|
||||
|
||||
RHI::RHIPipelineLayoutDesc pipelineLayoutDesc = {};
|
||||
pipelineLayoutDesc.setLayouts = setLayouts;
|
||||
pipelineLayoutDesc.setLayoutCount = 2;
|
||||
m_pipelineLayout = m_device->CreatePipelineLayout(pipelineLayoutDesc);
|
||||
if (m_pipelineLayout == nullptr) {
|
||||
DestroyResources();
|
||||
return false;
|
||||
}
|
||||
|
||||
RHI::DescriptorPoolDesc constantPoolDesc = {};
|
||||
constantPoolDesc.type = RHI::DescriptorHeapType::CBV_SRV_UAV;
|
||||
constantPoolDesc.descriptorCount = 1;
|
||||
constantPoolDesc.shaderVisible = false;
|
||||
m_constantPool = m_device->CreateDescriptorPool(constantPoolDesc);
|
||||
if (m_constantPool == nullptr) {
|
||||
DestroyResources();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_constantSet = m_constantPool->AllocateSet(constantLayout);
|
||||
if (m_constantSet == nullptr) {
|
||||
DestroyResources();
|
||||
return false;
|
||||
}
|
||||
|
||||
RHI::DescriptorPoolDesc texturePoolDesc = {};
|
||||
texturePoolDesc.type = RHI::DescriptorHeapType::CBV_SRV_UAV;
|
||||
texturePoolDesc.descriptorCount = 2;
|
||||
texturePoolDesc.shaderVisible = true;
|
||||
m_texturePool = m_device->CreateDescriptorPool(texturePoolDesc);
|
||||
if (m_texturePool == nullptr) {
|
||||
DestroyResources();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_textureSet = m_texturePool->AllocateSet(textureLayout);
|
||||
if (m_textureSet == nullptr) {
|
||||
DestroyResources();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_pipelineState = m_device->CreatePipelineState(
|
||||
CreatePipelineDesc(
|
||||
m_backendType,
|
||||
m_pipelineLayout,
|
||||
*m_builtinSelectionOutlineShader->Get(),
|
||||
outlinePass->name));
|
||||
if (m_pipelineState == nullptr || !m_pipelineState->IsValid()) {
|
||||
DestroyResources();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BuiltinSelectionOutlinePass::HasCreatedResources() const {
|
||||
return m_device != nullptr ||
|
||||
m_pipelineLayout != nullptr ||
|
||||
m_pipelineState != nullptr ||
|
||||
m_constantPool != nullptr ||
|
||||
m_constantSet != nullptr ||
|
||||
m_texturePool != nullptr ||
|
||||
m_textureSet != nullptr ||
|
||||
m_builtinSelectionOutlineShader.has_value();
|
||||
}
|
||||
|
||||
void BuiltinSelectionOutlinePass::DestroyResources() {
|
||||
if (m_pipelineState != nullptr) {
|
||||
m_pipelineState->Shutdown();
|
||||
delete m_pipelineState;
|
||||
m_pipelineState = nullptr;
|
||||
}
|
||||
|
||||
if (m_textureSet != nullptr) {
|
||||
m_textureSet->Shutdown();
|
||||
delete m_textureSet;
|
||||
m_textureSet = nullptr;
|
||||
}
|
||||
|
||||
if (m_texturePool != nullptr) {
|
||||
m_texturePool->Shutdown();
|
||||
delete m_texturePool;
|
||||
m_texturePool = nullptr;
|
||||
}
|
||||
|
||||
if (m_constantSet != nullptr) {
|
||||
m_constantSet->Shutdown();
|
||||
delete m_constantSet;
|
||||
m_constantSet = nullptr;
|
||||
}
|
||||
|
||||
if (m_constantPool != nullptr) {
|
||||
m_constantPool->Shutdown();
|
||||
delete m_constantPool;
|
||||
m_constantPool = nullptr;
|
||||
}
|
||||
|
||||
if (m_pipelineLayout != nullptr) {
|
||||
m_pipelineLayout->Shutdown();
|
||||
delete m_pipelineLayout;
|
||||
m_pipelineLayout = nullptr;
|
||||
}
|
||||
|
||||
if (m_builtinSelectionOutlineShader.has_value()) {
|
||||
m_builtinSelectionOutlineShader.reset();
|
||||
}
|
||||
|
||||
ResetState();
|
||||
}
|
||||
|
||||
void BuiltinSelectionOutlinePass::ResetState() {
|
||||
m_device = nullptr;
|
||||
m_backendType = RHI::RHIType::D3D12;
|
||||
m_pipelineLayout = nullptr;
|
||||
m_pipelineState = nullptr;
|
||||
m_constantPool = nullptr;
|
||||
m_constantSet = nullptr;
|
||||
m_texturePool = nullptr;
|
||||
m_textureSet = nullptr;
|
||||
m_builtinSelectionOutlineShader.reset();
|
||||
}
|
||||
|
||||
} // namespace Passes
|
||||
} // namespace Rendering
|
||||
} // namespace XCEngine
|
||||
@@ -33,6 +33,8 @@ constexpr const char* kBuiltinDepthOnlyShaderPath = "builtin://shaders/depth-onl
|
||||
constexpr const char* kBuiltinShadowCasterShaderPath = "builtin://shaders/shadow-caster";
|
||||
constexpr const char* kBuiltinObjectIdShaderPath = "builtin://shaders/object-id";
|
||||
constexpr const char* kBuiltinObjectIdOutlineShaderPath = "builtin://shaders/object-id-outline";
|
||||
constexpr const char* kBuiltinSelectionMaskShaderPath = "builtin://shaders/selection-mask";
|
||||
constexpr const char* kBuiltinSelectionOutlineShaderPath = "builtin://shaders/selection-outline";
|
||||
constexpr const char* kBuiltinSkyboxShaderPath = "builtin://shaders/skybox";
|
||||
constexpr const char* kBuiltinVolumetricShaderPath = "builtin://shaders/volumetric";
|
||||
constexpr const char* kBuiltinColorScalePostProcessShaderPath =
|
||||
@@ -60,6 +62,10 @@ constexpr const char* kBuiltinObjectIdShaderAssetRelativePath =
|
||||
"engine/assets/builtin/shaders/object-id.shader";
|
||||
constexpr const char* kBuiltinObjectIdOutlineShaderAssetRelativePath =
|
||||
"engine/assets/builtin/shaders/object-id-outline.shader";
|
||||
constexpr const char* kBuiltinSelectionMaskShaderAssetRelativePath =
|
||||
"engine/assets/builtin/shaders/selection-mask.shader";
|
||||
constexpr const char* kBuiltinSelectionOutlineShaderAssetRelativePath =
|
||||
"engine/assets/builtin/shaders/selection-outline.shader";
|
||||
constexpr const char* kBuiltinSkyboxShaderAssetRelativePath =
|
||||
"engine/assets/builtin/shaders/skybox.shader";
|
||||
constexpr const char* kBuiltinVolumetricShaderAssetRelativePath =
|
||||
@@ -149,6 +155,12 @@ const char* GetBuiltinShaderAssetRelativePath(const Containers::String& builtinS
|
||||
if (builtinShaderPath == Containers::String(kBuiltinObjectIdOutlineShaderPath)) {
|
||||
return kBuiltinObjectIdOutlineShaderAssetRelativePath;
|
||||
}
|
||||
if (builtinShaderPath == Containers::String(kBuiltinSelectionMaskShaderPath)) {
|
||||
return kBuiltinSelectionMaskShaderAssetRelativePath;
|
||||
}
|
||||
if (builtinShaderPath == Containers::String(kBuiltinSelectionOutlineShaderPath)) {
|
||||
return kBuiltinSelectionOutlineShaderAssetRelativePath;
|
||||
}
|
||||
if (builtinShaderPath == Containers::String(kBuiltinSkyboxShaderPath)) {
|
||||
return kBuiltinSkyboxShaderAssetRelativePath;
|
||||
}
|
||||
@@ -710,6 +722,14 @@ Shader* BuildBuiltinObjectIdOutlineShader(const Containers::String& path) {
|
||||
return TryLoadBuiltinShaderFromAsset(path);
|
||||
}
|
||||
|
||||
Shader* BuildBuiltinSelectionMaskShader(const Containers::String& path) {
|
||||
return TryLoadBuiltinShaderFromAsset(path);
|
||||
}
|
||||
|
||||
Shader* BuildBuiltinSelectionOutlineShader(const Containers::String& path) {
|
||||
return TryLoadBuiltinShaderFromAsset(path);
|
||||
}
|
||||
|
||||
Shader* BuildBuiltinSkyboxShader(const Containers::String& path) {
|
||||
return TryLoadBuiltinShaderFromAsset(path);
|
||||
}
|
||||
@@ -735,9 +755,6 @@ Material* BuildDefaultPrimitiveMaterial(const Containers::String& path) {
|
||||
params.memorySize = 0;
|
||||
material->Initialize(params);
|
||||
|
||||
MaterialRenderState renderState = {};
|
||||
renderState.cullMode = MaterialCullMode::Back;
|
||||
material->SetRenderState(renderState);
|
||||
material->SetRenderQueue(MaterialRenderQueue::Geometry);
|
||||
material->SetShader(ResourceManager::Get().Load<Shader>(GetBuiltinForwardLitShaderPath()));
|
||||
material->SetTexture(
|
||||
@@ -823,6 +840,14 @@ bool TryGetBuiltinShaderPathByShaderName(
|
||||
outPath = GetBuiltinObjectIdOutlineShaderPath();
|
||||
return true;
|
||||
}
|
||||
if (shaderName == "Builtin Selection Mask") {
|
||||
outPath = GetBuiltinSelectionMaskShaderPath();
|
||||
return true;
|
||||
}
|
||||
if (shaderName == "Builtin Selection Outline") {
|
||||
outPath = GetBuiltinSelectionOutlineShaderPath();
|
||||
return true;
|
||||
}
|
||||
if (shaderName == "Builtin Skybox") {
|
||||
outPath = GetBuiltinSkyboxShaderPath();
|
||||
return true;
|
||||
@@ -902,6 +927,14 @@ Containers::String GetBuiltinObjectIdOutlineShaderPath() {
|
||||
return Containers::String(kBuiltinObjectIdOutlineShaderPath);
|
||||
}
|
||||
|
||||
Containers::String GetBuiltinSelectionMaskShaderPath() {
|
||||
return Containers::String(kBuiltinSelectionMaskShaderPath);
|
||||
}
|
||||
|
||||
Containers::String GetBuiltinSelectionOutlineShaderPath() {
|
||||
return Containers::String(kBuiltinSelectionOutlineShaderPath);
|
||||
}
|
||||
|
||||
Containers::String GetBuiltinSkyboxShaderPath() {
|
||||
return Containers::String(kBuiltinSkyboxShaderPath);
|
||||
}
|
||||
@@ -1018,6 +1051,10 @@ LoadResult CreateBuiltinShaderResource(const Containers::String& path) {
|
||||
shader = BuildBuiltinObjectIdShader(path);
|
||||
} else if (path == GetBuiltinObjectIdOutlineShaderPath()) {
|
||||
shader = BuildBuiltinObjectIdOutlineShader(path);
|
||||
} else if (path == GetBuiltinSelectionMaskShaderPath()) {
|
||||
shader = BuildBuiltinSelectionMaskShader(path);
|
||||
} else if (path == GetBuiltinSelectionOutlineShaderPath()) {
|
||||
shader = BuildBuiltinSelectionOutlineShader(path);
|
||||
} else if (path == GetBuiltinSkyboxShaderPath()) {
|
||||
shader = BuildBuiltinSkyboxShader(path);
|
||||
} else if (path == GetBuiltinVolumetricShaderPath()) {
|
||||
|
||||
Reference in New Issue
Block a user