From ef1e22d6af4e7c2945b1cccb9385f1b8ace72a58 Mon Sep 17 00:00:00 2001 From: Eragon <450614754@qq.com> Date: Sat, 4 Jul 2026 00:29:46 +0800 Subject: [PATCH] Add Sampling.ush for IDE hint --- Shaders/Private/ShaderLabUEFunctions.ush | 7 +- Shaders/Private/UEFunctions/Sampling.ush | 72 +++++++++++++++++++ .../ShaderLabMaterialInstanceFactory.cpp | 4 ++ 3 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 Shaders/Private/UEFunctions/Sampling.ush diff --git a/Shaders/Private/ShaderLabUEFunctions.ush b/Shaders/Private/ShaderLabUEFunctions.ush index 33185a5..07d44bd 100644 --- a/Shaders/Private/ShaderLabUEFunctions.ush +++ b/Shaders/Private/ShaderLabUEFunctions.ush @@ -1,11 +1,12 @@ // Copyright UShaderLab. All Rights Reserved. // -// Aggregator for the ShaderLab `UE_` HLSL library functions. This header only includes the per-category -// implementation files under UEFunctions/. It is auto-included into every generated Custom node (so the -// forwarders compile) and pulled in by the ShaderLab.ush authoring umbrella (so they complete in the IDE). +// Aggregator for ShaderLab's UE-facing HLSL helpers. It is auto-included into every generated Custom node +// (so real helper forwarders compile) and pulled in by the ShaderLab.ush authoring umbrella (so they +// complete in the IDE). Some entries are IDE-only stubs for engine helpers already supplied by UE. #pragma once +#include "/Plugin/ShaderLab/Private/UEFunctions/Sampling.ush" // IDE-only Unreal Texture*Sample/Gather stubs. #include "/Plugin/ShaderLab/Private/UEFunctions/Noise.ush" #include "/Plugin/ShaderLab/Private/UEFunctions/Rotation.ush" #include "/Plugin/ShaderLab/Private/UEFunctions/SceneTexture.ush" diff --git a/Shaders/Private/UEFunctions/Sampling.ush b/Shaders/Private/UEFunctions/Sampling.ush new file mode 100644 index 0000000..abf9cac --- /dev/null +++ b/Shaders/Private/UEFunctions/Sampling.ush @@ -0,0 +1,72 @@ +// Copyright UShaderLab. All Rights Reserved. +// +// IDE-only stubs for Unreal's material texture sampling helpers from Common.ush. +// The real material template already provides these functions; this file only lets +// standalone HLSL tooling resolve calls inside .usl authoring files. + +#pragma once + +#ifdef SHADERLAB_IDE + +struct FloatDeriv2 +{ + float2 Value; + float2 Ddx; + float2 Ddy; +}; + +float4 Texture2DSample(Texture2D Tex, SamplerState Sampler, float2 UV) { return (float4)0; } +float4 Texture2DSample(Texture2D Tex, SamplerState Sampler, FloatDeriv2 UV) { return (float4)0; } +float Texture2DSample_A8(Texture2D Tex, SamplerState Sampler, float2 UV) { return 0; } +float4 Texture2DSampleLevel(Texture2D Tex, SamplerState Sampler, float2 UV, float Mip) { return (float4)0; } +float4 Texture2DSampleBias(Texture2D Tex, SamplerState Sampler, float2 UV, float MipBias) { return (float4)0; } +float4 Texture2DSampleGrad(Texture2D Tex, SamplerState Sampler, float2 UV, float2 DDX, float2 DDY) { return (float4)0; } + +float4 Texture3DSample(Texture3D Tex, SamplerState Sampler, float3 UV) { return (float4)0; } +float4 Texture3DSampleLevel(Texture3D Tex, SamplerState Sampler, float3 UV, float Mip) { return (float4)0; } +float4 Texture3DSampleBias(Texture3D Tex, SamplerState Sampler, float3 UV, float MipBias) { return (float4)0; } +float4 Texture3DSampleGrad(Texture3D Tex, SamplerState Sampler, float3 UV, float3 DDX, float3 DDY) { return (float4)0; } + +float4 TextureCubeSample(TextureCube Tex, SamplerState Sampler, float3 UV) { return (float4)0; } +float4 TextureCubeSampleLevel(TextureCube Tex, SamplerState Sampler, float3 UV, float Mip) { return (float4)0; } +float TextureCubeSampleDepthLevel(TextureCube TexDepth, SamplerState Sampler, float3 UV, float Mip) { return 0; } +float4 TextureCubeSampleBias(TextureCube Tex, SamplerState Sampler, float3 UV, float MipBias) { return (float4)0; } +float4 TextureCubeSampleGrad(TextureCube Tex, SamplerState Sampler, float3 UV, float3 DDX, float3 DDY) { return (float4)0; } + +float4 Texture2DArraySample(Texture2DArray Tex, SamplerState Sampler, float3 UV) { return (float4)0; } +float4 Texture2DArraySampleLevel(Texture2DArray Tex, SamplerState Sampler, float3 UV, float Mip) { return (float4)0; } +float4 Texture2DArraySampleBias(Texture2DArray Tex, SamplerState Sampler, float3 UV, float MipBias) { return (float4)0; } +float4 Texture2DArraySampleGrad(Texture2DArray Tex, SamplerState Sampler, float3 UV, float2 DDX, float2 DDY) { return (float4)0; } + +float4 Texture2DGatherRed(Texture2D Tex, SamplerState Sampler, float2 UV) { return (float4)0; } +float4 Texture2DGatherGreen(Texture2D Tex, SamplerState Sampler, float2 UV) { return (float4)0; } +float4 Texture2DGatherBlue(Texture2D Tex, SamplerState Sampler, float2 UV) { return (float4)0; } +float4 Texture2DGatherAlpha(Texture2D Tex, SamplerState Sampler, float2 UV) { return (float4)0; } + +float4 TextureCubeGatherRed(TextureCube Tex, SamplerState Sampler, float3 UV) { return (float4)0; } +float4 TextureCubeGatherGreen(TextureCube Tex, SamplerState Sampler, float3 UV) { return (float4)0; } +float4 TextureCubeGatherBlue(TextureCube Tex, SamplerState Sampler, float3 UV) { return (float4)0; } +float4 TextureCubeGatherAlpha(TextureCube Tex, SamplerState Sampler, float3 UV) { return (float4)0; } + +float4 Texture2DArrayGatherRed(Texture2DArray Tex, SamplerState Sampler, float3 UV) { return (float4)0; } +float4 Texture2DArrayGatherGreen(Texture2DArray Tex, SamplerState Sampler, float3 UV) { return (float4)0; } +float4 Texture2DArrayGatherBlue(Texture2DArray Tex, SamplerState Sampler, float3 UV) { return (float4)0; } +float4 Texture2DArrayGatherAlpha(Texture2DArray Tex, SamplerState Sampler, float3 UV) { return (float4)0; } + +float4 Texture2DSample_Decal(Texture2D Tex, SamplerState Sampler, float2 UV) { return (float4)0; } +float4 Texture3DSample_Decal(Texture3D Tex, SamplerState Sampler, float3 UV) { return (float4)0; } +float4 Texture2DArraySample_Decal(Texture2DArray Tex, SamplerState Sampler, float3 UV) { return (float4)0; } +float4 TextureCubeSample_Decal(TextureCube Tex, SamplerState Sampler, float3 UV) { return (float4)0; } + +float4 TextureCubeArraySample(TextureCubeArray Tex, SamplerState Sampler, float4 UV) { return (float4)0; } +float4 TextureCubeArraySampleLevel(TextureCubeArray Tex, SamplerState Sampler, float4 UV, float Mip) { return (float4)0; } +float4 TextureCubeArraySampleBias(TextureCubeArray Tex, SamplerState Sampler, float4 UV, float MipBias) { return (float4)0; } +float4 TextureCubeArraySampleGrad(TextureCubeArray Tex, SamplerState Sampler, float4 UV, float3 DDX, float3 DDY) { return (float4)0; } +float4 TextureCubeArraySampleLevel(TextureCubeArray Tex, SamplerState Sampler, float3 UV, float ArrayIndex, float Mip) { return (float4)0; } + +float4 TextureCubeArrayGatherRed(TextureCubeArray Tex, SamplerState Sampler, float4 UV) { return (float4)0; } +float4 TextureCubeArrayGatherGreen(TextureCubeArray Tex, SamplerState Sampler, float4 UV) { return (float4)0; } +float4 TextureCubeArrayGatherBlue(TextureCubeArray Tex, SamplerState Sampler, float4 UV) { return (float4)0; } +float4 TextureCubeArrayGatherAlpha(TextureCubeArray Tex, SamplerState Sampler, float4 UV) { return (float4)0; } + +#endif // SHADERLAB_IDE diff --git a/Source/UShaderLabEditor/Private/ShaderLabMaterialInstanceFactory.cpp b/Source/UShaderLabEditor/Private/ShaderLabMaterialInstanceFactory.cpp index 8e0ae02..1fd0fd5 100644 --- a/Source/UShaderLabEditor/Private/ShaderLabMaterialInstanceFactory.cpp +++ b/Source/UShaderLabEditor/Private/ShaderLabMaterialInstanceFactory.cpp @@ -48,6 +48,8 @@ namespace case EShaderLabDomain::PostProcess: return TEXT("PostProcess"); case EShaderLabDomain::UI: return TEXT("UI"); case EShaderLabDomain::Decal: return TEXT("Decal"); + case EShaderLabDomain::Volume: return TEXT("Volume"); + case EShaderLabDomain::LightFunction: return TEXT("LightFunction"); } checkNoEntry(); return FString(); @@ -62,6 +64,8 @@ namespace case EShaderLabBlendMode::Translucent: return TEXT("Translucent"); case EShaderLabBlendMode::Additive: return TEXT("Additive"); case EShaderLabBlendMode::Modulate: return TEXT("Modulate"); + case EShaderLabBlendMode::AlphaComposite: return TEXT("AlphaComposite"); + case EShaderLabBlendMode::AlphaHoldout: return TEXT("AlphaHoldout"); } checkNoEntry(); return FString();