# Saving UTexture2D to the PF\_R8G8 pixel format

**URL:** <https://forums.unrealengine.com/t/saving-utexture2d-to-the-pf-r8g8-pixel-format/2221048>\
**Category:** Rendering\
**Tags:** format, unreal-engine, Rendering, CPP, texture-channel\
**Created:** [December 14, 2024, 10:01pm UTC](https://forums.unrealengine.com/t/saving-utexture2d-to-the-pf-r8g8-pixel-format/2221048 "2024-12-14T22:01:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![OctoberIC](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OctoberIC](https://forums.unrealengine.com/u/OctoberIC)\
**Post date:** [December 14, 2024, 10:01pm UTC](https://forums.unrealengine.com/t/saving-utexture2d-to-the-pf-r8g8-pixel-format/2221048/1 "2024-12-14T22:01:20Z")

</div>

Creating and writing to UTexture2D in the PF\_R8G8 pixel format at runtime works well (for direct color lookup onto 256 x 256 textures, R = UV.x, G = UV.y). But I can’t get to save them without them losing their format.

```auto
texture->GetPlatformData()->PixelFormat = EPixelFormat::PF_R8G8;

texture->GetPlatformData()->Mips[0]->BulkData.Lock(LOCK_READ_WRITE);

void* data_ptr = texture->GetPlatformData()->Mips[0]->BulkData.Realloc(sizeof(uint16) * source._num);

memcpy(data_ptr, source, sizeof(uint16) * source_num);

texture->GetPlatformData()->Mips[0].BulkData.Unlock();
texture->UpdateResource();

```

This works fine. But at some point I have to write the following so the texture is saved across sessions :

```auto
texture->Source.Init(height, height, 1, 1, ETextureSourceFormat::TSF_BGRA8, (uint8*)source);

```

Problem is that there is no PF\_R8G8 or seemingly compatible 16 bit format in the ETextureSourceFormat enum.

Any workaround?

---

<div class="post-metadata">

**Author:** ![OctoberIC](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OctoberIC](https://forums.unrealengine.com/u/OctoberIC)\
**Post date:** [May 12, 2025, 10:40pm UTC](https://forums.unrealengine.com/t/saving-utexture2d-to-the-pf-r8g8-pixel-format/2221048/2 "2025-05-12T22:40:11Z")

</div>

It’s been nearly six months and a few dozen crashes dedicated to this later, I still didn’t find a way to save a R8G8 texture asset.

Saving it with the R16F compression settings and changing the pixel format programmatically on startup works in the Editor, but fails in builds because changing cooked static textures’ pixel format simply isn’t enabled.

I’m surprised to have found few posts even mentioning the existence of R8G8 or two channels formats in general given how useful they are to me. Bitmaps with values within 2^16, 2D distance fields, or even pairs of terrain indices used with a side blending weight linear grayscale texture. It’s just a waste to have to use four channels when you only need two, especially with very large textures.
