Shaders to write to the DepthBuffer

More
1 month 3 weeks 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.

More
6 days 1 hour 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.

More
1 day 7 hours 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.