mirror of
https://github.com/Eragon-Brisingr/UShaderLab.git
synced 2026-09-15 14:54:36 +00:00
44 lines
1.6 KiB
C++
44 lines
1.6 KiB
C++
// Copyright UShaderLab. All Rights Reserved.
|
|
//
|
|
// Global-distance-field intrinsics. These names are OVERLOADED (bAllowRawHelperWithArgs): the nullary form
|
|
// UE_DistanceToNearestSurface() / UE_DistanceFieldGradient() is this wired intrinsic (its real node reads the
|
|
// current pixel's world position and sets bUsesGlobalDistanceField), while UE_Name(worldPos) is a same-named
|
|
// raw HLSL helper in UEFunctions/DistanceField.ush whose binding is supplied by the "GlobalDistanceField"
|
|
// anchor capability. The parser routes a call with args to the helper and a nullary call to this node.
|
|
|
|
#include "ShaderLabIntrinsics.h"
|
|
|
|
#include "Materials/MaterialExpressionDistanceToNearestSurface.h"
|
|
#include "Materials/MaterialExpressionDistanceFieldGradient.h"
|
|
|
|
void RegisterDistanceFieldIntrinsics(FShaderLabIntrinsicRegistry& Registry)
|
|
{
|
|
using namespace ShaderLabIntrinsic_Private;
|
|
using EFreq = EShaderLabIntrinsicFrequency;
|
|
|
|
{
|
|
FShaderLabIntrinsicDesc Desc;
|
|
Desc.Name = TEXT("DistanceToNearestSurface");
|
|
Desc.Frequency = EFreq::Any;
|
|
Desc.ReturnType = TEXT("float");
|
|
Desc.bAllowRawHelperWithArgs = true;
|
|
Desc.MakeNode = [](UMaterial& M, const TArray<FString>&, FString&)
|
|
{
|
|
return MakeSimple<UMaterialExpressionDistanceToNearestSurface>(M);
|
|
};
|
|
Registry.Register(MoveTemp(Desc));
|
|
}
|
|
{
|
|
FShaderLabIntrinsicDesc Desc;
|
|
Desc.Name = TEXT("DistanceFieldGradient");
|
|
Desc.Frequency = EFreq::Any;
|
|
Desc.ReturnType = TEXT("float3");
|
|
Desc.bAllowRawHelperWithArgs = true;
|
|
Desc.MakeNode = [](UMaterial& M, const TArray<FString>&, FString&)
|
|
{
|
|
return MakeSimple<UMaterialExpressionDistanceFieldGradient>(M);
|
|
};
|
|
Registry.Register(MoveTemp(Desc));
|
|
}
|
|
}
|