Download

SetTextureParameterValue not working?

This code just doesn’t seem to work… more specifically the “SetTextureParameterValue” part, everything else works as intended.



UMaterialInstanceDynamic* MeshCompMat = Cast<UMaterialInstanceDynamic>(MeshComp->GetMaterial(0));
if (MeshCompMat)
{
	UTexture* TextureSample;
	if (MeshCompMat->GetTextureParameterValue(TextureSampleName, TextureSample))
	{
		UTextureRenderTarget2D* TextureToRenderTarget = Cast<UTextureRenderTarget2D>(TextureSample);
		UMaterialInstanceDynamic* NewMaterial = UKismetMaterialLibrary::CreateDynamicMaterialInstance(World, NewMaterialInstance);
		NewMaterial ->SetTextureParameterValue(TextureSampleName, TextureToRenderTarget);

		UKismetRenderingLibrary::DrawMaterialToRenderTarget(World, TextureToRenderTarget, NewMaterial);
	}
}


Goal: i would like to copy the TextureSampleParameter value from the MeshCompMat to a TextureSampleParameter within NewMaterial.

Outcome: TextureSampleParameter within NewMaterial is always blank.

I’m using UE4.15.3