UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SubsurfaceProfile.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreMinimal.h"
6#include "UObject/Object.h"
7#include "RenderResource.h"
8#include "SubsurfaceProfile.generated.h"
9
10#define MAX_SUBSURFACE_PROFILE_COUNT 256
11
12UENUM()
14{
19 SIH_AFIS UMETA(DisplayName = "Adaptive Filtered Importance Sampling"),
20
22 SIH_Separable UMETA(DisplayName = "Separable"),
23};
24
25// struct with all the settings we want in USubsurfaceProfile, separate to make it easer to pass this data around in the engine.
26USTRUCT(BlueprintType)
28{
30
31
34 UPROPERTY(Category = "Burley Normalized", EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0.01", UIMax = "1.0", ClampMax = "1.0", HideAlphaChannel, editcondition = "bEnableBurley"))
35 FLinearColor SurfaceAlbedo;
36
40 UPROPERTY(Category = "Burley Normalized", EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0.001", UIMax = "1.0", ClampMax = "1.0", HideAlphaChannel, editcondition = "bEnableBurley"))
41 FLinearColor MeanFreePathColor; //MeanFreePathLength;
42
46 UPROPERTY(Category = "Burley Normalized", EditAnywhere, BluePrintReadOnly, meta = (ClampMin = "0.1", UIMax = "50.0", ClampMax = "50.0", editcondition = "bEnableBurley"))
47 float MeanFreePathDistance;
48
52 UPROPERTY(Category = "Burley Normalized", EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0.1", UIMax = "50.0", ClampMax = "50.0", editcondition = "bEnableBurley"))
53 float WorldUnitScale;
54
58 UPROPERTY(Category = "Burley Normalized", EditAnywhere, BlueprintReadOnly, meta = (editcondition = "false", EditConditionHides))
59 bool bEnableBurley;
60
64 UPROPERTY(Category = "Burley Normalized", EditAnywhere, BlueprintReadOnly, meta = (editcondition = "false", EditConditionHides))
65 bool bEnableMeanFreePath;
66
72 UPROPERTY(Category = "Burley Normalized", EditAnywhere, BlueprintReadOnly, meta = (HideAlphaChannel, editcondition = "bEnableBurley"))
74
76 UPROPERTY(Category = "SubsurfaceProfileStruct", EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0.1", UIMax = "50.0", ClampMax = "1000.0", DeprecatedProperty, editcondition = "!bEnableBurley", EditConditionHides))
77 float ScatterRadius;
78
84 UPROPERTY(Category = "SubsurfaceProfileStruct", EditAnywhere, BlueprintReadOnly, meta = (HideAlphaChannel, DeprecatedProperty, editcondition = "!bEnableBurley", EditConditionHides))
85 FLinearColor SubsurfaceColor;
86
92 UPROPERTY(Category = "SubsurfaceProfileStruct", EditAnywhere, BlueprintReadOnly, meta = (HideAlphaChannel, DeprecatedProperty, editcondition = "!bEnableBurley", EditConditionHides))
93 FLinearColor FalloffColor;
94
95 UPROPERTY(Category = "Burley Normalized", EditAnywhere, BlueprintReadOnly, meta = (HideAlphaChannel))
96 FLinearColor BoundaryColorBleed;
97
101 UPROPERTY(Category = "Burley Normalized", EditAnywhere, BlueprintReadOnly)
103
104 UPROPERTY(Category = "Transmission", EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0.01", UIMax = "100.0", ClampMax = "100.0", SliderExponent="24"))
105 float ExtinctionScale;
106
107 UPROPERTY(Category = "Transmission", EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0.01", UIMax = "0.99", ClampMax = "1.0"))
108 float NormalScale;
109
110 UPROPERTY(Category = "Transmission", EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0.01", UIMax = "0.99", ClampMax = "1.0"))
111 float ScatteringDistribution;
112
113 UPROPERTY(Category = "Transmission", EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "1.0", UIMax = "3.0", ClampMax = "3.0"))
114 float IOR;
115
116 UPROPERTY(Category = "Dual Specular", EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0.5", UIMax = "2.0", ClampMax = "2.0"))
117 float Roughness0;
118
119 UPROPERTY(Category = "Dual Specular", EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0.5", UIMax = "2.0", ClampMax = "2.0"))
120 float Roughness1;
121
122 UPROPERTY(Category = "Dual Specular", EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0.1", UIMax = "0.9", ClampMax = "0.9"))
123 float LobeMix;
124
128 UPROPERTY(Category = "Transmission", EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0.001", UIMax = "1.0", ClampMax = "1.0", HideAlphaChannel))
129 FLinearColor TransmissionTintColor;
130
131 // constructor
133 {
134 // defaults from SeparableSSS.h and the demo
135 ScatterRadius = 1.2f;
136 SubsurfaceColor = FLinearColor(0.48f, 0.41f, 0.28f);
137 FalloffColor = FLinearColor(1.0f, 0.37f, 0.3f);
138 BoundaryColorBleed = FLinearColor::White;
139 ExtinctionScale = 1.0f;
140 ScatteringDistribution = 0.93f;
141 NormalScale = 0.08f;
142 IOR = 1.55f;
143 Roughness0 = 0.75f;
144 Roughness1 = 1.30f;
145 LobeMix = 0.85f;
146 bEnableBurley = false;
147 //match FalloffColor exactly for the default setting
148 SurfaceAlbedo = FLinearColor(0.91058f,0.338275f,0.2718f);
149 MeanFreePathColor = FLinearColor(1.0f,0.1983f/2.229f,0.1607f/2.229f);
150 MeanFreePathDistance = 1.2f*2.229f;
151 WorldUnitScale = 0.1f;
152 TransmissionTintColor = FLinearColor(1.0f, 1.0f, 1.0f);
153 Tint = FLinearColor(1.0f, 1.0f, 1.0f);
154 Implementation = ESubsurfaceImplementationTechniqueHint::SIH_AFIS;
155 bEnableMeanFreePath = false;
156 }
157
159 {
160 *this = FSubsurfaceProfileStruct();
161 }
162};
163
170{
172
173 UPROPERTY(Category = USubsurfaceProfile, EditAnywhere, meta = (ShowOnlyInnerProperties))
174 struct FSubsurfaceProfileStruct Settings;
175
176 UPROPERTY()
177 FGuid Guid;
178
179 //~ Begin UObject Interface
180 virtual void BeginDestroy();
181 virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent);
182 virtual void PostDuplicate(EDuplicateMode::Type DuplicateMode);
183 virtual void Serialize(FArchive& Ar) override;
184
185 // Upgrade parameters from Separable to Burley.
186 virtual void PostLoad();
187 //~ End UObject Interface
188};
189
190// render thread
192{
193public:
194 // constructor
196
197 // destructor
199
200 // convenience, can be optimized
201 // @param Profile must not be 0, game thread pointer, do not dereference, only for comparison
203 {
204 check(Profile);
205
207
208 if (AllocationId != -1)
209 {
210 UpdateProfile(AllocationId, Settings);
211 }
212 else
213 {
214 AllocationId = AddProfile(Settings, Profile);
215 }
216
217 return AllocationId;
218 }
219
220 // O(n) n is a small number
221 // @param InProfile must not be 0, game thread pointer, do not dereference, only for comparison
222 // @return AllocationId -1: no allocation, should be deallocated with DeallocateSubsurfaceProfile()
224
225 // O(n) to find the element, n is the SSProfile count and usually quite small
227
228 // @param InProfile must not be 0, game thread pointer, do not dereference, only for comparison
230
231 // @param InProfile must not be 0, game thread pointer, do not dereference, only for comparison
233
234 // @return can be 0 if there is no SubsurfaceProfile
237
238 struct IPooledRenderTarget* GetSSProfilesPreIntegratedTexture(class FRDGBuilder& GraphBuilder, EShaderPlatform ShaderPlatform);
239
240 //~ Begin FRenderResource Interface.
244 virtual void ReleaseRHI() override;
245
246 // for debugging, can be removed
247 void Dump();
248
249 // for debugging / VisualizeSSS
250 ENGINE_API bool GetEntryString(uint32 Index, FString& Out) const;
251
252 // @param InProfile must not be 0, game thread pointer, do not dereference, only for comparison
253 // @return -1 if not found
255
256private:
257
258 struct FSubsurfaceProfileEntry
259 {
260 // @param InProfile game thread pointer, do not dereference, only for comparison, 0 if the entry can be reused or it's [0] which is used as default
262 : Settings(InSubsurfaceProfileStruct)
263 , Profile(InProfile)
264 {
265 }
266
268
269 // 0 if the entry can be reused or it's [0] which is used as default
270 // game thread pointer, do not dereference, only for comparison
271 const USubsurfaceProfile* Profile;
272 };
273
274 //
275 TArray<FSubsurfaceProfileEntry> SubsurfaceProfileEntries;
276
277 // Could be optimized but should not happen too often (during level load or editor operations).
278 void CreateTexture(FRHICommandListImmediate& RHICmdList);
279
280};
281
282// If you change this you need to recompile the SSS shaders.
283// Required if we use a texture format with limited size but want to express a larger radius
284static const int32 SUBSURFACE_RADIUS_SCALE = 1024;
285
286 // The kernels range from -3 to 3
287static const int32 SUBSURFACE_KERNEL_SIZE = 3;
288
289// lives on the render thread
291
292// Initializes or updates the contents of the subsurface profile texture.
293UE_DEPRECATED(5.5, "Please, use the name space SubsurfaceProfile::")
294ENGINE_API void UpdateSubsurfaceProfileTexture(class FRDGBuilder& GraphBuilder, EShaderPlatform ShaderPlatform);
295
296// Returns the subsurface profile texture if it exists, or null.
297UE_DEPRECATED(5.5, "Please, use the name space SubsurfaceProfile::")
299
300// Returns the subsurface profile texture if it exists, or black.
301UE_DEPRECATED(5.5, "Please, use the name space SubsurfaceProfile::")
303
304// Returns the Preintegrated texture if it exists, or black.
305UE_DEPRECATED(5.5, "Please, use the name space SubsurfaceProfile::")
307
308// Returns the subsurface profile ID shader parameter name
309UE_DEPRECATED(5.5, "Please, use the name space SubsurfaceProfile::")
311
312// Returns the subsurface profile ID for a given Sub-surface Profile object
313UE_DEPRECATED(5.5, "Please, use the name space SubsurfaceProfile::")
315
316// Returns the shader parameter name for a Subsurface profile.
317UE_DEPRECATED(5.5, "Please, use the name space SubsurfaceProfile::")
319
321{
322// Initializes or updates the contents of the subsurface profile texture.
323ENGINE_API void UpdateSubsurfaceProfileTexture(class FRDGBuilder& GraphBuilder, EShaderPlatform ShaderPlatform);
324
325// Returns the subsurface profile texture if it exists, or null.
327
328// Returns the subsurface profile texture if it exists, or black.
330
331// Returns the Preintegrated texture if it exists, or black.
333
334// Returns the subsurface profile ID shader parameter name
336
337// Returns the subsurface profile ID for a given Sub-surface Profile object
339
340// Returns the shader parameter name for a Subsurface profile.
342};
#define check(expr)
Definition AssertionMacros.h:314
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
EShaderPlatform
Definition RHIShaderPlatform.h:11
ENGINE_API float GetSubsurfaceProfileId(const USubsurfaceProfile *In)
Definition SubsurfaceProfile.cpp:725
ENGINE_API FRHITexture * GetSubsurfaceProfileTexture()
Definition SubsurfaceProfile.cpp:730
ENGINE_API FName GetSubsurfaceProfileParameterName()
Definition SubsurfaceProfile.cpp:715
ESubsurfaceImplementationTechniqueHint
Definition SubsurfaceProfile.h:14
ENGINE_API TGlobalResource< FSubsurfaceProfileTexture > GSubsurfaceProfileTextureObject
Definition SubsurfaceProfile.cpp:52
ENGINE_API void UpdateSubsurfaceProfileTexture(class FRDGBuilder &GraphBuilder, EShaderPlatform ShaderPlatform)
Definition SubsurfaceProfile.cpp:745
ENGINE_API FRHITexture * GetSubsurfaceProfileTextureWithFallback()
Definition SubsurfaceProfile.cpp:735
ENGINE_API FRHITexture * GetSSProfilesPreIntegratedTextureWithFallback()
Definition SubsurfaceProfile.cpp:740
ENGINE_API FName CreateSubsurfaceProfileParameterName(const USubsurfaceProfile *InProfile)
Definition SubsurfaceProfile.cpp:720
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
Definition NameTypes.h:617
Definition RenderGraphBuilder.h:49
Definition RHICommandList.h:4626
Definition RHIResources.h:2153
Definition RenderResource.h:37
Definition SubsurfaceProfile.h:192
ENGINE_API bool GetEntryString(uint32 Index, FString &Out) const
Definition SubsurfaceProfile.cpp:641
void RemoveProfile(const USubsurfaceProfile *InProfile)
Definition SubsurfaceProfile.cpp:174
virtual void ReleaseRHI() override
Definition SubsurfaceProfile.cpp:307
struct IPooledRenderTarget * GetSSProfilesPreIntegratedTexture(class FRDGBuilder &GraphBuilder, EShaderPlatform ShaderPlatform)
Definition SubsurfaceProfile.cpp:251
void UpdateProfile(const FSubsurfaceProfileStruct Settings, const USubsurfaceProfile *Profile)
Definition SubsurfaceProfile.h:229
int32 FindAllocationId(const USubsurfaceProfile *InProfile) const
Definition SubsurfaceProfile.cpp:667
FSubsurfaceProfileTexture()
Definition SubsurfaceProfile.cpp:127
~FSubsurfaceProfileTexture()
Definition SubsurfaceProfile.cpp:140
struct IPooledRenderTarget * GetTexture()
Definition SubsurfaceProfile.cpp:213
void Dump()
Definition SubsurfaceProfile.cpp:682
int32 AddOrUpdateProfile(const FSubsurfaceProfileStruct Settings, const USubsurfaceProfile *Profile)
Definition SubsurfaceProfile.h:202
int32 AddProfile(const FSubsurfaceProfileStruct Settings, const USubsurfaceProfile *InProfile)
Definition SubsurfaceProfile.cpp:144
Definition Array.h:670
Definition RenderResource.h:543
Definition Object.h:95
Definition SubsurfaceProfile.h:170
Type
Definition UObjectGlobals.h:128
Definition SubsurfaceProfile.h:321
@ false
Definition radaudio_common.h:23
U16 Index
Definition radfft.cpp:71
Definition Guid.h:109
Definition Color.h:48
static CORE_API const FLinearColor White
Definition Color.h:456
Definition UnrealType.h:6865
Definition SubsurfaceProfile.h:28
void Invalidate()
Definition SubsurfaceProfile.h:158
Definition RendererInterface.h:494