Download

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

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 Goal,
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)
(For texture attach I have tried to follow this without success)

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

.h


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


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()"));
}