x

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"

Possible Bug? UTexture2D::CreateTransient

I'm creating a texture here:

 SizeX = 64;
 SizeY = 64;
 textureGraph = UTexture2D::CreateTransient(SizeX, SizeY);

Then I'm running this draw function up in blueprint:

 EPixelFormat pixelFormat = textureGraph->PlatformData->PixelFormat;
 FTexture2DMipMap* graphMipMap = &textureGraph->PlatformData->Mips[0];
 
 FByteBulkData* rawImageData = &graphMipMap->BulkData;
 uint8 * pImageData = (uint8 *)rawImageData->Lock(LOCK_READ_WRITE);
 
 uint32 TextureWidth = SizeX, TextureHeight = SizeY;
 FColor PixelColor;
     
 PixelColor.R = 0;
 PixelColor.G = 0;
 PixelColor.B = 0; 
     PixelColor.A = 255;
 
 uint32 DrawLineX = 8;
 uint32 DrawLineY = 8;
     
 for (uint32 j = 0; j < DrawLineY; j++){
     for (uint32 i = 0; i < DrawLineX; i++){
             uint8 *pPixelAddress = &pImageData[((j * (TextureWidth)) + (i)) * 4];
             pPixelAddress[0] = PixelColor.B;![alt text][1]
             pPixelAddress[1] = PixelColor.G;
             pPixelAddress[2] = PixelColor.R;
             pPixelAddress[3] = PixelColor.A;
     }
 }
 
 textureGraph->PlatformData->Mips[0].BulkData.Unlock();
 textureGraph->UpdateResource();
 
 
 return textureGraph;

Just trying to create a small little box for now so I can later make them into a graph or something across the static mesh. Originally I was just changing the whole pixels but by going this far down I was hoping to be able to see what was going on in the memory viewer.

I've noticed that when I use blueprint to set this texture to the material on the static mesh it was doubling the amount of pixels it was going in the Y direction, But leaving white space in between and the X direction was being halved. While the whole material seemed to be 16x16 pixels even though I set it as a 64x64. Shown in example 1 alt text

After I tried changing:

 uint8 *pPixelAddress = &pImageData[((j * (TextureWidth)) + (i)) * 4];

to this:

 uint8 *pPixelAddress = &pImageData[((j * (TextureWidth/2)) + (i*2)) * 4];

alt text

So changing that I managed to draw a box but it is the wrong colour. And clearly It's still a 16x16 texture. I'll go ahead and throw in the images of the blueprint as well. alt text

alt text

I'm assuming the problem is coming from the Pixel Format or the Create Transient function. Sorry for bad variable names and for generally having odd formatting before anyone shoots me, I've just been trying a lot of different things to test this and it left a lot of trash everywhere and it's my first time asking a question like this. :)

Product Version: Not Selected
Tags:
example1.png (709.8 kB)
example2.png (743.9 kB)
example3.png (279.3 kB)
example4.png (466.2 kB)
more ▼

asked Nov 12 '14 at 11:46 AM in C++ Programming

avatar image

Desendos
1 1 1 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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