UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::Geometry::FImageOccupancyMap Class Reference

#include <ImageOccupancyMap.h>

Public Types

using FGridSampler = TGridSampler< double >
 

Public Member Functions

void Initialize (FImageDimensions DimensionsIn, int32 SamplesPerPixel=1)
 
void Initialize (FImageDimensions DimensionsIn, const FImageTile &TileIn, int32 SamplesPerPixel=1)
 
bool IsInterior (int64 LinearIndex) const
 
int32 TexelNumSamples (int64 LinearIndex) const
 
template<typename MeshType , typename GetTriangleIDFuncType >
bool ClassifySamplesFromUVSpaceMesh (const MeshType &UVSpaceMesh, GetTriangleIDFuncType GetTriangleIDFunc=[](int32 TriangleID) { return TriangleID;}, const TArray< int32 > *UVSpaceMeshTriCharts=nullptr)
 
template<typename MeshType , typename GetTriangleIDFuncType >
bool ClassifySamplesFromUVSpaceMesh (const MeshType &UVSpaceMesh, const TMeshAABBTree3< MeshType > &UVSpaceMeshSpatial, GetTriangleIDFuncType GetTriangleIDFunc=[](int32 TriangleID) { return TriangleID;}, const TArray< int32 > *UVSpaceMeshTriCharts=nullptr)
 
bool ComputeGutterTexelsFromGutterSamples ()
 
template<typename MeshType , typename GetTriangleIDFuncType >
bool ComputeFromUVSpaceMesh (const MeshType &UVSpaceMesh, GetTriangleIDFuncType GetTriangleIDFunc=[](int32 TriangleID) { return TriangleID;}, const TArray< int32 > *UVSpaceMeshTriCharts=nullptr)
 
template<typename TexelValueType >
void ParallelProcessingPass (TFunctionRef< TexelValueType(int64 LinearIdx)> BeginTexel, TFunctionRef< void(int64 LinearIdx, float Weight, TexelValueType &)> AccumulateTexel, TFunctionRef< void(int64 LinearIdx, float Weight, TexelValueType &)> CompleteTexel, TFunctionRef< void(int64 LinearIdx, TexelValueType &)> WriteTexel, TFunctionRef< float(const FVector2i &TexelOffset)> WeightFunction, int32 FilterWidth, TArray< TexelValueType > &PassBuffer) const
 

Public Attributes

FImageDimensions Dimensions
 
FImageTile Tile
 
int32 GutterSize = 4
 
TArray64< int8TexelType
 
TArray64< int32TexelInteriorSamples
 
TArray64< FVector2fTexelQueryUV
 
TArray64< int32TexelQueryTriangle
 
TArray64< int32TexelQueryUVChart
 
TArray64< TTuple< int64, int64 > > BorderTexels
 
TArray64< TTuple< int64, int64 > > GutterTexels
 
FGridSampler PixelSampler = FGridSampler(1)
 
bool bParallel = true
 

Static Public Attributes

static constexpr int8 EmptyTexel = 0
 
static constexpr int8 InteriorTexel = 1
 
static constexpr int8 BorderTexel = 2
 
static constexpr int8 GutterTexel = 3
 

Protected Member Functions

void InitializePixelSampler (const int32 SamplesPerPixelIn)
 

Detailed Description

ImageOccupancyMap calculates and stores coverage information for a 2D image/texture, for example coverage derived from UV islands of a mesh, 2D polygons, etc.

An optional set of gutter texels can be calculated, and correspondence between gutter texels and the nearest interior texel is stored.

In addition, a 2D coordinate (eg UV) and integer ID (eg Triangle ID) of each texel can be calculated/stored. This is not just a cache. For 'border' texels where the texel center is technically outside the mesh/polygon, but the texel rectangle may still overlap the shape, the nearest UV/Triangle is stored. This simplifies computing samples around the borders such that the shape is covered under linear interpolatione/etc.

TODO Some of the names in this class are misleading because the name mentions "Texel" but should actually say "Sample" this is because the class initially supported only one sample per texel but later multi-sampling was added

Member Typedef Documentation

◆ FGridSampler

Member Function Documentation

◆ ClassifySamplesFromUVSpaceMesh() [1/2]

template<typename MeshType , typename GetTriangleIDFuncType >
bool UE::Geometry::FImageOccupancyMap::ClassifySamplesFromUVSpaceMesh ( const MeshType &  UVSpaceMesh,
const TMeshAABBTree3< MeshType > &  UVSpaceMeshSpatial,
GetTriangleIDFuncType  GetTriangleIDFunc = [](int32 TriangleID) { return TriangleID; },
const TArray< int32 > *  UVSpaceMeshTriCharts = nullptr 
)
inline

◆ ClassifySamplesFromUVSpaceMesh() [2/2]

template<typename MeshType , typename GetTriangleIDFuncType >
bool UE::Geometry::FImageOccupancyMap::ClassifySamplesFromUVSpaceMesh ( const MeshType &  UVSpaceMesh,
GetTriangleIDFuncType  GetTriangleIDFunc = [](int32 TriangleID) { return TriangleID; },
const TArray< int32 > *  UVSpaceMeshTriCharts = nullptr 
)
inline

Set texel type at the given X/Y

◆ ComputeFromUVSpaceMesh()

template<typename MeshType , typename GetTriangleIDFuncType >
bool UE::Geometry::FImageOccupancyMap::ComputeFromUVSpaceMesh ( const MeshType &  UVSpaceMesh,
GetTriangleIDFuncType  GetTriangleIDFunc = [](int32 TriangleID) { return TriangleID; },
const TArray< int32 > *  UVSpaceMeshTriCharts = nullptr 
)
inline

Computes the image occupancy map from a UV space mesh. This function classifies all the samples in the image, and computes the GutterTexels mapping, if you dont want the mapping you can call ClassifySamplesFromUVSpaceMesh and compute it yourself (eg for texture baking we use filter kernel coverage to compute the GutterTexels mapping)

Parameters
UVSpaceMeshUV space mesh to compute the occupancy map from.
GetTriangleIDFuncLambda to remap a texel's nearest triangle ID
UVSpaceMeshTriChartsOptional UVSpaceMesh triangle ID to UV chart map

◆ ComputeGutterTexelsFromGutterSamples()

bool UE::Geometry::FImageOccupancyMap::ComputeGutterTexelsFromGutterSamples ( )
inline

◆ Initialize() [1/2]

void UE::Geometry::FImageOccupancyMap::Initialize ( FImageDimensions  DimensionsIn,
const FImageTile TileIn,
int32  SamplesPerPixel = 1 
)
inline

◆ Initialize() [2/2]

void UE::Geometry::FImageOccupancyMap::Initialize ( FImageDimensions  DimensionsIn,
int32  SamplesPerPixel = 1 
)
inline

◆ InitializePixelSampler()

void UE::Geometry::FImageOccupancyMap::InitializePixelSampler ( const int32  SamplesPerPixelIn)
inlineprotected

Initialize the pixel sampler.

Parameters
SamplesPerPixelInThe desired number of samples per pixel

◆ IsInterior()

bool UE::Geometry::FImageOccupancyMap::IsInterior ( int64  LinearIndex) const
inline
Returns
true if texel sample at this sample linear index is an Interior texel

◆ ParallelProcessingPass()

void UE::Geometry::FImageOccupancyMap::ParallelProcessingPass ( TFunctionRef< TexelValueType(int64 LinearIdx)>  BeginTexel,
TFunctionRef< void(int64 LinearIdx, float Weight, TexelValueType &)>  AccumulateTexel,
TFunctionRef< void(int64 LinearIdx, float Weight, TexelValueType &)>  CompleteTexel,
TFunctionRef< void(int64 LinearIdx, TexelValueType &)>  WriteTexel,
TFunctionRef< float(const FVector2i &TexelOffset)>  WeightFunction,
int32  FilterWidth,
TArray< TexelValueType > &  PassBuffer 
) const
inline

◆ TexelNumSamples()

int32 UE::Geometry::FImageOccupancyMap::TexelNumSamples ( int64  LinearIndex) const
inline
Returns
number of interior samples for the texel at this image linear index.

Member Data Documentation

◆ BorderTexel

constexpr int8 UE::Geometry::FImageOccupancyMap::BorderTexel = 2
staticconstexpr

◆ BorderTexels

TArray64<TTuple<int64, int64> > UE::Geometry::FImageOccupancyMap::BorderTexels

Set of Border Texels, Pair is <LinearIndexOfBorderTexel, LinearIndexOfNearestInteriorTexel>, so Border can be filled by directly copying from source to target.

◆ bParallel

bool UE::Geometry::FImageOccupancyMap::bParallel = true

◆ Dimensions

FImageDimensions UE::Geometry::FImageOccupancyMap::Dimensions

Image Dimensions

◆ EmptyTexel

constexpr int8 UE::Geometry::FImageOccupancyMap::EmptyTexel = 0
staticconstexpr

◆ GutterSize

int32 UE::Geometry::FImageOccupancyMap::GutterSize = 4

Width of the gutter. This is actually multiplied by the diagonal length of a texel, so the gutter is generally larger than this number of pixels

◆ GutterTexel

constexpr int8 UE::Geometry::FImageOccupancyMap::GutterTexel = 3
staticconstexpr

◆ GutterTexels

TArray64<TTuple<int64, int64> > UE::Geometry::FImageOccupancyMap::GutterTexels

Set of Gutter Texels. Pair is <LinearIndexOfGutterTexel, LinearIndexOfNearestInteriorTexel>, so Gutter can be filled by directly copying from source to target.

◆ InteriorTexel

constexpr int8 UE::Geometry::FImageOccupancyMap::InteriorTexel = 1
staticconstexpr

◆ PixelSampler

FGridSampler UE::Geometry::FImageOccupancyMap::PixelSampler = FGridSampler(1)

◆ TexelInteriorSamples

TArray64<int32> UE::Geometry::FImageOccupancyMap::TexelInteriorSamples

Count of interior samples for each texel in Tile. Size = Tile.GetWidth() x Tile.GetHeight().

◆ TexelQueryTriangle

TArray64<int32> UE::Geometry::FImageOccupancyMap::TexelQueryTriangle

Integer/Triangle ID for each sample in Tile. Size = Tile.GetWidth() x Tile.GetHeight() x SamplesPerPixel.

◆ TexelQueryUV

TArray64<FVector2f> UE::Geometry::FImageOccupancyMap::TexelQueryUV

UV for each sample in Tile. Size = Tile.GetWidth() x Tile.GetHeight() x SamplesPerPixel.

◆ TexelQueryUVChart

TArray64<int32> UE::Geometry::FImageOccupancyMap::TexelQueryUVChart

UV Chart ID for each texel in Tile. Only set if UVSpaceMeshTriCharts is provided Size = Tile.GetWidth() x Tile.GetHeight().

◆ TexelType

TArray64<int8> UE::Geometry::FImageOccupancyMap::TexelType

Classification of each sample in Tile. Size = Tile.GetWidth() x Tile.GetHeight() x SamplesPerPixel.

◆ Tile

FImageTile UE::Geometry::FImageOccupancyMap::Tile

The documentation for this class was generated from the following file: