How to make photography mechanic in Unreal C++ integrated with Widget blueprints

41 views Asked by At

In blueprint, I setup a system where a WBP individual photo had an image, with a masterialinstancedynamic on it, which was being set whenever I created the widget based on a texture target. This is to make a camera system for taking pictures. Im trying to recreate it in code, and Im properly calling Scene capture, and storing the texturetarget in an array of textargets2ds,

    camera->SceneCaptureComponent->TextureTarget = TempRenderTarget;

    // Capture the scene
    camera->SceneCaptureComponent->CaptureScene();

    //// Store the captured texture in the array
    PhotoGallery[MaxFilm - CurrentFilm] = camera->SceneCaptureComponent->TextureTarget;

Then when I create my widget for the gallery, I called this in native construct to set it up. (Image1 is bound properly to the widget blueprint)

PhotoGalleryMaterial = UMaterialInstanceDynamic::Create(Image1->GetDynamicMaterial(), this);
    Image1->SetBrushFromMaterial(PhotoGalleryMaterial);

    UpdatePhotoGallery();

Then finally, in UpdatePhotoGallery, Im setting the texture target value to the photo I took (just one element for testing)

    PhotoGalleryMaterial->SetTextureParameterValue("PhotoMaterial_Inst", Cast<UTexture2D>(PhotoGallery[0]));

The widget for the photo is just blank. Went through breakpoints and values seem to be fine, im pretty sure its the creation of the materials, material instances that are wrong. I have the material created with a texture param of texturetar2ds, which I thought calling SetTextureParameterValue with the name of the parameter would work, but it isnt.

I've tried all of the above, with dynamically creating the material instances, loading them from the files themselves and nothing seems to work. Any help is appreciated, thank you.

0

There are 0 answers