Depth buffer detection modifications
- conan2k
-
thalixte wrote: Strange, indeed.
Ok, so let's be orderly. Here are the last builds ok my dlls. Can you tell me wich one are the best (RE4HD, L4D2 and source engins games) ? By advance, thks.
Reshade-3b13969c5519529642169f2fd339353e0bfd11e0.zip
Reshade-5dc247f8020f7426952b10a682d87adadbc721db.zip
Reshade-41ec1bf24bc6120696e79cd7dff39dd13ba09b75.zip
Reshade-68c989e3cf1498b04eb04006272fe37d17ace52b.zip
Reshade-307a0f7cc754214ed92f3367633623fd9b7b15b9.zip
Reshade-851bb7b6e1371d66673481a5a46ffdc310a81075.zip
Reshade-4009a4b8633b41f8aa2546468e1daade297c3cf2.zip
Based on L4D2 testing, the above builds can be divided into two groups depending on the resulting behavior:
1) Correct depth map is retrieved when the Flashlight is OFF, "skybox" depth map is retrieved when the Flashlight is ON, silhouette issues are present, shadow issues are absent
- 90 (Reshade-4009a4b8633b41f8aa2546468e1daade297c3cf2)
- 104 (Reshade-3b13969c5519529642169f2fd339353e0bfd11e0)
2) These are worse than builds from the 1st group. "skybox" depth map is retrieved when the Flashlight is OFF, "rotated" depth map is retrieved when the Flashlight is ON (it can be seen on one of screenshots I've posted previously), silhouette issues are absent, shadow issues are absent too
- 93 (Reshade-851bb7b6e1371d66673481a5a46ffdc310a81075)
- 96 (Reshade-307a0f7cc754214ed92f3367633623fd9b7b15b9)
- 97 (Reshade-68c989e3cf1498b04eb04006272fe37d17ace52b)
- 100 (Reshade-41ec1bf24bc6120696e79cd7dff39dd13ba09b75)
- 101 (Reshade-5dc247f8020f7426952b10a682d87adadbc721db)
In the end, none of these builds are better than the build 85 which is able to retrieve the correct depth map when the Flashlight is both ON and OFF (but there are serious shadow issues when the Flashlight is ON).
- conan2k
-
1) Aarklash: Legacy
The depth map can be successfully retrieved after selecting "DepthBufferClearingNumber = 0" and "DepthBufferClearingFlagNumber = 2". But there are "character model colorization" issues (seems like character models are being colorized by semi-transparent selection marker color).
2) Batman: Arkham Asylum
The depth map is retrieved and the game works pretty good in general after selecting "DepthBufferClearingNumber = 0" and "DepthBufferClearingFlagNumber = 6". But there are occasional depth test issues that can mostly be seen in foggy areas as black/white/green "reminder" flashes. I've even crashed one time (it might have been related to the game itself though).
3) Mirror's Edge (the 1st one from series)
There is no way to retrieve the correct depth map so far. Different parts of depth map can be seen when changing "Before clearing" settings.
4) Styx: Master of Shadows (the 1st one from series)
The depth map is retrieved after selecting "DepthBufferClearingNumber = 0" and "DepthBufferClearingFlagNumber = 5" but there are evident depth test issues. For example, in the main menu (when you see Styx sitting on the castle wall), try switching between the "Post-processing" and "Before clearing" modes while looking at the fire above Styx (i.e. there is something like a burning torch above him).
5) Trine 2 - Complete Story
An interesting and unexpected finding in this game. The correct depth map can be retrieved even in the "Post-processing" mode when setting "RestrictDepthBufferDimensions = 0". But different shadow issues appear in this case (main character's shadow is frozen and then disappears, etc.). There are no "Before clearing" settings that allow to retrieve the correct depth map if "RestrictDepthBufferDimensions = 1" (either different parts or shrunk depth map can be seen instead).
- robgrab
-
UPDATE: I tried all 7 versions of the files you linked to. The one I've been using wasn't among those and still works the best for me. I'll post my full findings when I have more time but I did notice there were some common issues between a few of these versions. One big problem I encountered testing some of these was if I chose a setting that didn't work NONE of the settings would work after that unless I quit and restarted the game. So if I had a preset with values for Depth Buffer Clearing Number and Depth Buffer Clearing Flag Number that didn't work then no other settings would work no matter what I entered. So when I was testing a new .dll it would appear that version didn't work at all. I had to try and guess which settings would most likely work. Through trial and error Depth Buffer Clearing Numbers between Third and Eighth are the most "compatible."
The most common Depth Buffer Clearing Numbers that were empty were the First, Second, and Ninth. The Third Depth Buffer Clearing Number almost always had an issue once you raised your weapon to aim. One of two things would happen: either the screen would flicker while the laser beam on the weapon disappeared or the screen would go black causing the depth buffer to be lost no matter what settings you choose after that. I'd have to restart game to get it back.
The oddest thing I encountered was with Reshade-851bb7b6e1371d66673481a5a46ffdc310a81075 using
Depth Buffer Clearing Number = None
Depth Buffer Clearing Flag Number = 1
where only Leon's hair and laser beam on his weapon would appear when I tried to aim.
NONE of these versions had depth buffer access in the area where you're supposed to take the boat across the lake. I'll try to upload my save files so you can take a look at that area to see what makes it different than the rest.
- JoeJoe90
-
Summary: the only best solution is still the r_drawvgui 0 which hides all GUI elements, including menus. Not a convenient solution, but works.
With Depth Buffer Clear Number settings, the effects are highly varied. At some settings, water reflections ruin it (disabling water reflections using console commands helped). Some settings do absolutely nothing. In some cases, flash light disables or inverts depth buffer. One of the settings works only on the background (Source engine does a weird job with background models with the "3d skybox" feature)
r_depthoverlay draws the depth texture of the engine itself, interesting to see, how low resolution it is, also the very gradient is very rough. And the 3D sky looks weird, the depth overlay shows the closer part of it as it was very close to the camera.
Going to try the 7 uploaded DLL versions on Source based games. Tried the latest d3d9 branch from github, but didn't really work. No effect at all (needs further testing).
UPDATE
The video:
- luluco250
-
Note that the black borders on the screenshot are because of a shader I made to fix some border artifacts when running the game borderless, completely unrelated to your changes.
I've used these settings:
Other settings messed with the depth testing, this seems to work flawlessly.
Although for some reason, which could be completely unrelated, using this makes it impossible to go back to the game (on fullscreen) after alt-tabbing. If I try it, nothing happens (but the screen freezes) and I'm forced to stop the process. This sometimes happens when I use both this build and Flawless Widescreen at the same time and the game is full screen, it maybe be conflicting with that in some way, and sometimes it happens even if the game is windowed (it makes the window freeze). It might be just a fault on the poor port anyways.
Is this already on one of the branches in your repo? I wanted to merge into mine if possible (I like blending multiple cutting edge features into a single build).
- jminternelia
-
thalixte wrote: Just tested the game (at the very beginning). No problem in my case. Could you test those settings:
PreprocessorDefinitions=RESHADE_DEPTH_LINEARIZATION_FAR_PLANE=75,RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN=0,RESHADE_DEPTH_INPUT_IS_REVERSED=0,RESHADE_DEPTH_INPUT_IS_LOGARITHMIC=1
[DEPTH_BUFFER_DETECTION]
DepthBufferRetrievalMode=1
DepthBufferClearingNumber=0
DepthBufferTextureFormat=44
Same results.
So, from the beginning, yes, those settings work. However, I did observe that I could also select DepthBufferClearingNumber=2, and everything was fine.
Also, the DepthBufferTextureFormat setting apparently can be left at unknown, as it had no effect (between unknown and 44, other values weren't tested) in these tests.
Then, I checked out sarif industries, which doesn't appear to work at all with those settings, and works intermittently with others, notably DepthBufferClearingNumber must be set to "1". No other settings work.
Then, much the same in detroit, except DepthBufferClearingNumber must be set to "2", and there is intermittent breakage depending on where you are standing. In all videos, it isn't shown, but I have found consistently that DepthBufferTextureFormat can be set to unknown or 44 and it has no discernable impact on the result.
- conan2k
-
JoeJoe90 wrote: With Depth Buffer Clear Number settings, the effects are highly varied. At some settings, water reflections ruin it (disabling water reflections using console commands helped). Some settings do absolutely nothing. In some cases, flash light disables or inverts depth buffer. One of the settings works only on the background (Source engine does a weird job with background models with the "3d skybox" feature)
luluco250 wrote: I can confirm build "Reshade-4009a4b8633b41f8aa2546468e1daade297c3cf2.zip" works on Mass Effect 1:
...
Other settings messed with the depth testing, this seems to work flawlessly.
...
Although for some reason, which could be completely unrelated, using this makes it impossible to go back to the game (on fullscreen) after alt-tabbing. If I try it, nothing happens (but the screen freezes) and I'm forced to stop the process. This sometimes happens when I use both this build and Flawless Widescreen at the same time and the game is full screen, it maybe be conflicting with that in some way, and sometimes it happens even if the game is windowed (it makes the window freeze). It might be just a fault on the poor port anyways.
It's normal that only specific combinations of "Before clearing" settings are working fine in some games and don't work in others (poorly selected settings could even break the game rendering completely or cause occasional visual glitches). I.e. the lists with "Before clearing" settings are kind of universal and designed for you guys to go through and carefully select settings which are working fine in a specific game you play. Hope this explains things a bit.
BTW, Mass Effect 1-3 are indeed working fine starting from early builds with thalixte's Depth Buffer-related changes.
luluco250, regarding freezes that you experience, do they happen when you use the original ReShade 3.1.2?
PS: thalixte, sorry for being your advocate

- luluco250
-
Right, I'll look it up then.conan2k wrote: BTW, Mass Effect 1-3 are indeed working fine starting from early builds with thalixte's Depth Buffer-related changes.
Pretty sure it's completely unrelated, because I was just able to use the game for an extended period of time with thalixte's build, even when working with the game in the background. I think it was just a random coincidence that I was getting freezes on it but not on vanilla ReShade.luluco250, regarding freezes that you experience, do they happen when you use the original ReShade 3.1.2?
Also, made a video to showcase the depth buffer working.
- OtisInf
-
It happens when I pause the game with numpad 0, then enable camera, then enable display depth (so I see the depth buffer), and I move the camera with the camera tools (not the game!): the depth buffer stays the same. To get the depth buffer updated, I have to click reload on reshade. In fact, if I enable display depth I don't see anything, I have to click reload to get things working in the reshade window.thalixte wrote: @OtisInf: i tested TitanFall2 with your great camera tools. Unfortunately, i cannot reproduce your issues. In my rig, the depth buffer displays correctly, even when i am in camera mod and i pause the time, then disable the pause... have you a specific sequence where the pb occurs ?
This is also the same btw with the normal game I now notice: enable displaydepth: nothing changes when the camera is moved. Windowed or full screen, doesn't matter. Perhaps it's a weird setting of the game itself, no idea. I've everything maxed, vsync to triple buffered, adaptive resolution fps target to 60, adaptive supersampling switched off...
- jminternelia
-
41ec1bf24bc6120696e79cd7dff39dd13ba09b75 - All white - but when I press pause the depth buffer is present - even in places where the main dll (the latest dxgi32) wasn't showing all depth buffer output (i.e. all white except for phonebooth letter stenciling), however unrestricting viewport and changing DepthBufferClearingFlagNumber to 7 shows this:
5dc247f8020f7426952b10a682d87adadbc721db - same as above.
68c989e3cf1498b04eb04006272fe37d17ace52b - This one i tinkered with and found that changing the following values provides seemingly better buffer access in more places, but it still flickers out and shows something like the screenshot above. Also, massive ghosting, and textures disappearing.
[DEPTH_BUFFER_DETECTION]
DepthBufferRetrievalMode=1
DepthBufferClearingNumber=9
DepthBufferTextureFormat=0
DepthBufferClearingFlagNumber=0
RestrictDepthBufferDimensions=1
307a0f7cc754214ed92f3367633623fd9b7b15b9 - same as first (41ec1bf24bc6120696e79cd7dff39dd13ba09b75 )
851bb7b6e1371d66673481a5a46ffdc310a81075 - No access (either all white or all black) - all white except fifth - and that only displays something similar to the screenshot if viewport restriction is disabled.
4009a4b8633b41f8aa2546468e1daade297c3cf2 - No access (either all white or all black)
If I was religious about this it'd be more beneficial to use a spreadsheet for each configuration, lol.
Also, before I forget:
OtisInf wrote: Thalixte: great stuff
Isn't it taxing though to copy the textures around at that stage (as in: loss in performance?)
I notice some not wholly insubstantial hitching with this series of .dll's.
- thalixte
-
Topic Author
jminternelia wrote:
thalixte wrote: Just tested the game (at the very beginning). No problem in my case. Could you test those settings:
PreprocessorDefinitions=RESHADE_DEPTH_LINEARIZATION_FAR_PLANE=75,RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN=0,RESHADE_DEPTH_INPUT_IS_REVERSED=0,RESHADE_DEPTH_INPUT_IS_LOGARITHMIC=1
[DEPTH_BUFFER_DETECTION]
DepthBufferRetrievalMode=1
DepthBufferClearingNumber=0
DepthBufferTextureFormat=44
Same results.
So, from the beginning, yes, those settings work. However, I did observe that I could also select DepthBufferClearingNumber=2, and everything was fine.
Also, the DepthBufferTextureFormat setting apparently can be left at unknown, as it had no effect (between unknown and 44, other values weren't tested) in these tests.
Then, I checked out sarif industries, which doesn't appear to work at all with those settings, and works intermittently with others, notably DepthBufferClearingNumber must be set to "1". No other settings work.
Then, much the same in detroit, except DepthBufferClearingNumber must be set to "2", and there is intermittent breakage depending on where you are standing. In all videos, it isn't shown, but I have found consistently that DepthBufferTextureFormat can be set to unknown or 44 and it has no discernable impact on the result.
Is it possible for you to send me a save ? By advance, thks...
- thalixte
-
Topic Author
OtisInf wrote:
It happens when I pause the game with numpad 0, then enable camera, then enable display depth (so I see the depth buffer), and I move the camera with the camera tools (not the game!): the depth buffer stays the same. To get the depth buffer updated, I have to click reload on reshade. In fact, if I enable display depth I don't see anything, I have to click reload to get things working in the reshade window.thalixte wrote: @OtisInf: i tested TitanFall2 with your great camera tools. Unfortunately, i cannot reproduce your issues. In my rig, the depth buffer displays correctly, even when i am in camera mod and i pause the time, then disable the pause... have you a specific sequence where the pb occurs ?
This is also the same btw with the normal game I now notice: enable displaydepth: nothing changes when the camera is moved. Windowed or full screen, doesn't matter. Perhaps it's a weird setting of the game itself, no idea. I've everything maxed, vsync to triple buffered, adaptive resolution fps target to 60, adaptive supersampling switched off...
I guess it has something related to the game settings, because i did exactly the same tests as yours, and the depth buffer is correctly updated. When i did my tests, i moved with the camera tool, not the game. Will try yo play with the game settings to see if i can reproduce it.

- thalixte
-
Topic Author
robgrab wrote: Thanks, thalixte! This will make it much easier to track changes. I'll try to focus all of my testing on RE4.
UPDATE: I tried all 7 versions of the files you linked to. The one I've been using wasn't among those and still works the best for me. I'll post my full findings when I have more time but I did notice there were some common issues between a few of these versions. One big problem I encountered testing some of these was if I chose a setting that didn't work NONE of the settings would work after that unless I quit and restarted the game. So if I had a preset with values for Depth Buffer Clearing Number and Depth Buffer Clearing Flag Number that didn't work then no other settings would work no matter what I entered. So when I was testing a new .dll it would appear that version didn't work at all. I had to try and guess which settings would most likely work. Through trial and error Depth Buffer Clearing Numbers between Third and Eighth are the most "compatible."
The most common Depth Buffer Clearing Numbers that were empty were the First, Second, and Ninth. The Third Depth Buffer Clearing Number almost always had an issue once you raised your weapon to aim. One of two things would happen: either the screen would flicker while the laser beam on the weapon disappeared or the screen would go black causing the depth buffer to be lost no matter what settings you choose after that. I'd have to restart game to get it back.
The oddest thing I encountered was with Reshade-851bb7b6e1371d66673481a5a46ffdc310a81075 using
Depth Buffer Clearing Number = None
Depth Buffer Clearing Flag Number = 1
where only Leon's hair and laser beam on his weapon would appear when I tried to aim.
NONE of these versions had depth buffer access in the area where you're supposed to take the boat across the lake. I'll try to upload my save files so you can take a look at that area to see what makes it different than the rest.
Thks. Is it possible for you to send me a save of RE4HD ? By advance, thks...
- jminternelia
-
thalixte wrote: Is it possible for you to send me a save ? By advance, thks...
Absolutely.
drive.google.com/file/d/1vJGUKGYhpbP1PK9...9mB/view?usp=sharing
- thalixte
-
Topic Author
Thks. Will be easier to test.jminternelia wrote:
thalixte wrote: Is it possible for you to send me a save ? By advance, thks...
Absolutely.
drive.google.com/file/d/1vJGUKGYhpbP1PK9...9mB/view?usp=sharing
- thalixte
-
Topic Author
luluco250 wrote:
Right, I'll look it up then.conan2k wrote: BTW, Mass Effect 1-3 are indeed working fine starting from early builds with thalixte's Depth Buffer-related changes.
Pretty sure it's completely unrelated, because I was just able to use the game for an extended period of time with thalixte's build, even when working with the game in the background. I think it was just a random coincidence that I was getting freezes on it but not on vanilla ReShade.luluco250, regarding freezes that you experience, do they happen when you use the original ReShade 3.1.2?
It was a bug in those releases i fixed in the last ones. I introduced the fix after the build 85...
- luluco250
-
Oh ok, sorry it's a bit hard for me to keep track of releases.thalixte wrote: It was a bug in those releases i fixed in the last ones. I introduced the fix after the build 85...
- robgrab
-
thalixte wrote: thks. Is it possible for you to send me a save of RE4HD ? By advance, thks...
Of course!
www.dropbox.com/s/wbvjenej4nxyl0g/RE4_Game_Save.zip?dl=0
Note: Save number 10 (1-3 Typewriter) is the save at the lake. That's one of the few areas with no depth buffer.
Here's the path to the save game folder:
<Steam-folder>\userdata\<user-id>\254700\remote\
I also made a new video of RE4 captured at a native 3440x1440 resolution with AO, DoF, No HUD, RE4HD Textures, and used Cheat Engine to give a wider FOV. YouTube's compression is awful but it looks great running in-game. To see the best quality you need a 4K monitor or, ideally, a 21:9 aspect ratio monitor with a native resolution of 3440x1440.
- Aelius Maximus
-
Can this be done with many games?