Deep deferred shading demo

Humus

Crazy coder
Veteran
I have a new demo available that's implementing a technique that allows translucent objects to be used with deferred shading, without resorting to forward rendering passes for these objects. This is done by extracting different depth layers into slices in a texture array using depth peeling. Then in the deferred passes the shader traverses as many layers as needed to compute the total lighting contribution, blending the layers on the fly.

DeepDeferredShading.jpg


Download here
 
I'll admit that I've not seen the demo as I don't have time right this second but I'm impressed already. Depth peeling with texture arrays and deferred shading - nice combo :cool:

Excuse the ignorance maybe, but mind if I ask how this fits with the regular deferred shading approach? Or is this covered in the download docs? Just wondering how ~8 MRT's can be used for this without seperating into multiple pre-passes?

Keep up the good work!
Jack
 
There were some errors when I run the demo. When moving the camera rectangular chunks of the screen is faulty. It looks like some surface isn't cleared or something?
 
Similarly, the depth buffer is also a texture array. In this demo three layers are used, which allows for up to two translucent layers in front of an opaque surface
So I see 6 MRT's already, position, normal... 8 MRT's... convenient, or am I just jumping the gun for not having time to dig into the code you've most kindly donated to the community?

Jack
 
So I see 6 MRT's already, position, normal... 8 MRT's... convenient, or am I just jumping the gun for not having time to dig into the code you've most kindly donated to the community?

It's 2 MRTs, one for diffuse and one for normals, but each is three slices deep. Each texture array counts as a single render target*. The position is extracted from the depth buffer, which is 3 slices too. The pre-passes are done one slices at a time.

* You could theorethically render to 8 times the max primitive output from GS number of surfaces in a single pass.
 
A word in your shell like humus, take a seat. have a marmite sandwich
Now i thought we agreed on fireworks
 
Very nice stuff! I'm happy to see that this runs at a pretty nice frame-rate (>100fps @ 1920x1200). Now all we need are some nice coloured shadows from the glass and we're laughing :)

Seriously though, that's really neat. I've always been a big fan of deferred shading and this chips off another one of the common complaints, and indeed does so more flexibly than standard ROP-based forward blending does.
 
I got a 8600GT card and driver version 7.15.11.6375, it's the latest PerfHUD driver (5.1). The screen looks good at startup but that's the only time.

Tile sizes of 16x16, so that's probably the depth buffer that's gone crazy. It's most definitely cleared. This looks very much like a driver bug. I would assume that the driver simply forgets to clear the Hi-Z data, or mismanages it in some way.

Now all we need are some nice coloured shadows from the glass and we're laughing :)

That would be possible with a deep shadow map. It would be slower though. I considered doing that, but I got lazy. I wanted to get this done since I have other ideas I want to take on next. But I guess for this demo it would probably be enough to assume a single layer and simply do like I did in this old demo.
 
That would be possible with a deep shadow map. It would be slower though. I considered doing that, but I got lazy.
Yup, first-layer coloured projection you could do with just a depth map for each color channel (equivalent to your "store depth and colour" example). Handling multi-layer coloured shadows can be done with any of the more complex shadow mapping methods that can model distributions/layers - such as deep, variance, convolution and opacity shadow maps - each with various trade-offs. I've been meaning to write up some quick samples of this as well but also haven't had the time :)

Your continully neat demos have inspired me to at least post the fluids demo that I wrote up a few months ago (I'll get to that hopefully tonight or tomorrow)...

Anyways kudos for another neat demo, and also for making me stop being lazy :D

Davros said:
ps: can Deep deferred shading not be done in dx 9
This demo uses texture arrays. While you could certainly use viewports/atlasig in DX9, the rendering would be more complicated and probably require multiple passes (a la typical depth peeling). There was a clever way to reduce these pass counts from a Microsoft whitepaper a while ago, but it wasn't exactly cheap and it had some weird reliances on "undefined" API behaviour, such as reading and writing the same texture :D
 
This demo uses texture arrays. While you could certainly use viewports/atlasig in DX9, the rendering would be more complicated and probably require multiple passes (a la typical depth peeling).

Well, if the number of layers is relatively low you could just use multiple textures. Each layer is filled separately anyway. As long as the number of attribute textures you need times the number of layers is not more than 16, it should be workable. For this demo it would be 9, diffuse, normal and depth, with three layers.
Loops will have to be unrolled since each layer will be on a separate sampler, but I do that with the DX10 version too for a tiny performance improvement, so that shouldn't be much of a problem.

There was a clever way to reduce these pass counts from a Microsoft whitepaper a while ago, but it wasn't exactly cheap and it had some weird reliances on "undefined" API behaviour, such as reading and writing the same texture :D

Yeah, I skimmed through that. Another option might be to use stencil routing. It would reduce it to a single pass, plus sorting pass. However, it might still be slower than depth peeling since all layers, including hidden ones behind opaque surfaces will be rendered. I found that in this demo filling the buffers was the bottleneck and that's what I had to optimize. Separating it into a pre-z pass and then filling the buffers after that boosted performance a lot.
 
Last edited by a moderator:
Can you Actually have coloured shadows - in real life I mean ?
When I say "coloured shadows" I mean shadows cast from translucent objects, such as the stained glass in this demo. The only differentiation between these shadows and typical ones are that they only attenuate *part* of the incoming light rather than *all* of it.
 
Can you Actually have coloured shadows - in real life I mean ?
You've never done any theatre, have you? The lighting usually always has coloured filters and so if you have, say, red and green lights the scene will be lit yellow but the shadows will be shaded red (in the shadow of the green light), green, and 'ambient' (in the shadows of both).
 
Back
Top