UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ImportanceSamplingLibrary.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6#include "Engine/Texture2D.h"
8#include "ImportanceSamplingLibrary.generated.h"
9
11UENUM(BlueprintType)
13{
14 enum Type : int
15 {
18
21
24
27
30 };
31}
32
37USTRUCT(BlueprintType, meta = (HasNativeMake = "/Script/Engine.ImportanceSamplingLibrary.MakeImportanceTexture", HasNativeBreak = "/Script/Engine.ImportanceSamplingLibrary.BreakImportanceTexture"))
39{
41
42 // active texture dimensions, capped to 1024 x 1024
43 UPROPERTY()
45
46 // active number of MIP levels
47 UPROPERTY()
48 int NumMips;
49
50 // Unnormalized cumulative density of the image by rows (Size.Y+1)
51 // First entry is zero, final entry is the CDF normalization factor
52 UPROPERTY()
53 TArray<float> MarginalCDF;
54
55 // Unnormalized cumulative probability of each pixel in a row (Size.Y row CDFs of Size.X+1)
56 // First entry of each row is zero, final entry in each row is the CDF normalization factor for that row
57 UPROPERTY()
58 TArray<float> ConditionalCDF;
59
60 UE_DEPRECATED(5.6, "FColor TextureData has been deprecated, use LinearTextureData")
61 UPROPERTY(Transient, meta = (DeprecatedProperty, DeprecationMessage = "Please use LinearTextureData instead."))
62 TArray<FColor> TextureData_DEPRECATED;
63
64 // packed copy of MIP level data for filtered sampling (capped to 1024x1024)
65 // local copy seems better than allocating and copying the same data temporarily for each sample
67 TArray<FLinearColor> LinearTextureData;
68
69 // Original texture object for Break function
70 UPROPERTY()
72
73 // Original importance weight for Break function
74 UPROPERTY()
76
77public:
78 /* Default constructor, must Initialize before use */
80
81 /* Constructor with initialization */
83
88
89
90 /* Allocate and compute PDF arrays for a texture */
92
103 void ImportanceSample(const FVector2D &Rand, int Samples, float Intensity,
105
106 /* return color of texel at given MIP level, clamped to available Mip levels */
107 FLinearColor GetColorBilinear(FVector2D Position, int32 Mip) const;
108
109 /* return color interpolated between MIP levels */
110 FLinearColor GetColorTrilinear(FVector2D Position, float Mip) const;
111
112 /* importance probability weight for given texel */
113 float ImportanceWeight(FColor Texel, TEnumAsByte<EImportanceWeight::Type> WeightingFunc) const;
114};
115
116
117UCLASS(MinimalAPI)
119{
121
122 //
123 // Sobol quasi-random generator functions
124 //
125
126
132 UFUNCTION(BlueprintPure, Category = "Math|Random")
133 static ENGINE_API float RandomSobolFloat(int32 Index, int32 Dimension, float Seed);
134
141 UFUNCTION(BlueprintPure, Category = "Math|Random")
142 static ENGINE_API float NextSobolFloat(int32 Index, int32 Dimension, float PreviousValue);
143
151 UFUNCTION(BlueprintPure, Category = "Math|Random")
152 static ENGINE_API FVector2D RandomSobolCell2D(int32 Index, int32 NumCells = 1, FVector2D Cell = FVector2D(0,0), FVector2D Seed = FVector2D(0,0));
153
160 UFUNCTION(BlueprintPure, Category = "Math|Random")
161 static ENGINE_API FVector2D NextSobolCell2D(int32 Index, int32 NumCells = 1, FVector2D PreviousValue = FVector2D(0,0));
162
170 UFUNCTION(BlueprintPure, Category = "Math|Random")
171 static ENGINE_API FVector RandomSobolCell3D(int32 Index, int32 NumCells = 1, FVector Cell = FVector(0,0,0), FVector Seed = FVector(0,0,0));
172
179 UFUNCTION(BlueprintPure, Category = "Math|Random")
180 static ENGINE_API FVector NextSobolCell3D(int32 Index, int32 NumCells = 1, FVector PreviousValue = FVector(0,0,0));
181
188 UFUNCTION(BlueprintPure, meta = (NativeMakeFunc), Category = "Math|Random")
190
198 UFUNCTION(BlueprintPure, meta = (NativeBreakFunc), Category = "Math|Random")
200
211 UFUNCTION(BlueprintPure, Category = "Math|Random")
212 static ENGINE_API void ImportanceSample(const FImportanceTexture &Texture, const FVector2D &Rand, int Samples, float Intensity,
214};
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 FVector
Definition IOSSystemIncludes.h:8
UE::Math::TVector2< double > FVector2D
Definition MathFwd.h:48
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#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
uint32 Size
Definition VulkanMemory.cpp:4034
Definition UnrealType.h:3087
Definition Array.h:670
Definition EnumAsByte.h:22
Definition BlueprintFunctionLibrary.h:16
Definition ImportanceSamplingLibrary.h:119
Definition Texture2D.h:26
Definition ImportanceSamplingLibrary.h:13
Type
Definition ImportanceSamplingLibrary.h:15
U16 Index
Definition radfft.cpp:71
Definition Color.h:486
Definition ImportanceSamplingLibrary.h:39
Definition Color.h:48
Definition WeakObjectPtrTemplates.h:25
Definition IntPoint.h:25