Talk:Depth buffer

From Valve Developer Community
Jump to: navigation, search

Scaling the depth output

This section doesn't make any sense. What does "scaling" the output mean? I would have thought making the depth 'fog' extend further, yet the page doesn't say that. And then what exactly are we being told to do? "Render all opaque geometry in a scene with modified shaders" is incredibly vague, and the rest of the section is apparently telling us all about something we can't do?

Can you provide screens and code, please? --TomEdwards 12:14, 16 January 2011 (UTC)

As you noticed, the available range of the default depth buffer is very short. 'Scaling the depth output' simply means adjusting the range - do you think the term 'quantify' would make it clearer then? This has nothing to do with 'fog' at all - I was wondering why you would want to compare it anyway. All of the things I mentioned can be done, I personally didn't try the third option of shader replacement yet, that's all, but if standard filesystem rules apply it should be possible. I can provide screenshots of a larger depthbuffer in source with 32bit precision or anyone could take a look at zeno clash's depth buffer which has increased range, yet 8bit precision -> strong colour banding, but I don't think that's necessary as it looks the same (well, my depth is inverted), it just has another range.
I tried explaining how it works with more detail, for anyone who could care about that anyway, that part should make clear why 'scaling/quantifying' the output should be the correct term. --Biohazard 12:40, 16 January 2011 (UTC)
What kind of code would you want to see exactly? Other than changing the line I mentioned, recompiling the shaders and then using SDK_ shaders instead of default ones there's nothing else to do. --Biohazard 12:40, 16 January 2011 (UTC)
OK, I'm getting a clearer picture. I thought you were giving us two solutions to extend range, but in fact they are both part of the same one. There is only one thing I still don't understand: of the three options given in your first para, which one is the modification of OO_DESTALPHA_DEPTH_RANGE? It reads like it's impossible to override the standard shaders right now... (A screen of a proper depth buffer in Source would be great, upload away!) --TomEdwards 13:29, 16 January 2011 (UTC)
The second one is the modification - "the definition should be changed to this:"
Since i'm not using this myself at all (8bit limitation due to backbuffer format) I have to recompile all shaders first etc, so I will upload it later today. I can also provide code on how to reallocate the depth buffer texture, so anti-aliasing does not break. But you will see that the colour banding is a huge issue for effects like SSAO, just DoF could maybe get away with that.
"It reads like it's impossible to override the standard shaders right now" This is kinda hard to explain I think, sorry, I will try it again though; you can't override default shaders like UnlitGeneric with a custom shader dll, it will give you an error if you try to do so. So the most stable solution would be to change all 'UnlitGeneric' in vmt files to SDK_UnlitGeneric (same goes for every other opaque and $alphatest material, since $translucent does not draw depth). My idea was to override the .vcs files in Sourcemods/modname/shader/fxc with custom compiled ones - so the default UnlitGeneric shader would load a custom .vcs, but this would be unstable since you must ensure that the combos are setup the excat same way. Maybe it doesn't even work, I didn't try it out, but it would be the easiest solution if you were just to change the depth range. --Biohazard 13:38, 16 January 2011 (UTC)


Would you want to add to the article a list of shaders/effects that can/would utilize the depth buffer? I know of SSAO and DoF but nothing else specific. Thelonesoldier 06:31, 18 January 2011 (UTC)

@Thelonesoldier Shadowmapping, more accurate godrays, soft water, soft particles (they work, but only up to 128 units according to the page on here, even though depth is 192.) --Legend286 00:00, 8 April 2011 (UTC)

This belongs specialized. Make that list elsewhere, perhaps close to Shader Authoring.--1/4 Life 08:38, 18 January 2011 (UTC)