Depth buffer detection modifications

  • Posts: 581
2 years 4 months ago - 2 years 4 months ago #181 by thalixte
Here are two new dlls. the 32 bits one should work with RE4 HD ;)

Just disable in game anti-aliasing and play with the Depth buffer clearing number (third works fine for me)...

d3d9_32bits.zip
d3d9_64bits.zip

Those new dlls should also fix the displaying UI problem in Dark messiah, Supreme Commander, Divinity II, and so on... Could you please check this.

I revert back to the old version of input.cpp and input.hpp of the 3.1.2 release reshade lib.
Seems that, for d3d9 games, modifications introduced in the last commits lead to some displaying pbs. Will probably add an issue in the github repo...

@Crosire: could you pls test this...
The following user(s) said Thank You: Uncle Crassius, AladinZ, Nerrel, AssassinsDecree

Please Log in or Create an account to join the conversation.

  • Posts: 26
2 years 4 months ago - 2 years 4 months ago #182 by AladinZ
I confirm that Depth Buffer detection is working properly with FUEL (Made by Asobo Studio)

Display_Depth ON:



Display_Depth OFF:


I can never thank you enough. This is one of my Life-long favorite Games! I wish I could donate.

Please Log in or Create an account to join the conversation.

  • Posts: 42
2 years 4 months ago - 2 years 4 months ago #183 by Nerrel

thalixte wrote: Sorry to say that my modifs do not impact OpenGL games for the moment.

I should have followed up on this, is it possible for OpenGL games to receive the same type of mods? Or can this only be done for D3D?


EDIT: This part can be ignored, as I didn't have the "depth is reversed" preprocessor setting correct.

RE4 is working with AA disabled and the third clearing number, but it's hard to get MXAO to give a natural result. The AO generally isn't applied to the environment in the way it should based on what I've seen in other games, and turning the sample radius up at all results in Leon's back being blackening out regardless of position as well as odd shapes in the sky getting shaded:
Warning: Spoiler! [ Click to expand ]

Warning: Spoiler! [ Click to expand ]


Turning the radius down fixes those issues, but it still generally doesn't look so hot and doesn't shade a lot of objects that it should:
Warning: Spoiler! [ Click to expand ]


It's great that it's working at all, but it doesn't seem usable yet... unless I'm doing something way wrong.

Please Log in or Create an account to join the conversation.

  • Posts: 228
2 years 4 months ago - 2 years 4 months ago #184 by Uncle Crassius

Nerrel wrote: RE4 is working with AA disabled and the third clearing number, but it's hard to get MXAO to give a natural result. The AO generally isn't applied to the environment in the way it should based on what I've seen in other games, and turning the sample radius up at all results in Leon's back being blackening out regardless of position as well as odd shapes in the sky getting shaded:
Turning the radius down fixes those issues, but it still generally doesn't look so hot and doesn't shade a lot of objects that it should:
It's great that it's working at all, but it doesn't seem usable yet... unless I'm doing something way wrong.


Looks like depth buffer is inverted. Try switching the corresponding preprocessor setting off when it's on or vice versa.

Please Log in or Create an account to join the conversation.

  • Posts: 533
2 years 4 months ago - 2 years 4 months ago #185 by lowenz
Those new dlls should also fix the displaying UI problem in Dark messiah.

Yes but still no DB.

Please Log in or Create an account to join the conversation.

  • Posts: 46
2 years 4 months ago #186 by conan2k

thalixte wrote: Those new dlls should also fix the displaying UI problem in Dark messiah, Supreme Commander, Divinity II, and so on... Could you please check this.


Yes, all of UI issues previously reported by me are gone with these new DLLs (well, there is still a problem in Supreme Commander 1/2 but it's the same as in the original ReShade). Besides, the depth map can now be successfully retrieved for the following games:
1) Divinity II: Developer's Cut
Seems to work fine with "DepthBufferClearingNumber=7" even when the HDR option is enabled in the game now (there are various shading artifacts with other clearing numbers). Awesome!

2) King's Bounty: Warriors of the North
Works fine with "DepthBufferClearingNumber=3"!

3) X3: Terran War Pack
Works fine with "DepthBufferClearingNumber=3"!

Please Log in or Create an account to join the conversation.

  • Posts: 42
2 years 4 months ago #187 by Nerrel

Uncle Crassius wrote: Looks like depth buffer is inverted. Try switching the corresponding preprocessor setting off when it's on or vice versa.


You're right! It looks great now, definitely adds a lot to the game. The only issue is that cutscenes don't seem to work:

Please Log in or Create an account to join the conversation.

  • Posts: 46
2 years 4 months ago #188 by conan2k
But, there are still problems with the depth buffer access in these games:
1) The Witcher: Enhanced Edition Director's Cut
The depth map can now be retrieved with different clearing numbers but it's not "complete" (i.e. various objects and/or main character are missing in the retrieved depth map). Besides, selecting any clearing number other than None breaks the game rendering (there are partially transparent walls, missing shadows, etc.).

2) Fallout 3 GotY
The depth map can now be retrieved with "DepthBufferClearingNumber=5" but it's disappearing randomly and breaks the game rendering (for example, MXAO randomly becomes "frozen" and moves together with the camera view).

3) Far Cry 2
The depth map can now be retrieved with "DepthBufferClearingNumber=5" but it's flickering wildly. Besides, selecting any clearing number other than None breaks the game rendering (disappearing objects/walls, etc.).

I'll test more games as I have time.

Please Log in or Create an account to join the conversation.

  • Posts: 272
2 years 4 months ago #189 by robgrab

thalixte wrote: Here are two new dlls. the 32 bits one should work with RE4 HD ;)

Just disable in game anti-aliasing and play with the Depth buffer clearing number (third works fine for me)...

d3d9_32bits.zip
d3d9_64bits.zip

Those new dlls should also fix the displaying UI problem in Dark messiah, Supreme Commander, Divinity II, and so on... Could you please check this.

I revert back to the old version of input.cpp and input.hpp of the 3.1.2 release reshade lib.
Seems that, for d3d9 games, modifications introduced in the last commits lead to some displaying pbs. Will probably add an issue in the github repo...

@Crosire: could you pls test this...


You did it! I never thought I'd see the day we'd get depth buffer access in RE4. If you need help testing anything else or have a way to donate to you please let me know. Thank you so much! I can die happy now. :) :) :)

Please Log in or Create an account to join the conversation.

  • Posts: 581
2 years 4 months ago - 2 years 4 months ago #190 by thalixte

Nerrel wrote:

thalixte wrote: Sorry to say that my modifs do not impact OpenGL games for the moment.

I should have followed up on this, is it possible for OpenGL games to receive the same type of mods? Or can this only be done for D3D?


EDIT: This part can be ignored, as I didn't have the "depth is reversed" preprocessor setting correct.

RE4 is working with AA disabled and the third clearing number, but it's hard to get MXAO to give a natural result. The AO generally isn't applied to the environment in the way it should based on what I've seen in other games, and turning the sample radius up at all results in Leon's back being blackening out regardless of position as well as odd shapes in the sky getting shaded:
Turning the radius down fixes those issues, but it still generally doesn't look so hot and doesn't shade a lot of objects that it should:

It's great that it's working at all, but it doesn't seem usable yet... unless I'm doing something way wrong.


Sorry to hear that, but my modifs only concist in retrieving the existing depth buffer, not modifying it. Maybe you could ask Marty Mc Fly to help you in this way :)

Please Log in or Create an account to join the conversation.

  • Posts: 581
2 years 4 months ago - 2 years 4 months ago #191 by thalixte

conan2k wrote: But, there are still problems with the depth buffer access in these games:
1) The Witcher: Enhanced Edition Director's Cut
The depth map can now be retrieved with different clearing numbers but it's not "complete" (i.e. various objects and/or main character are missing in the retrieved depth map). Besides, selecting any clearing number other than None breaks the game rendering (there are partially transparent walls, missing shadows, etc.).

2) Fallout 3 GotY
The depth map can now be retrieved with "DepthBufferClearingNumber=5" but it's disappearing randomly and breaks the game rendering (for example, MXAO randomly becomes "frozen" and moves together with the camera view).

3) Far Cry 2
The depth map can now be retrieved with "DepthBufferClearingNumber=5" but it's flickering wildly. Besides, selecting any clearing number other than None breaks the game rendering (disappearing objects/walls, etc.).

I'll test more games as I have time.


Thks for your feedback. When i have time, will test Witcher 1. The problem you describe is the same i had with Mass Effect 2. It seems too that some games use a different clearing flag than the others. So the best i could do is check if i cannot find a proper clearing flag for Witcher 1, otherwise, as you mentionned, it breaks the depth map, that's why you see "transparent" objects, because the depth test always succeed in this specific case :cheer:

Please Log in or Create an account to join the conversation.

  • Posts: 228
2 years 4 months ago #192 by Uncle Crassius

thalixte wrote: Sorry to hear that, but my modifs only concist in retrieving the existing depth buffer, not modifying it. Maybe you could ask Marty Mc Fly to help you in this way :)


All good, just a flipped depth buffer. Other than that, tested the latest one with Lord of the Rings: War in the North and couldn't get depth to work. There don't seem to be any anti aliasing settings, though, so maybe that's to blame.

Please Log in or Create an account to join the conversation.

  • Posts: 533
2 years 4 months ago - 2 years 4 months ago #193 by lowenz

lowenz wrote: Yes but still no DB.

Errata corrige!

Dark Messiah and Sin Emergence CAN give their DB (clearing value 3-4-5) but it's "unstable" (some part of the scene with 3, some others with 4 or 5).
It's the same behaviour of Deus Ex Human Revolution DC (d3d11).....

Please Log in or Create an account to join the conversation.

  • Posts: 581
2 years 4 months ago - 2 years 4 months ago #194 by thalixte

lowenz wrote:

lowenz wrote: Yes but still no DB.

Errata corrige!

Dark Messiah and Sin Emergence CAN give their DB (clearing value 3-4-5) but it's "unstable" (some part of the scene with 3, some others with 4 or 5).
It's the same behaviour of Deus Ex Human Revolution DC (d3d11).....


Ah. bad news. And if you select Post processing ? Or maybe this is a specific clearing flag.

Please Log in or Create an account to join the conversation.

  • Posts: 344
2 years 4 months ago - 2 years 4 months ago #195 by OtisInf
I built reshade from source (master, latest) to see whether the depth buffer techniques added recently would find the depth buffer in Titanfall 2, but no dice, no matter what I pick (post process, in merger stage, before clearning etc.) the depth buffer stays empty (or filled with ones). Is there a particular combination I need to choose? TIA

Please Log in or Create an account to join the conversation.

  • Posts: 581
2 years 4 months ago - 2 years 4 months ago #196 by thalixte

OtisInf wrote: I built reshade from source (master, latest) to see whether the depth buffer techniques added recently would find the depth buffer in Titanfall 2, but no dice, no matter what I pick (post process, in merger stage, before clearning etc.) the depth buffer stays empty (or filled with ones). Is there a particular combination I need to choose? TIA


Hi OtisInf ;) In titanFall2, there is a working combination with the latest master build. Be sure not to be online for this to work. As soon as i am at home, i will give it to you :cheer:

Please Log in or Create an account to join the conversation.

  • Posts: 533
2 years 4 months ago - 2 years 4 months ago #197 by lowenz

thalixte wrote:

lowenz wrote:

lowenz wrote: Yes but still no DB.

Errata corrige!

Dark Messiah and Sin Emergence CAN give their DB (clearing value 3-4-5) but it's "unstable" (some part of the scene with 3, some others with 4 or 5).
It's the same behaviour of Deus Ex Human Revolution DC (d3d11).....


Ah. bad news. And if you select Post processing ? Or maybe this is a specific clearing flag.

About SIN it seems the culprit is the overlay handling....when you show the demoplayer (SHIFT+F2 -> i use SHIFT+F3 for ReShade in Source Engine powered games) the DB is correctly retrieved and here's the MXAO applied:

File Attachment:


File Attachment:

Please Log in or Create an account to join the conversation.

  • Posts: 344
2 years 4 months ago #198 by OtisInf

thalixte wrote:

OtisInf wrote: I built reshade from source (master, latest) to see whether the depth buffer techniques added recently would find the depth buffer in Titanfall 2, but no dice, no matter what I pick (post process, in merger stage, before clearning etc.) the depth buffer stays empty (or filled with ones). Is there a particular combination I need to choose? TIA


Hi OtisInf ;) In titanFall2, there is a working combination with the latest master build. Be sure not to be online for this to work. As soon as i am at home, i will give it to you :cheer:

Thanks! Will try to be offline indeed, that's something I forgot to check.

Please Log in or Create an account to join the conversation.

  • Posts: 46
2 years 4 months ago #199 by conan2k

thalixte wrote: Thks for your feedback. When i have time, will test Witcher 1. The problem you describe is the same i had with Mass Effect 2. It seems too that some games use a different clearing flag than the others. So the best i could do is check if i cannot find a proper clearing flag for Witcher 1, otherwise, as you mentionned, it breaks the depth map, that's why you see "transparent" objects, because the depth test always succeed in this specific case :cheer:


How difficult is it to find a proper clearing flag? Maybe it would be reasonable to provide the community with instructions and ability to enter a Custom Clearing Flag (when pre-defined ones from the list don't work)? Since I don't know how these clearing flags work exactly, I apologize if I'm suggesting something stupid :)

Please Log in or Create an account to join the conversation.

  • Posts: 581
2 years 4 months ago #200 by thalixte

OtisInf wrote:

thalixte wrote:

OtisInf wrote: I built reshade from source (master, latest) to see whether the depth buffer techniques added recently would find the depth buffer in Titanfall 2, but no dice, no matter what I pick (post process, in merger stage, before clearning etc.) the depth buffer stays empty (or filled with ones). Is there a particular combination I need to choose? TIA


Hi OtisInf ;) In titanFall2, there is a working combination with the latest master build. Be sure not to be online for this to work. As soon as i am at home, i will give it to you :cheer:

Thanks! Will try to be offline indeed, that's something I forgot to check.


Here are the settings in the dxgi.ini file:

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

[DEPTH_BUFFER_DETECTION]
DepthBufferRetrievalMode=2
DepthBufferClearingNumber=0
DepthBufferTextureFormat=2

:cheer:
The following user(s) said Thank You: OtisInf

Please Log in or Create an account to join the conversation.