Is texture compression at runtime supported?

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;
	}

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

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.

Any update on this?

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

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