# Really need help with textures! - Please can someone tell me how to go about this?

**URL:** <https://forums.unrealengine.com/t/really-need-help-with-textures-please-can-someone-tell-me-how-to-go-about-this/14836>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [November 8, 2014, 1:35am UTC](https://forums.unrealengine.com/t/really-need-help-with-textures-please-can-someone-tell-me-how-to-go-about-this/14836 "2014-11-08T01:35:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fredrum](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fredrum](https://forums.unrealengine.com/u/Fredrum)\
**Post date:** [November 8, 2014, 1:35am UTC](https://forums.unrealengine.com/t/really-need-help-with-textures-please-can-someone-tell-me-how-to-go-about-this/14836/1 "2014-11-08T01:35:35Z")

</div>

I am new to UE but I think that I have read every thread here resulting from a ‘texture’ search now and still can’t figure out how this should be done.

**The Goa** l,  
to create my own texture object that I will continuously update with streaming per frame data. I will have to roll this myself as I need the full control.  
This will get attached to simple color shaders and onto simple geometry ‘screens’ that gets spawned by the player (with new texture stream sources).

**Where I’m at** ,  
I have managed to create an Actor derived class that that gets a UTexture2D as a subcomponent. I managed to fill this with a color of my choosing.

**What I’m asking for help about** ,  
**1.** I don’t understand if this is how I should go about creating this texture class, for example should it really be derived off Actor?  
(I do need to be able to refresh continuously over time so that’s why I thought that was the right thing to do but now _the texture seems locked as a subcomponent_)  
**2.** I don’t understand how I should attach this texture to an shader/material.

(For the texture-refresh I will look into [this](https://answers.unrealengine.com/questions/31658/best-way-to-modify-a-texture-every-frame.html))  
(For texture attach I have tried to follow [this](https://forums.unrealengine.com/showthread.php?33446-Creating-UTexture-from-data-in-code-making-it-a-material-and-adding-it-to-a-mesh&highlight=custom+texture)without success)

This is my class I have it now, (texture bits pseudo code)

.h

```auto

class PROGRAMMINGEXMPL1_API ABasics : public AActor
{
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = My_Basics)
		UTexture2D *mTexture;

                FColor * mMipData;

	virtual void BeginPlay() override; // using this just now for testing
}

```

.cpp

```auto

void ABasics::BeginPlay()
{
	Super::BeginPlay();

	// Filling in the texture. <- https://answers.unrealengine.com/questions/48217/why-does-my-created-utexture2d-suddenly-become-inv.html
	FColor tmpCol(255, 0, 255, 128);

	mTexture = UTexture2D::CreateTransient((int32)1024, (int32)1024, PF_B8G8R8A8);
	mTexture->Filter = TextureFilter::TF_Nearest;

	// Lock the texture so it can be modified
	mMipData = static_cast<FColor*>(mTexture->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE));

	// Create base mip from the pixel color array
	for (int32 y = 0; y < mTexture->PlatformData->Mips[0].SizeY; y++)
	{
		for (int32 x = 0; x < mTexture->PlatformData->Mips[0].SizeX; x++)
		{
			int32 curPixelIndex = (y * mTexture->PlatformData->Mips[0].SizeX) + x;
			//mMipData[curPixelIndex] = sourceColors[curPixelIndex];
			mMipData[curPixelIndex] = tmpCol;
		}
	}

	//// Unlock the texture
	mTexture->PlatformData->Mips[0].BulkData.Unlock();
	mTexture->UpdateResource();

	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Got thru BeginPLay()"));
}

```
