Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Issue reading pixel values of HDR UTexture2D

I've been working with using images as heightmaps, by reading individual pixel values of the UTexture2D object and creating a procedural mesh based on that. However, I've hit a limitation, as a regular image with 8-bits per-channel cannot hold precise enough values to create a proper landscape. So I'm trying to work with HDR images, and I've created a few HDR images and set their compression mode to HDR (RGB, no sRGB).

However, I can't figure out how to modify my code to properly read the data when it's compressed with this method.

This is the function I was using to read the data before:

 void AProceduralActor::ParseUTexture2DToFColorArray(UTexture2D * HeightMap, TArray<FColor> &ColorArray, FIntVector2D &WidthHeight) {
     FTexture2DMipMap* HeightMipMap = &HeightMap->PlatformData->Mips[0];
     FByteBulkData* RawImageData = &HeightMipMap->BulkData;
     FColor* FormattedImageData = static_cast<FColor*>(RawImageData->Lock(LOCK_READ_ONLY));
     WidthHeight.X = HeightMipMap->SizeX;
     WidthHeight.Y = HeightMipMap->SizeY;
     const int32 TotalTextureSize = WidthHeight.X * WidthHeight.Y;
     auto stride = (int32)(sizeof(int8) * 4);
     FMemory::Memcpy(ColorArray.GetData(), FormattedImageData, TotalTextureSize * stride);

I thought that I might be able to use an FLinearColor pointer instead of FColor, and then change the stride so that the correct memory would be copied, but I still seem to get incorrect values for pixels. My ultimate goal is to populate a TArray with FLinearColors with the values from the texture, to use as values for vertex locations.

Product Version: UE 4.15
more ▼

asked May 31 '17 at 01:14 PM in C++ Programming

avatar image

303 8 7 30

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question