Announcement

Collapse
No announcement yet.

reading texture from memory address?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    reading texture from memory address?

    So I know now that UE4 doesn't support reading movies to 3D textures (I don't mean to load movies to cinematic cut scenes), but need this to happen or I can't use UE4 for my project. So, I'm wondering if anyone can help point in me in the right direction for reading an image to 3D texture from image handle, or image location, already in memory. I know it's possible in straight c++, but am so new at UE4 programming that I don't know enough about the API and intricate texture calls to make this happen.

    So... what do you think community? How can I make this happen?

    #2
    Did this in the rough Coherent UI plugin I created:

    Code:
        UTexture2D* Texture = <YourTexture>;
    
        const size_t Size = TextureWidth * TextureHeight * sizeof(uint32);
    
        uint32* Src = (uint32*)<YourSource>;
    
        uint32* Dest = (uint32*)Texture->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
    
        FMemory::Memcpy(Dest, Src, Size);
    
        Texture->PlatformData->Mips[0].BulkData.Unlock();
    
        Texture->UpdateResource();
    The texture was just a UTexture2D created using thusly:
    Code:
        // Create a NEW texture
        ViewTexture = UTexture2D::CreateTransient(Width, Height, PF_B8G8R8A8);
        
        if (ViewTexture)
        {
            ViewTexture->AddToRoot();
            ViewTexture->UpdateResource();
        }
    In this case, the source and destination were in the same format.
    The full source will have other examples I'm sure.
    Rule#21: Be polite, be professional, but have a plan to kill everyone you meet.

    Comment

    Working...
    X