How to write to SV_Depth?

  • Fu-Bama
  • Topic Author
More
7 years 7 months ago #1 by Fu-Bama How to write to SV_Depth? was created by Fu-Bama
I'm trying to UV-distort the depth buffer along with the image distortion, for effects that follow and use depth.
Problem is that I don't know how to write to the depth buffer SV_Depth.
I tried to write the depth to Pass1 alpha channel, then in second pass, that targets SV_Depth, return the alpha channel from the first one.
But it gives an error undefined variable "_return"

Shader Code:
Warning: Spoiler!

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

  • crosire
More
7 years 7 months ago #2 by crosire Replied by crosire on topic How to write to SV_Depth?
This is not going to work, unfortunately. The depth-stencil buffer bound for writing is not the one you get as input.
In fact ReShade does not guarantee a depth buffer being bound during post-processing at all, it's only defined to at least bind a stencil buffer when the render target size matches that of the game viewport (SMAA needs this). A depth buffer doesn't make much sense during post-processing usually, because we only draw fullscreen primitives that should not be depth sorted.
Depth data you get as input comes straight from the depth texture the game had bound as depth buffer during rendering, but it's considered immutable at this point like all resources ReShade gives access to. The backbuffer is the one and only exception. Giving write access to any other resource would come with a heavy performance penalty and is therefore not allowed nor implemented.

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

  • Fu-Bama
  • Topic Author
More
7 years 7 months ago #3 by Fu-Bama Replied by Fu-Bama on topic How to write to SV_Depth?
Thanks for the answer.

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

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.