mirror of
https://github.com/Eragon-Brisingr/UShaderLab.git
synced 2026-09-16 07:14:38 +00:00
39 lines
1.8 KiB
C++
39 lines
1.8 KiB
C++
// Copyright FlecsProj. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
class UMaterial;
|
|
struct FShaderLabModel;
|
|
|
|
/**
|
|
* Editor-only builder that turns a parsed FShaderLabModel into a UMaterial expression graph:
|
|
* property parameter nodes + a Custom HLSL node for the Surface body wired into a Substrate
|
|
* Slab BSDF (-> FrontMaterial), plus an optional Vertex Custom node for WPO/displacement/UVs.
|
|
*
|
|
* The build is fully deterministic for a given model (node creation order, input/output order,
|
|
* generated HLSL) so the cook-time and editor-time graphs — and therefore the baked uniform
|
|
* expression set — match.
|
|
*/
|
|
class USHADERLABEDITOR_API FShaderLabGraphBuilder
|
|
{
|
|
public:
|
|
/**
|
|
* Clear `Material`'s expression graph and rebuild it from `Model`, applying settings
|
|
* (domain/blend/two-sided) and updating cached expression data. Does NOT trigger shader
|
|
* compilation — callers decide when to compile. Returns false with diagnostics on failure.
|
|
*/
|
|
static bool BuildInto(UMaterial& Material, const FShaderLabModel& Model, TArray<FString>& OutErrors);
|
|
|
|
/**
|
|
* Replace `Material`'s graph with a minimal Substrate material whose single Custom node emits a
|
|
* `#line`-mapped `#error` for `Diagnostics`, so it deliberately fails to compile with those messages
|
|
* mapped back to `SrcPath` (an absolute, forward-slashed .usl path). This routes .usl parse/build
|
|
* errors through the standard shader-compile path — MIC editor red text, GetCompileErrors, cook —
|
|
* instead of dropping them. The graph itself is always valid; the failure is intentional and happens
|
|
* at shader compile. Does NOT trigger compilation (the caller decides when).
|
|
*/
|
|
static void BuildPoisonInto(UMaterial& Material, const TArray<FString>& Diagnostics, const FString& SrcPath);
|
|
};
|