# Is texture compression at runtime supported?

**URL:** <https://forums.unrealengine.com/t/is-texture-compression-at-runtime-supported/352144>\
**Category:** Asset Creation\
**Tags:** modules, compression, unreal-engine, UE4, question\
**Created:** [March 29, 2016, 1:06pm UTC](https://forums.unrealengine.com/t/is-texture-compression-at-runtime-supported/352144 "2016-03-29T13:06:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![eyesiah](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eyesiah](https://forums.unrealengine.com/u/eyesiah)\
**Post date:** [March 29, 2016, 1:06pm UTC](https://forums.unrealengine.com/t/is-texture-compression-at-runtime-supported/352144/1 "2016-03-29T13:06:57Z")

</div>

Hello,

I have written some code that creates a texture at runtime by modifiying pixel values, and then compresses the texture to the DXT format. This works fine in the Editor build, but when I compile my game for the Development or Shipping config, I get the following compile error:

```
2>LINK : fatal error LNK1181: cannot open input file 'C:\work\Epic Games\4.10\Engine\Binaries\Win64\UE4-TextureCompressor.lib'

```

It appears that this module is in the “Developer” folder, rather than the “Runtime” or “Editor” folders. What does it mean to be a “Developer” module? How can I compress a texture at runtime? I’ve added the “TextureCompressor” module to the list of PublicDependencyModuleNames in my game project’s .Build.cs file.

For reference, here is my code:

```
	/** Allocate render target for writing uncompressed texture to */
	TArray<FImage> generatedMips;
	FImage &generatedImage = generatedMips[generatedMips.Add(FImage())];
	generatedImage.Init(m_targetTexSize.X, m_targetTexSize.Y, ERawImageFormat::BGRA8);

	FMemory::Memzero(generatedImage.RawData.GetData(), generatedImage.RawData.Num());

/// image generation here
/// ...    

	/** Compress the created texture */
	ITextureCompressorModule* Compressor = &FModuleManager::LoadModuleChecked<ITextureCompressorModule>(TEXTURE_COMPRESSOR_MODULENAME);

	TArray<FImage> CompositeSourceMips;
	TArray<FCompressedImage2D> CompressedMips;
	FTextureBuildSettings BuildSettings;

	BuildSettings.TextureFormatName = TEXT("DXT5");
	BuildSettings.MipGenSettings = TextureMipGenSettings::TMGS_NoMipmaps;

	if (Compressor->BuildTexture(generatedMips, CompositeSourceMips, BuildSettings, CompressedMips))
	{
		UTexture2D *newTex = UTexture2D::CreateTransient(m_targetTexSize.X, m_targetTexSize.Y, PF_DXT5/*m_source->GetPixelFormat()*/);
		newTex->NeverStream = true;

		newTex->CompressionSettings = TextureCompressionSettings::TC_Default;

		FTexture2DMipMap& targetMip = newTex->PlatformData->Mips[0];

		int32 size = targetMip.BulkData.GetBulkDataSize();

		FColor* targetData = static_cast<FColor*>(targetMip.BulkData.Lock(LOCK_READ_WRITE));

		FMemory::Memcpy(targetData, CompressedMips[0].RawData.GetData(), size);

		targetMip.BulkData.Unlock();

		newTex->UpdateResource();

		return newTex;
	}

```

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [March 29, 2016, 3:34pm UTC](https://forums.unrealengine.com/t/is-texture-compression-at-runtime-supported/352144/2 "2016-03-29T15:34:59Z")

</div>

It’s probably the case, you could add that module to build it self on non-editor build one way or another, but problem is by EULA, you can’t include editor code/module in to the game and i don’t know if that module counts as editor module if it build only in editor build (probably yes). Epic probably didn’t thouth somebody would want to do something like that on runtime

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_cc989825](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cc989825](https://forums.unrealengine.com/u/anonymous_user_cc989825)\
**Post date:** [April 7, 2016, 10:53pm UTC](https://forums.unrealengine.com/t/is-texture-compression-at-runtime-supported/352144/3 "2016-04-07T22:53:15Z")

</div>

I love to hear more about what UE4 offers in terms of runtime texture compression. Many games require combining or altering textures at runtime, and it saves a lot of memory to compress the results down.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_cc989825](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cc989825](https://forums.unrealengine.com/u/anonymous_user_cc989825)\
**Post date:** [June 9, 2016, 4:15pm UTC](https://forums.unrealengine.com/t/is-texture-compression-at-runtime-supported/352144/4 "2016-06-09T16:15:45Z")

</div>

Any update on this?

---

<div class="post-metadata">

**Author:** ![Anonymous\_e5d5c0bf7d300728867097ff79906dbe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_e5d5c0bf7d300728867097ff79906dbe](https://forums.unrealengine.com/u/Anonymous_e5d5c0bf7d300728867097ff79906dbe)\
**Post date:** [April 22, 2018, 7:18pm UTC](https://forums.unrealengine.com/t/is-texture-compression-at-runtime-supported/352144/5 "2018-04-22T19:18:10Z")

</div>

Any update ?  
Can I make a manual code to do this ?

---

<div class="post-metadata">

**Author:** ![Alex.Kang](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alex.Kang](https://forums.unrealengine.com/u/Alex.Kang)\
**Post date:** [January 6, 2021, 5:58pm UTC](https://forums.unrealengine.com/t/is-texture-compression-at-runtime-supported/352144/6 "2021-01-06T17:58:52Z")

</div>

> **[TextureRuntimeImporter in Code Plugins - UE Marketplace](https://www.unrealengine.com/marketplace/en-US/product/textureruntimeimporter/questions)**
>
> Runtime import Texture for ue4

---

<div class="post-metadata">

**Author:** ![somawheels](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@somawheels](https://forums.unrealengine.com/u/somawheels)\
**Post date:** [May 8, 2022, 11:29pm UTC](https://forums.unrealengine.com/t/is-texture-compression-at-runtime-supported/352144/7 "2022-05-08T23:29:50Z")

</div>

bump, anyone know about runtime texture compression?  
I need to compress things at runtime too.
