Knowledge Base: Using SceneViewExtension to Extend the Rendering System

Using SceneViewExtension to Extend the Rendering System
Article written by Jon C.
Frequently, we receive requests for guidance on how to introduce new rendering passes into the engine, and in particular how to achieve …

https://dev.epicgames.com/community/learning/knowledge-base/0ql6/unreal-engine-using-sceneviewextension-to-extend-the-rendering-system

10 Likes

When I use this line to retrieve the scene textures, what should I include? I just get an error saying “incomplete type” on FSceneTextures.

1 Like

bump

bump! is it possible to get FSceneTextures& Scenetextures in sceneview extension?

1 Like

yeah sorta, I figured out a few ways of getting to them. The thing is, I’m not sure what state they’re in when I do try to get them. I’ve had some weird artifacts, like scene color texture returning black and white. I’m on a custom engine fork, so I’m not sure if that’s the fork’s fault or not.

I left some of my commented notes in there if it helps anyone.

Here’s one way with RDG:

FRDGTexture* SceneColorRDG = GraphBuilder.FindExternalTexture(InView.Family->RenderTarget->GetRenderTargetTexture());
if (!SceneColorRDG) return;

And here’s some other ways with RHI:

// Fetch Viewport Info Manually (No RDG)
	const FIntRect Viewport = static_cast<const FViewInfo&>(View).ViewRect;
	FVector2f ViewSize = FVector2f(FVector2D(Viewport.Width(), Viewport.Height()));
	FRHITexture* SceneColorRHI = View.Family->RenderTarget->GetShaderResourceTexture();

	// Fetch SceneColor from Scene Textures

	// const FSceneTextureShaderParameters SceneTextures = GetSceneTextureShaderParameters(View);
	// FRDGTextureRef SceneColor = SceneTextures.MobileSceneTextures.GetUniformBuffer()->GetContents()->SceneColorTexture;
	// Convert SceneColor to an FRHITexture*
	// FRHITexture* SceneColorRHI = SceneColor->GetRHI();
	*/


	if (!SceneColorRHI)
	{
		UE_LOG(LogTemp, Error, TEXT("SceneColorRHI is NULL!"));
		return;
	}

I think I had found one other way at one point, but I can’t find my notes on it. Essentially from the view family or RHI list (might need to be immediate mode), you’ll drill down enough to find an array of render targets. You’ll need to sort out how to determine which render target is which on your own, but I believe they should have named descriptors or debug info.

1 Like