Skip to content

Instantly share code, notes, and snippets.

View Anruin's full-sized avatar
🏠
Working from home

Hackerman Me Anruin

🏠
Working from home
View GitHub Profile
@Anruin
Anruin / UE4_GenerateMipmaps.cpp
Last active April 10, 2024 03:51
CPU code used to generate dynamic mipmaps for UE4 dynamic UTexture2D objects.
// Copyright 2021 Impossibility Labs Inc. https://github.com/ArtheonVR.
// Based on: https://answers.unrealengine.com/questions/607129/how-do-you-generate-mips-at-runtime.html
void FAsyncTaskDownloadTexture::GenerateMipmaps() const {
const int32 Width = Texture->GetSizeX();
const int32 Height = Texture->GetSizeY();
// Texture bytes.
TArray<uint8> TextureByteArray;
TextureByteArray.AddUninitialized(Texture->PlatformData->Mips[0].BulkData.GetElementCount());