Support Legacy shader mode

This commit is contained in:
Eragon-Brisingr
2026-07-05 19:37:06 +08:00
parent 59af77e8f6
commit 3dbdf02f27
7 changed files with 739 additions and 323 deletions

View File

@@ -24,6 +24,7 @@
#include "Serialization/JsonReader.h"
#include "Serialization/JsonSerializer.h"
#include "Serialization/JsonWriter.h"
#include "RenderUtils.h" // Substrate::IsSubstrateEnabled()
#include "ShaderCore.h"
#include "ShaderLabIntrinsicRegistry.h"
@@ -405,6 +406,20 @@ namespace ShaderLabIDEPrepare_Private
bChanged = true;
}
// SHADERLAB_SUBSTRATE picks the surface-struct parameterization (Substrate Slab fields vs legacy
// Metallic/Roughness) the IDE checks against. It mirrors the project's r.Substrate so authoring on
// the legacy (r.Substrate=0) branch sees the legacy FShaderLabSurface (S.BaseColor/Metallic/...) and
// does not red-underline it as "no member". The real compiler derives this from the engine's own
// SUBSTRATE_ENABLED; this only affects the editor's shader-validator.
const TCHAR* SubstrateValue = Substrate::IsSubstrateEnabled() ? TEXT("1") : TEXT("0");
FString SubstrateDefine;
if (!Defines->TryGetStringField(TEXT("SHADERLAB_SUBSTRATE"), SubstrateDefine) || SubstrateDefine != SubstrateValue)
{
Defines->SetStringField(TEXT("SHADERLAB_SUBSTRATE"), SubstrateValue);
Settings->SetObjectField(TEXT("shader-validator.defines"), Defines);
bChanged = true;
}
if (!bChanged)
{
UE_LOG(LogShaderLabIDE, Log, TEXT(" unchanged: %s"), *SettingsPath);