UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ProceduralNoise.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6#include "Math/Vector2D.h"
7#include "MathUtil.h"
9
10namespace UE {
11namespace Geometry {
12
13enum class EFBMMode : uint8
14{
19
24
28 Ridge
29};
30
31template <typename T>
33 const EFBMMode FBMMode,
34 const uint32 OctaveCount,
35 const Math::TVector2<T> Coords, //< sampling coordinates
36 const T Lacunarity, //< multiplier to apply to frequency from one octave to the next finer one
37 const T Gain, //< weight to apply to amplitude from one octave to the next finer one
38 const T Smoothness, //< smoothness amount to apply to turbulent and ridge modes
39 const T Gamma) //< gamma to apply to turbulent and ridge
40{
41 T Amplitude{ 1. };
42
43 checkSlow(Smoothness >= T(0.));
44 checkSlow(Gain > T(0.));
45 checkSlow(Lacunarity > T(0.));
46 checkSlow(Gamma > T(0.));
47
48 const T SmoothEps = Smoothness * T(0.01);
49 FVector2d ST(Coords.X, Coords.Y);
50
51 T TotalOffset{ 0. };
52
53 for (uint32 Octave = 0; Octave < OctaveCount; ++Octave)
54 {
56 switch (FBMMode) {
58 // nothing to be done
59 break;
61 Offset = FMath::Pow(2. * FMath::Sqrt(Offset * Offset + SmoothEps), Gamma);
62 break;
63 case EFBMMode::Ridge:
64 Offset = FMath::Pow(1. - FMath::Sqrt(Offset * Offset + SmoothEps), Gamma);
65 break;
66 };
67
68 TotalOffset += Amplitude * Offset;
69 ST *= Lacunarity;
70 Amplitude *= Gain;
71 }
72
73 return TotalOffset;
74}
75
76} // namespace Geometry
77} // namespace UE
#define checkSlow(expr)
Definition AssertionMacros.h:332
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint32 Offset
Definition VulkanMemory.cpp:4033
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
EFBMMode
Definition ProceduralNoise.h:14
T FractalBrownianMotionNoise(const EFBMMode FBMMode, const uint32 OctaveCount, const Math::TVector2< T > Coords, const T Lacunarity, const T Gain, const T Smoothness, const T Gamma)
Definition ProceduralNoise.h:32
Definition AdvancedWidgetsModule.cpp:13
static CORE_API float PerlinNoise2D(const FVector2D &Location)
Definition UnrealMath.cpp:3629
Definition Vector2D.h:38
T Y
Definition Vector2D.h:52
T X
Definition Vector2D.h:49