Welcome, Guest.
Username: Password: Remember me

TOPIC: How to enable ReShade for secondary render target

How to enable ReShade for secondary render target 1 year 8 months ago #1

Hi,
I am the developer of the Extended Video Export mod for GTA V.
Video exporting in Rockstar Editor uses an offscreen render target, and ReShade effects are not enabled on that target.
I need to know how to enable ReShade for the offscreen render target.
So far I've been able to hook into the game functions and get access to the D3D11 rendering pipeline.
The administrator has disabled public write access.

How to enable ReShade for secondary render target 1 year 8 months ago #2

ReShade always renders to the backbuffer and caches the texture, so there is no way to change it (unless the swapchain is reset).
Cheers, crosire =)
The administrator has disabled public write access.
The following user(s) said Thank You: Nightingale

How to enable ReShade for secondary render target 1 year 8 months ago #3

Thank you for your response. So I guess creating a fake swap chain bound to my alternative render target and presenting it would do the trick? I'll try it later today and see if it works.
The administrator has disabled public write access.

How to enable ReShade for secondary render target 1 year 8 months ago #4

Yes, that should work. ReShade creates an instance for each swapchain it can find, so using it to present your render target to an invisible window or similar would cause it to render the post-processing effects over it. You'll have to get the results back somehow though, which could be difficult after the present call finished, depending on the presentation technique used. Another way would be to overwrite the IDXGISwapChain::GetBuffer method and have it return your offscreen target on the custom swapchain, so ReShade renders to it directly.
Cheers, crosire =)
The administrator has disabled public write access.
The following user(s) said Thank You: Nightingale

How to enable ReShade for secondary render target 1 year 8 months ago #5

Using a new swap chain with a hidden window did the job. The only problem is that ReShade reloads everything for the new swap chain and thus effects are disabled until all shaders are loaded and the initial ReShade message is visible on the buffer. Is there a way to wait for ReShade to load everything and hide the message?
Here is a frame from captured video: imgur.com/GuuUgGu
The administrator has disabled public write access.

How to enable ReShade for secondary render target 1 year 8 months ago #6

Update: I managed to fix the problem by resizing the hidden swap chain whenever the original swap chain got resized, and doing a present() on it. This way the ReShade initialization is done before exporting video begins. Thank you for your help crosire.
Last Edit: 1 year 8 months ago by Nightingale.
The administrator has disabled public write access.

How to enable ReShade for secondary render target 1 year 8 months ago #7

Glad to hear!
Cheers, crosire =)
The administrator has disabled public write access.

How to enable ReShade for secondary render target 1 year 8 months ago #8

I was wrong. It still initializes ReShade as soon as exporting video starts and the initialization message is exported too.
The administrator has disabled public write access.

How to enable ReShade for secondary render target 1 year 8 months ago #9

ReShade has to reinitialize each time the swapchain is created/reset. There is no way around that. You'll have to create the swapchain earlier before exporting or add a delay.
Cheers, crosire =)
Last Edit: 1 year 8 months ago by crosire.
The administrator has disabled public write access.

How to enable ReShade for secondary render target 1 year 8 months ago #10

You could just render a couple of seconds worth of black screen, then just crop it off in the end.
The administrator has disabled public write access.

How to enable ReShade for secondary render target 1 year 8 months ago #11

The problem is that it seems that ReShade doesn't initialize two swap chains at once. I would have to wait until the main swap chain is initialized, then call present on the other swap chain. I fixed it by calling present on secondary swap chain (width DXGI_PRESENT_TEST flag) whenever the present is called on the primary swap chain. I don't know about any performance issues of this hack, but it seems to be working perfectly right now.
Last Edit: 1 year 8 months ago by Nightingale.
The administrator has disabled public write access.

How to enable ReShade for secondary render target 1 year 8 months ago #12

ReShade does lazy initialization over the course of multiple present calls (at least as many calls as effects files to load). Creation/Reset of a swapchain effectively only sets a flag so ReShade knows to start reloading on the next couple of presents.
Cheers, crosire =)
Last Edit: 1 year 8 months ago by crosire.
The administrator has disabled public write access.