UImportanceSamplingLibrary::MakeImportanceTexture
#include "Kismet/ImportanceSamplingLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Builds an FImportanceTexture from a 2D texture, precomputing cumulative distribution functions per row and per pixel so ImportanceSample can later draw points proportional to the chosen weighting channel.
Caveats & Gotchas
- • Only accepts RGBA8-format textures — other pixel formats will not produce valid importance data.
- • Precomputation reads back and processes the full texture (capped internally to 1024x1024), so this is not something to call every frame; build the FImportanceTexture once and reuse it for repeated ImportanceSample calls.
- • Requires the texture's CPU-accessible mip data to be available; textures that have had their CPU copy stripped (common in cooked builds without mip streaming settings adjusted) will fail to build correctly.
Signature
static FImportanceTexture MakeImportanceTexture(UTexture2D *Texture, TEnumAsByte<EImportanceWeight::Type> WeightingFunc) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Texture | UTexture2D* | Source texture to build the importance data from. Must be RGBA8 format. | — |
| WeightingFunc | TEnumAsByte<EImportanceWeight::Type> | How to convert texture data into probability weights (Luminance, Red, Green, Blue, or Alpha). | — |
Return Type
FImportanceTexture Example
Build an importance texture from a light cookie C++
FImportanceTexture ImportanceTex = UImportanceSamplingLibrary::MakeImportanceTexture(MyTexture, EImportanceWeight::Luminance);
// Reuse ImportanceTex across many ImportanceSample calls See Also
Tags
Version History
Introduced in: 5.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?