I need to send a pre-sized array of normalized floats to a material, and rather than using scalar or vector parameters the best way to do this would be to send the data via a Texture. I’ve got as far as creating the texture (I believe), and sending it to the material. The material samples it as it needs to.
This is where I’m at so far:
// Create Data Buffer
// Don't ever save it
UTexture2D* NewDataBuffer = UTexture2D::CreateTransient(MAX_CHARGE_ABILITIES, 1, PF_G8);
ASSERTV(NewDataBuffer != nullptr, TEXT("Invalid Data Buffer"));
NewDataBuffer->Filter = TextureFilter::TF_Nearest;
NewDataBuffer->SRGB = false;
NewDataBuffer->CompressionSettings = TextureCompressionSettings::TC_Grayscale;
NewDataBuffer->CompressionNoAlpha = true;
NewDataBuffer->MipGenSettings = TextureMipGenSettings::TMGS_NoMipmaps;
NewDataBuffer->AddressX = TextureAddress::TA_Clamp;
NewDataBuffer->AddressY = TextureAddress::TA_Clamp;
// Actually creates the GPU resource?
NewDataBuffer->UpdateResource();
NewDataBuffer->RefreshSamplerStates();
What I want to do now is ‘set’ the pixels to the values in an array of floats. It’s so I can pack a bunch of progress bars into a single material.
error C2664: 'UECGame_PieMenu::Update::EURCMacro_void::EURCMacro_void(UECGame_PieMenu::Update::EURCMacro_void &&)': cannot convert argument 1 from 'FRHITexture' to 'const TRefCountPtr<FRHITexture2D> &'
Reason: cannot convert from 'FRHITexture' to 'const FTexture2DRHIRef'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called