Shaders to write to the DepthBuffer

  • AlucardDH
  • Topic Author
More
2 years 6 months ago #1 by AlucardDH Shaders to write to the DepthBuffer was created by AlucardDH
Hello Crosire,

For a lot of games, there is no depthbuffer (old games, or using DosBox for example) or a corrupted one (emulators..).
We could build a specific version of Reshade with custom DephtBuffer (somebody already did this for emulators but it's based on an old version and pretty buggy).

So, I tried to compute/correct DepthBuffers with shaders and save it to a new texture, that i then use by modifying Reshade common library (GetLinearizedDepth).
I achieved some results but it's very hacky.
So, i wondered if it would be possible to directly write to the depthbuffer so it's available without changing commons or other shaders per game basis.
Or if it's not possible to write to the DepthBuffer, add a hook to commons to enable using a custom texture as depthbuffer.

Best regards.

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

  • crosire
More
2 years 4 months ago #2 by crosire Replied by crosire on topic Shaders to write to the DepthBuffer
It's not possible to write to the texture shaders reference via the "DEPTH" semantic, as that generally uses a special depth-stencil format that is read-only in shaders (and can only be written to by the rasterizer).
So the only solution is to declare a custom texture with a normal format (e.g. R32F) and use that in all shaders (simply replace "DepthBufferTex" in ReShade.fxh with a full custom texture definition, instead of the current declaration with a "DEPTH" semantic; textures with the same name are shared across effect files, so that will just work). But it sounds like you are already doing something like that.
The following user(s) said Thank You: AlucardDH

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

  • AlucardDH
  • Topic Author
More
2 years 4 months ago #3 by AlucardDH Replied by AlucardDH on topic Shaders to write to the DepthBuffer
Thanks for your answer.

Creating a global to use a custom texture and a few functions to use the game depthBuffer to update the custom depthBuffer could be nice.

I'm not sure if it could be useful even for a small number of people but do you accept pull-request on your different repos ?

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.