Manual depthbuffer flip

More
6 years 4 weeks ago #21 by OtisInf
Replied by OtisInf on topic Manual depthbuffer flip
In Reshade.fx, at line 98 you see:
return depth;

Replace that with
return -depth;

It seems the SSAO shader now uses the normalized buffer created by that shader in Reshade.fx instead of its own (which was the case in 1.0).

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

More
6 years 4 weeks ago #22 by Moonkey
Replied by Moonkey on topic Manual depthbuffer flip

In Reshade.fx, at line 98 you see:
return depth;

Replace that with
return -depth;

It seems the SSAO shader now uses the normalized buffer created by that shader in Reshade.fx instead of its own (which was the case in 1.0).

Oh! Thank you. I spent about 3-4 hours tweaking certain values to no success. I wouldn't have thought of that :P

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

More
6 years 4 weeks ago #23 by Kleio420
Replied by Kleio420 on topic Manual depthbuffer flip

In Reshade.fx, at line 98 you see:
return depth;

Replace that with
return -depth;

It seems the SSAO shader now uses the normalized buffer created by that shader in Reshade.fx instead of its own (which was the case in 1.0).


idk why they didnt just put a setting in for any games working under a upside down buffer (unity engine)

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

More
5 years 11 months ago - 5 years 11 months ago #24 by Uncle Crassius
Replied by Uncle Crassius on topic Manual depthbuffer flip
Pushing this old thread, hope it's ok. Just adding the "-" doesn't seem to work with 1.1.0, buffer's still flipped, like upside down (in Layers of Fear if you're curious). Anything I might miss? Is it possible that it just might be the game or should it theoretically work with every flipped depth buffer? It does look like it flips normals, not the 2D ssao output itself.

Edit: Ok, the solution to my problem rather seems to be this . After changing reshade.fx it gives out an error message, though, so I must've made some mistakes. Does that solution work with 1.1.0 at all? If yes, could anyone give more precise insturctions for a coding noob like me which lines to add and which to delete, if any?
Last edit: 5 years 11 months ago by Uncle Crassius.

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

More
5 years 10 months ago #25 by Moonkey
Replied by Moonkey on topic Manual depthbuffer flip
I'd also like to know how to get this fix. American Truck Simulator's buffer is flipped, and simply placing a negative after depth at the same line does not flip the depth.

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

More
5 years 10 months ago #26 by crosire
Replied by crosire on topic Manual depthbuffer flip
There is a difference between upside-down depth and inversed depth. This fixes the latter. The former is fixed with a "texcoord.y = 1 - texcoord.y" at the beginning of the depth storage function in ReShade.fx.
The following user(s) said Thank You: NattyDread

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

More
5 years 10 months ago #27 by Moonkey
Replied by Moonkey on topic Manual depthbuffer flip

There is a difference between upside-down depth and inversed depth. This fixes the latter. The former is fixed with a "texcoord.y = 1 - texcoord.y" at the beginning of the depth storage function in ReShade.fx.

I'm not sure how I would do that? That doesn't seem to fit anywhere where you specify.
// Fullscreen Triangle Vertex Shader
void RFX_VS_PostProcess(in uint id : SV_VertexID, out float4 pos : SV_Position, out float2 texcoord : TEXCOORD)
{
	texcoord.x = (id == 2) ? 2.0 : 0.0;
	texcoord.y = (id == 1) ? -2.0 : 0.0;
	pos = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}

#if RFX_InitialStorage
float4 RFX_PS_StoreColor(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
	return tex2D(RFX_backbufferColor, texcoord);
}
#endif
#if RFX_DepthBufferCalc

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

More
5 years 10 months ago #28 by crosire
Replied by crosire on topic Manual depthbuffer flip
Right below line 85.
float  RFX_PS_StoreDepth(in float4 position : SV_Position, in float2 texcoord : TEXCOORD0) : SV_Target
{
texcoord.y = 1 - texcoord.y;
...
The following user(s) said Thank You: NattyDread, Moonkey

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

More
5 years 9 months ago #29 by Janson
Replied by Janson on topic Manual depthbuffer flip

Pushing this old thread, hope it's ok. Just adding the "-" doesn't seem to work with 1.1.0, buffer's still flipped, like upside down (in Layers of Fear if you're curious). Anything I might miss? Is it possible that it just might be the game or should it theoretically work with every flipped depth buffer? It does look like it flips normals, not the 2D ssao output itself.

Edit: Ok, the solution to my problem rather seems to be this . After changing reshade.fx it gives out an error message, though, so I must've made some mistakes. Does that solution work with 1.1.0 at all? If yes, could anyone give more precise insturctions for a coding noob like me which lines to add and which to delete, if any?

ReShade.fx, replace the code at line 89 with this:
float2 source = float2(texcoord.x, 1.0-texcoord.y);
float depth = tex2D(RFX_depthColor, source).x;

It's tested on Layers of Fear and Oddworld Strangers Wrath, probably works with other games too.
Credit to OtisInf!

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

More
5 years 9 months ago #30 by crosire
Replied by crosire on topic Manual depthbuffer flip
ReShade 2.0 will have a RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN option for this: github.com/crosire/reshade-shaders/blob/...r/ReShade/Global.cfg.
The following user(s) said Thank You: SpinelessJelly, jas01, davemode

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

More
5 years 9 months ago #31 by Janson
Replied by Janson on topic Manual depthbuffer flip

ReShade 2.0 will have a RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN option for this: github.com/crosire/reshade-shaders/blob/...r/ReShade/Global.cfg.


Nice, is the release date for 2.0 close?

Another thing, the linearization of the depthbuffer/value, is this a method that has to be done always a certain way or is it possible to do it several different ways? What I'm trying to get at, some games that seemingly don't show information inside the depthbuffer visualisation, is it possible that they have to be approached individually/differently to get to that information?

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

More
5 years 9 months ago #32 by crosire
Replied by crosire on topic Manual depthbuffer flip

Another thing, the linearization of the depthbuffer/value, is this a method that has to be done always a certain way or is it possible to do it several different ways? What I'm trying to get at, some games that seemingly don't show information inside the depthbuffer visualisation, is it possible that they have to be approached individually/differently to get to that information?

Yes. Some games use a reverse depth buffer, some a logarithmic one, some both (i.e. GTA V), some the default (i.e. Need for Speed). So you need to play around with the "RESHADE_DEPTH_INPUT_IS_REVERSED" and "RESHADE_DEPTH_INPUT_IS_LOGARITHMIC" options (or their equivalents in 1.1).
The following user(s) said Thank You: SiriusHours

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

More
4 years 10 months ago - 4 years 10 months ago #33 by NoMansReshade
Replied by NoMansReshade on topic Manual depthbuffer flip
How would I do this in MXAO in Reshade 3.0?

EDIT:
IGNORE ME IM STUPID!!!! (found out what a preprocessor definition is)
Last edit: 4 years 10 months ago by NoMansReshade.

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