// 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&) { return MakeSimple(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&) { return MakeSimple(M); }; Registry.Register(MoveTemp(Desc)); } }