rendering: formalize editor support object id boundary

This commit is contained in:
2026-04-22 16:17:27 +08:00
parent 17326f455e
commit ab87ad85d7
30 changed files with 646 additions and 178 deletions

View File

@@ -32,9 +32,6 @@ constexpr const char* kBuiltinUnlitShaderPath = "builtin://shaders/unlit";
constexpr const char* kBuiltinDepthOnlyShaderPath = "builtin://shaders/depth-only";
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* kBuiltinGaussianSplatShaderPath = "builtin://shaders/gaussian-splat";
constexpr const char* kBuiltinGaussianSplatUtilitiesShaderPath =
@@ -63,12 +60,6 @@ constexpr const char* kBuiltinShadowCasterShaderAssetRelativePath =
"engine/assets/builtin/shaders/shadow-caster.shader";
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* kBuiltinGaussianSplatShaderAssetRelativePath =
@@ -156,18 +147,11 @@ const char* GetBuiltinShaderAssetRelativePath(const Containers::String& builtinS
if (builtinShaderPath == Containers::String(kBuiltinShadowCasterShaderPath)) {
return kBuiltinShadowCasterShaderAssetRelativePath;
}
#if XCENGINE_ENABLE_RENDERING_EDITOR_SUPPORT
if (builtinShaderPath == Containers::String(kBuiltinObjectIdShaderPath)) {
return kBuiltinObjectIdShaderAssetRelativePath;
}
if (builtinShaderPath == Containers::String(kBuiltinObjectIdOutlineShaderPath)) {
return kBuiltinObjectIdOutlineShaderAssetRelativePath;
}
if (builtinShaderPath == Containers::String(kBuiltinSelectionMaskShaderPath)) {
return kBuiltinSelectionMaskShaderAssetRelativePath;
}
if (builtinShaderPath == Containers::String(kBuiltinSelectionOutlineShaderPath)) {
return kBuiltinSelectionOutlineShaderAssetRelativePath;
}
#endif
if (builtinShaderPath == Containers::String(kBuiltinSkyboxShaderPath)) {
return kBuiltinSkyboxShaderAssetRelativePath;
}
@@ -731,19 +715,12 @@ Shader* BuildBuiltinShadowCasterShader(const Containers::String& path) {
}
Shader* BuildBuiltinObjectIdShader(const Containers::String& path) {
#if XCENGINE_ENABLE_RENDERING_EDITOR_SUPPORT
return TryLoadBuiltinShaderFromAsset(path);
}
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);
#else
(void)path;
return nullptr;
#endif
}
Shader* BuildBuiltinSkyboxShader(const Containers::String& path) {
@@ -852,22 +829,12 @@ bool TryGetBuiltinShaderPathByShaderName(
outPath = GetBuiltinShadowCasterShaderPath();
return true;
}
#if XCENGINE_ENABLE_RENDERING_EDITOR_SUPPORT
if (shaderName == "Builtin Object Id") {
outPath = GetBuiltinObjectIdShaderPath();
return true;
}
if (shaderName == "Builtin Object Id Outline") {
outPath = GetBuiltinObjectIdOutlineShaderPath();
return true;
}
if (shaderName == "Builtin Selection Mask") {
outPath = GetBuiltinSelectionMaskShaderPath();
return true;
}
if (shaderName == "Builtin Selection Outline") {
outPath = GetBuiltinSelectionOutlineShaderPath();
return true;
}
#endif
if (shaderName == "Builtin Skybox") {
outPath = GetBuiltinSkyboxShaderPath();
return true;
@@ -948,19 +915,11 @@ Containers::String GetBuiltinShadowCasterShaderPath() {
}
Containers::String GetBuiltinObjectIdShaderPath() {
#if XCENGINE_ENABLE_RENDERING_EDITOR_SUPPORT
return Containers::String(kBuiltinObjectIdShaderPath);
}
Containers::String GetBuiltinObjectIdOutlineShaderPath() {
return Containers::String(kBuiltinObjectIdOutlineShaderPath);
}
Containers::String GetBuiltinSelectionMaskShaderPath() {
return Containers::String(kBuiltinSelectionMaskShaderPath);
}
Containers::String GetBuiltinSelectionOutlineShaderPath() {
return Containers::String(kBuiltinSelectionOutlineShaderPath);
#else
return Containers::String();
#endif
}
Containers::String GetBuiltinSkyboxShaderPath() {
@@ -1083,14 +1042,10 @@ LoadResult CreateBuiltinShaderResource(const Containers::String& path) {
shader = BuildBuiltinDepthOnlyShader(path);
} else if (path == GetBuiltinShadowCasterShaderPath()) {
shader = BuildBuiltinShadowCasterShader(path);
#if XCENGINE_ENABLE_RENDERING_EDITOR_SUPPORT
} else if (path == GetBuiltinObjectIdShaderPath()) {
shader = BuildBuiltinObjectIdShader(path);
} else if (path == GetBuiltinObjectIdOutlineShaderPath()) {
shader = BuildBuiltinObjectIdOutlineShader(path);
} else if (path == GetBuiltinSelectionMaskShaderPath()) {
shader = BuildBuiltinSelectionMaskShader(path);
} else if (path == GetBuiltinSelectionOutlineShaderPath()) {
shader = BuildBuiltinSelectionOutlineShader(path);
#endif
} else if (path == GetBuiltinSkyboxShaderPath()) {
shader = BuildBuiltinSkyboxShader(path);
} else if (path == GetBuiltinGaussianSplatShaderPath()) {