Render Target Reader / Base class?

I’m having a brain fart here. I have tried several different basis for implementing this custom height map reader with no success

Would sure be nice we could update the wiki / submit edits again hu?

Anyway, I’m curious not only to know what base class this is intended to be used with, but also to know if anyone has modified this at all since the release of ue4.20 which included basic Read Render Target Pixel functions as part of the regular engine functions / blueprint functions.

before someone be like “ocean community project” no thanks. Not interested in it / already looked into it.
They have their own close ended implementation of some sort of reader which doesn’t work for me. I need to mess things up to get it to do what I need reliably for what I need.

Wanted to bump this and also add some clarifications.

The default class to use is Actor.
the include for render target 2d is however obviously missing and must be added to get this to compile.

Not that it does any good, as I cant seem to get it to read anything from any texture material at all.

I’m probably doing something wrong somewhere - probably as simple as not storing the render target in the appropriate variable or not selecting it in the viewport.
it just occurred to me that factually there isn’t anything telling this code that it needs to read the coordinates from the texture I choose - since I haven’t chosen one anywhere…
And, I was 100% correct on that. the new BP created with the new class as the base has a Height-map value you can set from within the level editor.

Not that it works still. the sheer size of the map has the render thread locked 100% of the time of execution… I’ll have to figure out how to implement the non blocking updated buffer correctly.

Anyway, if anyone runs into it again:


#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Runtime/Engine/Classes/Engine/TextureRenderTarget2D.h"
- your generated line instead of #include "C_CustomActor.generated.h" -

UCLASS()
class AHeightMapReader : public AActor
{
    GENERATED_BODY()

    UPROPERTY(Category = HeightMap, EditAnywhere)
        UTextureRenderTarget2D* RenderTarget;

    UFUNCTION(BlueprintCallable, Category = "HeightMap|Update")
        void UpdateBuffer();

    UFUNCTION(BlueprintCallable, Category = "HeightMap|Texture Helper")
        FColor GetRenderTargetValue(float x, float y);

private:

    TArray<FColor> ColorBuffer;

};

I think I came up with a logical way to re-do all of this in a way that actually works.

Custom Actor Class that generates the height-map math.
Save off the “math” result to a render texture adjusted by the bounds of the actor.
Custom Dynamic material with the render texture as displacement - and world location absolute so it can merge with duplication.
Read location height based on code that generated the height-map in the first place.

Basically reversing the order of operations and making sure initial calculations happen on CPU side.
The downside is this cannot really be reactive. there is no talking back to the math function after-all.