mirror of
https://github.com/Eragon-Brisingr/UShaderLab.git
synced 2026-09-15 14:54:36 +00:00
Support Legacy shader mode
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
#include "Misc/FileHelper.h"
|
||||
#include "ShaderCore.h"
|
||||
#include "SceneTypes.h"
|
||||
#include "RenderUtils.h" // Substrate::IsSubstrateEnabled()
|
||||
|
||||
#define SHADERLAB_COMMON_INCLUDE TEXT("/Plugin/ShaderLab/Private/ShaderLabCommon.ush")
|
||||
#define SHADERLAB_FUNCTIONS_INCLUDE TEXT("/Plugin/ShaderLab/Private/ShaderLabUEFunctions.ush")
|
||||
@@ -2521,6 +2522,10 @@ namespace ShaderLabGraph
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy (non-Substrate) pixel-stage emitter. Pulled into this TU (inside namespace ShaderLabGraph) so it
|
||||
// reuses the helpers above without a shared header. Deletable wholesale with the non-Substrate scheme.
|
||||
#include "ShaderLabSurfaceEmitter_Legacy.inl"
|
||||
}
|
||||
|
||||
bool FShaderLabGraphBuilder::ResolveVirtualShaderFile(const FString& VirtualPath, FString& OutDiskPath)
|
||||
@@ -3099,6 +3104,17 @@ bool FShaderLabGraphBuilder::BuildInto(UMaterial& Material, const FShaderLabMode
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!Substrate::IsSubstrateEnabled())
|
||||
{
|
||||
// Legacy (non-Substrate) scheme: PostProcess/UI already handled above (mode-independent). Everything
|
||||
// else (SL_SURFACE -> DefaultLit, single SL_UNLIT -> Unlit) wires to the standard material pins; the
|
||||
// rest is rejected with a .usl error. See ShaderLabSurfaceEmitter_Legacy.inl.
|
||||
if (!EmitLegacyPixelStage(Material, *EditorOnly, Model, Program, Emit, PropertyNodes,
|
||||
InterpByName, UsedInterps, Samples, SurfaceOutParam, ParamY, OutErrors))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (Model.bHasSurface)
|
||||
{
|
||||
// Single-Surface sugar: one slab straight to FrontMaterial, with the FShaderLabSurface material-level
|
||||
@@ -3526,9 +3542,22 @@ void FShaderLabGraphBuilder::BuildPoisonInto(UMaterial& Material, const TArray<F
|
||||
*SrcPath, *Combined);
|
||||
Custom->RebuildOutputs();
|
||||
|
||||
UMaterialExpressionSubstrateSlabBSDF* Slab = NewExpr<UMaterialExpressionSubstrateSlabBSDF>(Material, IoY, 0);
|
||||
Slab->DiffuseAlbedo.Connect(0, Custom);
|
||||
EditorOnly->FrontMaterial.Connect(0, Slab);
|
||||
if (Substrate::IsSubstrateEnabled())
|
||||
{
|
||||
// Substrate: Custom -> Slab.DiffuseAlbedo -> FrontMaterial (DiffuseAlbedo is a core BSDF pin, always
|
||||
// translated, so the #error is reached).
|
||||
UMaterialExpressionSubstrateSlabBSDF* Slab = NewExpr<UMaterialExpressionSubstrateSlabBSDF>(Material, IoY, 0);
|
||||
Slab->DiffuseAlbedo.Connect(0, Custom);
|
||||
EditorOnly->FrontMaterial.Connect(0, Slab);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Legacy (non-Substrate): FrontMaterial is inactive, so the Slab->FrontMaterial poison would be
|
||||
// dead-stripped and the #error never compiled. Wire the Custom to MP_BaseColor (a core DefaultLit pin
|
||||
// that is always translated) so the #error still aborts the compile with our diagnostics.
|
||||
Material.SetShadingModel(MSM_DefaultLit);
|
||||
EditorOnly->BaseColor.Connect(0, Custom);
|
||||
}
|
||||
|
||||
Material.UpdateCachedExpressionData();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user