Custom renderer

Hi,

I’m trying to get a feel on how to create a custom render pass. I don’t really know where to start. I’ve read the documentations Threaded Rendering in Unreal Engine | Unreal Engine 5.2 Documentation and Graphics Programming for Unreal Engine | Unreal Engine 5.2 Documentation. I don’t have experience in rendering and I would like to dig into it and get it. When I read the documentation, it explains what are the important graphics programming classes and the important functions that are called by which thread. It feels like I can call these functions by myself in a custom script and then modify the rendering process behaviour. As an exercice, I would like to create my own class, call all these important functions in it, reproduce the exact same behaviour the renderer has now and make the engine/my project use my custom renderer.

Can I program this code in my project? Which class should I extend? How should I make the project use my renderer?

When this will be done, I will try to modify the renderer. But I’ll think about that later.

As for why I want to learn this, it’s because I’m trying to learn the rendering process, so that I can evaluate by myself what I can and can’t do with it and why.

Thank you :slight_smile:

Start by looking in Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp at (line 782 in 4.10 branch, same file for the rest but can be at a different line)

void FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate& RHICmdList)

This is the place where you can see what pass is rendered and when.

I put a breakpoint at the beginning of the function

void FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate& RHICmdList)

and went through it step by step. I’m starting to feel a bit more comfortable than before with unreal deferred rendering.
If I want to create my custom renderer, do I create my own FSceneRenderer ?

The renderer is created in SceneRendering.cpp line 1660

FSceneRenderer* SceneRenderer = FSceneRenderer::CreateSceneRenderer(ViewFamily, Canvas->GetHitProxyConsumer());

Then I guess I would have to modify this function so that it creates and returns my custom renderer. (SceneRendering.cpp line 1383 to 1394)

FSceneRenderer* FSceneRenderer::CreateSceneRenderer(const FSceneViewFamily* InViewFamily, FHitProxyConsumer* HitProxyConsumer)
{
	bool bUseDeferred = InViewFamily->Scene->ShouldUseDeferredRenderer();
	if (bUseDeferred)
	{
		return new FDeferredShadingSceneRenderer(InViewFamily, HitProxyConsumer);
	}
	else
	{
		return new FForwardShadingSceneRenderer(InViewFamily, HitProxyConsumer);
	}
}

I’m wondering if that is the way to modify the renderer or if there is a cleaner way of doing it?

Actually I think I’m going to change tactics a bit. My goal is to use unreal’s powers, not replace their renderer with mine.

have you achieved anything in this question?
Actually i want to replace their render, just need a starting point