Hi,I am modifying the engine resource in UE 4.22.I added a mesh Pass to draw clouds to a new render target and it worked,then i trying to blur the texture by compute shader like what Sea of Thieves did.
void FSceneRenderTargets::AllocateCloudTarget(FRHICommandList& RHICmdList)
{
//FIntPoint QuarterSize(BufferSize.X / 2, BufferSize.Y / 2);
FPooledRenderTargetDesc Desc(FPooledRenderTargetDesc::Create2DDesc(BufferSize, PF_B8G8R8A8, DefaultColorClear, TexCreate_None, TexCreate_RenderTargetable | TexCreate_ShaderResource | TexCreate_UAV, true));
Desc.NumSamples = GetNumSceneColorMSAASamples(CurrentFeatureLevel);
//Desc.Flags |= GFastVRamConfig.SceneDepth;
GRenderTargetPool.FindFreeElement(RHICmdList, Desc, CloudRT, TEXT("CloudRT"));
}
This is how i create the RenderTarget like most Allocator in SceneRenderTarget.cpp do,notice that I use flag RenderTargetable | ShaderResource | UAV ,but when i past this to CS as followed,it doesn’t work.
FTexture2DRHIRef CloudTex2D = (FTexture2DRHIRef&)SceneContext.CloudRT->GetRenderTargetItem().TargetableTexture;
FShaderResourceViewRHIRef TextureSRV = RHICreateShaderResourceView(CloudTex2D,0,1,PF_B8G8R8A8);
The compile work in both CPP and HLSL are ok,but in RenderDoc it show no resource.
I tried to pass the FTexture2DRHIRef as UAV to the CS,it worked.I also tried create a new texture2d to bind SRV to CS,it works too.Anyone knows what i did wrong here?Thanks in advance!