Download

How to render custom shader to render target after 4.23

Hi,

I want to render a custom shader to a render target. I have found a tutorial : https://docs.unrealengine.com/en-US/…art/index.html

but the problem is SetRenderTaret function has been removed since 4.23. In the document, it recommands using BeginRenderPass to replace. But I can’t figure out how to use it.


FRHIRenderPassInfo passInfo(OutputRenderTargetResource->GetRenderTargetTexture(), ERenderTargetActions::LoadOpMask);
RHICmdList.BeginRenderPass(passInfo, TEXT("test"));

this will trigger a breakpoint : Ensure condition failed: Store != ERenderTargetStoreAction::EMultisampleResolve || Entry.RenderTarget->GetNumSamples() > 1

I set the render target using blueprint in editor.

Is there any one can give me some examples about how to using BeginRenderPass?

Thank you very much!

Hey,

That global shader is in the engine even in UE 4.23. So you can for sure check the source code:



FRHIRenderPassInfo RPInfo(RenderTargetTexture, ERenderTargetActions::DontLoad_Store, OutTextureRenderTargetResource->TextureRHI);
RHICmdList.BeginRenderPass(RPInfo, TEXT("DrawUVDisplacement"));

Chek that here: https://github.com/EpicGames/UnrealEngine/blob/4.23.1-release/Engine/Plugins/Compositing/LensDistortion/Source/LensDistortion/Private/LensDistortionRendering.cpp#L184

Enjoy

Hi, Ale_32

Thank you for your reply, that’s really helpful.

And I also has other problem about how to draw a simple quad on the render target.

In the LensDistortionRendering.cpp it use:


// Draw grid.
uint32 PrimitiveCount = kGridSubdivisionX * kGridSubdivisionY * 2;
RHICmdList.DrawPrimitive(0, PrimitiveCount, 1);

to draw the grid. And in the post:

it uses:
/


/ Setup the vertices
FVector4 Vertices[4];
Vertices[0].Set(-1.0f, 1.0f, 0, 1.0f);
Vertices[1].Set(1.0f, 1.0f, 0, 1.0f);
Vertices[2].Set(-1.0f, -1.0f, 0, 1.0f);
Vertices[3].Set(1.0f, -1.0f, 0, 1.0f);

// Draw the quad
DrawPrimitiveUP(RHICmdList, PT_TriangleStrip, 2, Vertices, sizeof(Vertices[0]));

but DrawPrimitiveUP function has been removed since 4.21.

And finally, I get the answer from here:
https://forums.unrealengine.com/community/community-content-tools-and-tutorials/1560965-shadersplus-infrastructure-for-custom-shaders