[Release] Misc. emulators with depth buffer access
- Boulotaur2024
- Topic Author
Soul Calibur with Marty McFly's Ground Truth AO implementation running in Redream... Now imagine DOA boobs...
This is an attempt at making *every* OpenGL emulator outputting 3D compatible with depth buffer related effects (SSAO, DOF...) in Reshade.
It is focused on OpenGL, as most emulators use that backend (I realize my work could become obsolete really fast once emu devs move to Vulkan but that's another story).
Right now all my code is stored in a separate repository (see my signature) but I fully intend to make a pull request to master at some point.
You'll find instructions below for every supported emulator.
32 bits (compatible with Pcsx2, glideN64) | mega.nz/#!vcsiDI6A!AkGWkVRQkJEelOYa7quAOI1cOxHfU-HuDBcS1CnVrTI |
64 bits (compatible with Redream, Ppsspp, Dolphin...) | mega.nz/#!zUch0ABA!fnOJcjZrjH52LEKpIximPoWMm46QA7e7gBDSwMVdTMw |
Redream : brillant Dreamcast emu (imho). Yes it is payware but I think it *has* a future and everything feels smooth about it
Instructions :
- Install latest Redream
- Install Reshade as you would normally do
- Download and replace your existing Reshade opengl32.dll at the root of your Redream directory with the 64 bits dll provided above
- Run the emulator once to make sure Reshade is working at all and close it
- Make sure to grab Marty qUINT shaders
- Run Redream - press "Home" key to toggle Reshade UI and select "redream" in the "Hacks for custom apps" dropdownlist (Opengl tab)
- In ReShade.ini, create or replace the line starting with PreprocessorDefinitions by this line :
PreprocessorDefinitions=RESHADE_DEPTH_LINEARIZATION_FAR_PLANE=1000.0,RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN=1,RESHADE_DEPTH_INPUT_IS_REVERSED=1,RESHADE_DEPTH_INPUT_IS_LOGARITHMIC=1
Issues :
- Do not ALT + ENTER too much if you have AMD card, the runtime gets lost in the mix...
- It (the depth buffer texture) doesn't adapt to different aspect ratios so for now you have to keep the aspect ratio to "stretched"
Please Log in or Create an account to join the conversation.
- Boulotaur2024
- Topic Author
Pcsx2 : Compatibility is okayish, some games refuse to show depth (ask the devs, nothing I can do to help).
Be prepared for some tweaking. Please read carefully the instructions over here :
reshade.me/forum/general-discussion/5391...-depth-buffer-access
PPSSPP : The same dll (64 bits) also works nicely with PPSSPP :
- Run the 64 bits executable PPSSPPWindows64.exe
- Use the OpenGL Renderer
- Run ppsspp - press "Home" key to toggle Reshade UI and select "ppsspp" in the "Hacks for custom apps" dropdownlist (Opengl tab)
Citra : Citra is also somewhat working. For 8x native resolution enter in Reshade.ini :
[OPENGL]
AppWidth=3200
ForceMainDepthBuffer=0
IsUpscaled=1
AppHeight=1920
AppMode=1
AppName=none
AltDetection=1
If you are interested in getting Reshade working with Citra, ask the devs if they can add an extra texture with the rotated depth buffer.
I had a quick look at their source code and they have a function named "DrawSingleScreenRotated" that would do the job
EDIT : A feature request has been opened (thanx otherman) but I don't think this is going to happen... and he explained in a clear manner why. Which I can understand.
Cemu : Cemu work already with default Reshade but only if you fullscreen to native monitor res (ie. 1080p)
With this mod you can upscale to any res.
Run Cemu - press "Home" key to toggle Reshade UI and select "cemu" in the "Hacks for custom apps" dropdownlist (Opengl tab)
Please Log in or Create an account to join the conversation.
- Nerrel
It also applies one frame too soon, which the developer of GlideN64 says is due to the incorrect buffer being chosen "N64 games allocate at least two color buffers for double-buffering. One buffer is being rendered, other is displayed." It's basically choosing the newly rendered buffer instead of the one that displays a few vertical interrupts later. It needs to use the depth buffer instead.
I'm not sure if an OpenGL mod for buffer selection (like what Thalixte did for D3D) would work or if it's possible to do something like what you've done and use a custom ReShade version that gets depth data from the correct location. The developer of GlideN64 wants to help, he just doesn't know what needs to be done on his end to make ReShade work.
If you could share any speculation or advice I'd appreciate it!
Please Log in or Create an account to join the conversation.
- Boulotaur2024
- Topic Author
But no, unfortunately I have no idea what's going on about that "1 frame too soon" issue (might be 3 more frames btw due to triple buffering...).
I don't have much time these days (wedding and [strike]rat race[/strike] work).
In case you haven't seen I talked about the same problem in PCSX2 here
And here is another example of it in PPSSPP :
- The fact the depth buffer is misaligned if the camera is static is *not* an issue. It probably needs resizing somewhere.
- The fact the depth buffer is misaligned once in motion (see above) is a big problem, for which I have no solution so far.
- Both D3D11 and OpenGL are affected by that issue
- Both AMD and NVIDIA
I tried various things but no luck so far.
I have to go to work now -_-
Crosire, any idea ?
ethereal_intellect wrote: Nice does it work with ps1 emulators or retroarch like in this old video? I don't really have the time to test right now but i'll get to it eventually
Beetle-PSX does not really have z-buffer. What you see on video is an "experimental Z-buffer" that never got released.
And the best I got right now debugging through it is this (Resident Evil, lol) .
So no, no depth buffer for Ps1, until iCatButler decides to implement one (that was never present in the original hardware, btw)
EDIT : same for ePSXe 2.05. I just tried this morning and it produces "flat" depth around the vertices. No usable depth because the ps1 did not have a z-buffer.
Please Log in or Create an account to join the conversation.
- ethereal_intellect
Please Log in or Create an account to join the conversation.
- crosire
TLDR: Emulator does manual render-ahead of frames because emulator reasons (normal GL apps/games don't generaly do that). ReShade selects last depth buffer that was drawn into (because emulator currently renders a frame it will show later in the future), but emulator displays an older frame. Result: ReShade gets color data from old frame (the one being displayed), but depth data from future frame (the one being rendered ahead of time).
Please Log in or Create an account to join the conversation.
- Silveraga
Please Log in or Create an account to join the conversation.
- Nerrel
Please Log in or Create an account to join the conversation.
- crosire
Please Log in or Create an account to join the conversation.
- Nerrel
It works as long as the effect is disabled at startup, then only turned on after ReShade has loaded. On the other hand, MXAO seems to work even if it's enabled at startup, there are no issues there.
Please Log in or Create an account to join the conversation.
- Boulotaur2024
- Topic Author
We solved that one remaining issue (refer to the GitHub thread above).Nerrel wrote: ...
There's a little bit more involved than reading from FBO 0.
Again, refer to the github thread, everything is explained (binary and code changes included).
Please Log in or Create an account to join the conversation.
- Boulotaur2024
- Topic Author
Tags : Dolphin, Reshade, SSAO, MXAO, DOF, MartyMcFly's RT shader
Dolphin now is working and I'm really happy about it !
It was a lot of work mostly to get the depth buffer rendering properly aligned with the backbuffer rectangle.
I had to add and handle an extra pass PS_ResizeDepth for that reason.
Instructions :
- Install latest Dolphin
- Install Reshade as you would normally do
- Download and replace your existing Reshade opengl32.dll at the root of your Dolphin directory with the 64 bits DLL in the first post of this thread:
- In Dolphin, please select OpenGL renderer and activate Immediately present XFB in OpenGL Graphics Configuration -> Hacks to prevent depth buffer flickering (has to be activated per game, I think)
- Download and replace modified qUINT shaders
HERE
: I added an extra pass to handle misalignment issues
- Run Dolphin again and select "dolphin" in the "Hacks for custom apps" dropdownlist - in the Opengl tab in Reshade :
- In ReShade.ini, create (or replace) the following line :
[GENERAL]
PreprocessorDefinitions=RESHADE_DEPTH_LINEARIZATION_FAR_PLANE=1000.0,RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN=0,RESHADE_DEPTH_INPUT_IS_REVERSED=0,RESHADE_DEPTH_INPUT_IS_LOGARITHMIC=0
Notes for MartyMcFly's RT shader :
As I obviously cannot redistribute MartyMcFly's RT shader. Here is what you have to do to fix alignment issue :
- (You should have downloaded my modified qUINT shaders - see above)
- Open qUINT_rt.fx and replace "linear_depth" by "linear_depth_resized" throughout the shader file
- Add the following new pass :
void PS_ResizeDepth(in VSOUT v, out float4 color : SV_Target0)
{
color = tex2D(qUINT::sDepthBufferTex, v.uv).x;
}
- And call it this way, at the end of the shader file (it has to be the first pass)
pass
{
VertexShader = PostProcessVS;
PixelShader = PS_ResizeDepth;
RenderTarget = qUINT::DepthBufferTexResized;
}
Please Log in or Create an account to join the conversation.
- Marty McFly
Please Log in or Create an account to join the conversation.
- Boulotaur2024
- Topic Author
I'm doing whatever I can to make the depth buffer perfectly aligned with the backbuffer dimensions.
Otherwise I'm getting this (with the default mxao) :
That's right, the depth buffer only covers 2/3 of the screen height (sometimes the width too -depending on the game)
So I tried every trick in the book (glBlitFrarmebuffer with modified dimensions works but with a huge loss in quality since it is destructive) and the best way I could come up with perfectly aligned dimensions and good output quality was through shaders -even though I wish I didn't have to mess with shader files- by adding a "PS_ResizeDepth" pass that resize the depth to fill up the whole height and to fix the issue above.
Wait, no. The resizing part is actually done on the CPU side (c++ code), I added some specific code to fix the viewport height at the moment that "PS_ResizeDepth" is processed.
RG32F format ? Yeah, honestly I picked the first texture format that seemed to not have banding too much (RG16F had banding to my untrained eyes)
UV scaling ? Mmmh I'm not as knowledgeable as you, you know your stuff for sure, I don't even know what it means
If you have some spare time you might want to help with this.Try the dll with the default mxao shader : you'll observe the same thing I show in the pic above but you may very well come up with a better solution
Please Log in or Create an account to join the conversation.
- Niko of Death
Please Log in or Create an account to join the conversation.
- WicketW
Please Log in or Create an account to join the conversation.
- Boulotaur2024
- Topic Author
No, I removed every trace of D3D11 code path because it was poorly implemented, it was just meant as a POC.Niko of Death wrote: Is this still working with the latest PCSX2 build? I'm trying to use it with games that did work on the old DX11 build to no avail on the latest nightly. I have an AMD card if it matters.
Stick to OpenGL even if I know you're AMD user (I am one too - I feel your pain)
Thanks for the heads up, I totally forgot about rpcs3.WicketW wrote: I don't know if this is new news but reshade works with RPCS3 now in OpenGL. I get a crash when exiting and the game I'm playing glitches out when hooked but I do get depth buffer access. It'd be great if someone would look into what's causing the crashes and if the depth buffer implementation can be improved.
Will try tomorrow. I never used it. Not sure my CPU can handle it but we'll see.
EDIT :
Yeah it works, I get a crash too when I exit rpcs3. Not much of a big problem anyways (somehow the hook for glDeleteTextures fails and crashes... I have no idea why...)
The depth buffer doesn't render too well , there's something like a grid pattern... I tried many things but to no avail. It's beta software anyway (though very good)
EDIT : might have something to do with MSAA used internally in some games
You can see I added a few options in the new OpenGL pane that Crosire created last week. It should be easier to configure
Also added a few tooltips to make it even easier. Imgui is sooo cool ;p
Please Log in or Create an account to join the conversation.
- Niko of Death
Boulotaur2024 wrote:
No, I removed every trace of D3D11 code path because it was poorly implemented, it was just meant as a POC.Niko of Death wrote: Is this still working with the latest PCSX2 build? I'm trying to use it with games that did work on the old DX11 build to no avail on the latest nightly. I have an AMD card if it matters.
Stick to OpenGL even if I know you're AMD user (I am one too - I feel your pain)
Thanks for the heads up, I totally forgot about rpcs3.WicketW wrote: I don't know if this is new news but reshade works with RPCS3 now in OpenGL. I get a crash when exiting and the game I'm playing glitches out when hooked but I do get depth buffer access. It'd be great if someone would look into what's causing the crashes and if the depth buffer implementation can be improved.
Will try tomorrow. I never used it. Not sure my CPU can handle it but we'll see.
EDIT :
Yeah it works, I get a crash too when I exit rpcs3. Not much of a big problem anyways (somehow the hook for glDeleteTextures fails and crashes... I have no idea why...)
The depth buffer doesn't render too well , there's something like a grid pattern... I tried many things but to no avail. It's beta software anyway (though very good)
EDIT : might have something to do with MSAA used internally in some games
You can see I added a few options in the new OpenGL pane that Crosire created last week. It should be easier to configure
Also added a few tooltips to make it even easier. Imgui is sooo cool ;p
This was using OpenGL. Will try with new build in a bit though.
Please Log in or Create an account to join the conversation.
- otherman
Boulotaur2024 wrote: Citra : Citra is also somewhat working. For 8x native resolution enter :
What's funny is that the depth buffer is flipped/rotated at 90 degrees.[EMULATORS] EMUHeight=1920 EMUMode=1 EMUName=pcsx2 EMUWidth=3200
If you are interested in getting Reshade working with Citra, ask the devs if they can add an extra texture with the rotated depth buffer.
I had a quick look at their source code and they have a function named "DrawSingleScreenRotated" that would do the job
I opened a feature request here , please follow it.
Meanwhile, in dolphin shaders not seam to have any effect; suggestions?
Please Log in or Create an account to join the conversation.
- Drakonas
I've been trying to get Dolphin to work. I've checked your instructions over like 5 times, and double checked all the code edits in my qUINT_rt.fx shader.
I get these errors when Reshade loads:
C:\Dolphin-I\reshade-shaders\Shaders\qUINT_rt.fx(389, 41): error X3018: invalid subscript 'texcoord'
C:\Dolphin-I\reshade-shaders\Shaders\qUINT_rt.fx(389, 49): error X3000: syntax error: unexpected ')'
I'm aware that GLSL is sometimes particular about abnormal whitespace, so I made sure there are no tabs and just spaces in the file.
I'm not sure what else to do. Any ideas? Has the code been updated to prevent this?
I had this issue, but I found out I wasn't editing the shader files like the instructions further up in this thread say to do. You have to use the modified qUINT shaders and modify the RT shader with the proposed code edits. But as you can see from above, I can't get that to successfully compiled due to an invalid subscript error.otherman wrote: Meanwhile, in dolphin shaders not seam to have any effect; suggestions?
Please Log in or Create an account to join the conversation.