Hi, I am trying to create mesh to show the scenecapture. I successfully get the captureScene, but i cant show the texture on materials. it seems i should use another first parameter of SetTextureParameterValue function. Which one should use?
void ATestPortal::BeginPlay()
{
Super::BeginPlay();
TextureRenderTarget2D = NewObject<UTextureRenderTarget2D>(this, UTextureRenderTarget2D::StaticClass());
TextureRenderTarget2D->InitAutoFormat(1920, 1080);
TextureRenderTarget2D->UpdateResourceImmediate(true);
SceneCaptureComponent2D->TextureTarget = TextureRenderTarget2D;
SceneCaptureComponent2D->CaptureScene();
UMaterialInterface* M = MeshComponent->GetMaterial(0);
MaterialInstance = UMaterialInstanceDynamic::Create(M, this, TEXT("MaterialInstance"));
UMaterialExpressionTextureSample* TextureSample = NewObject<UMaterialExpressionTextureSample>(this);
TextureSample->SamplerType = EMaterialSamplerType::SAMPLERTYPE_LinearColor;
TextureSample->Texture = TextureRenderTarget2D;
MaterialInstance->SetTextureParameterValue(TEXT("Image"), SceneCaptureComponent2D->TextureTarget);
//MaterialInstance->SetVectorParameterValue(TEXT("Color"), FLinearColor::Red);
MeshComponent->SetMaterial(0, MaterialInstance);
}