Depth Buffer + Normals access for Post-process shaders

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: GZDoom Developers

Depth Buffer + Normals access for Post-process shaders

Postby Rachael » Thu Aug 01, 2019 9:37 pm

Hello.

I would like to be able to access the depth buffer at the very least, with post-processing shaders, as well as the normals buffer.

The use case that I have for this is to be able to create a proper cel-shading post-process shader (similar to what games like Borderlands have), using the depth buffer (and possibly normals to detect corners) in order to create borders instead of just extremely unreliable pixel sampling.
User avatar
Rachael
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Debian-like Linux (Debian, Ubuntu, Mint, etc) 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Depth Buffer + Normals access for Post-process shaders

Postby Marisa Kirisame » Fri Aug 02, 2019 12:19 am

This has been shot down before, but now even one of the developers wants this, I see.

Maybe we can make this possible by hooking these shaders in during the ssao pass(es)?
User avatar
Marisa Kirisame
ZScript Crimester
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: 霧雨魔理沙#1666
Twitch ID: MarisaDOOM
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Depth Buffer + Normals access for Post-process shaders

Postby Kinsie » Fri Aug 02, 2019 3:09 am

IIRC this was turned down because portals perform horrible black magic that renders the basic concept of "depth" a lie.
User avatar
Kinsie
Dog Days
 
Joined: 22 Oct 2004
Location: MAP33
Discord: Find Me...
Twitch ID: thekinsie

Re: Depth Buffer + Normals access for Post-process shaders

Postby phantombeta » Fri Aug 02, 2019 3:16 am

It was turned down because portals have to be "sealed", or things will draw where they shouldn't. But turns out, if you think about it for a moment, it's actually not that hard to figure out a way to get a clean depth buffer for shaders.

Basically, the simplest way to deal with this is have the depth buffer for PP shaders just be an extra texture. You render the geometry to it in the world rendering pass in addition to the normal colour buffer, and just draw the depth value to it.
However, you don't draw the "sealing" to it, so this depth texture remains "unsealed", while the actual depth buffer gets sealed, so that it doesn't render things where it shouldn't.

The drawbacks of this method are (very slightly) higher VRAM usage and possibly very slightly more work for the GPU (but not really that much), but it's certainly not that bad of a price to pay to have a proper depth buffer for shaders.
This would also actually allow SSAO to be done normally, too, so it'll be able to happen for all portals with recursive ones instead of having to be limited to a certain number.
User avatar
phantombeta
Tired of being treated like trash by control freaks
 
Joined: 02 May 2013

Re: Depth Buffer + Normals access for Post-process shaders

Postby dpJudas » Fri Aug 02, 2019 8:10 am

The SSAO pass has to run before translucent stuff (anything where alpha is not 0 or 1) or it will not look right. That is actually the primary reason it has to run where it does, because portal rendering means it renders everything inside a portal before sealing it up.

I don't think it is a good idea to allow custom shaders access to the internal gbuffers as they may change. A much better solution would be to allow custom gbuffers, possibly where you would specify some of the channels being the normals or depth and the engine would then do a copy.
dpJudas
 
 
 
Joined: 28 May 2016


Return to Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests