Sign in to follow this  

Is my depth pass correct?

This topic is 3112 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been trying to incorporate a depth pass into my terrain rendering pipeline as, in principal, I might get an improvement in performance. My pipeline is like this (with average CPU timings per operation): RenderPrep (produce a list of patches to be drawn) ~0.05 ms RenderDepth (switch on ZWriteEnable; switch off ColorWrite; iterate through patches drawing each using very bare minimum shaders - return float4(0,0,0,0)) ~0.35ms RenderColour (switch off ZWriteEnable; switch on ColorWrite; iterate through patches drawing each using full shaders) ~0.5ms A typical view of my map is ~50 DIP consisting of ~102,400 triangles (since one patch/DIP call is always 2048 tris - 32x32 tilesize). I don't actually get any improvement in framerate with the depth pass, in fact it's quite a bit worse. I think this is partly because the particular area of my terrain that I test with isn't overly 'occlusive', i.e. there aren't that many pixels hidden by closer pixels and partly because I'm not sure if I'm setting up the depth pass correctly. I thought it might get quicker if I view the terrain by positioning the camera in front of a steep slope which occludes most of the terrain, but the performance is still poor. I could maybe try using a bigger patch size (8192 tris - 64x64) which would result in a quarter of the DIP calls, but then I might end up with a lot more 'wasted' triangles, i.e. those that are clipped by the viewport - maybe this doesn't matter so much nowadays. Is this generally the right method for incorporating a Depth Pass? Is it correct also that in some places it's actually going to degrade performance if not many pixels are hidden by closer pixels? Thanks

Share this post


Link to post
Share on other sites
It seems right,but maybe your pixel shader isn't heavy enough? Vertex buffer switch,transformation in vertex shader,two passes and so on-it may increase total time.
Try to do occlusion query in first Z-pass,and use this info.

Share this post


Link to post
Share on other sites
The depth only pass typically helps the most (in my experience) when your pixel shading is very expensive. Something like sampling 4 shadow maps, a reflection map, an SSAO map, and some fancy lighting model on top of that would be pretty expensive if you have a high overdraw. Depending on how irregular your terrain is, you may or may not see enough saved pixel shader invocations to make it worth the extra rendering pass.

However, where you can save some performance is when you need the depth pass already. If you are using D3D10, you could utilize the depth pass for SSAO calculations, some motion blur techniques, and some depth of field techniques as well. If you stack up the algorithms that need that information, then the overall benefits will start to add up.

What type of pixel shading are you using for your terrain?

Share this post


Link to post
Share on other sites
In article about making cryengine 2 some guy from crytek said that early z-pass is good in complicated scenes ( like in crysis ). If you are using early z-pass only with terrain it's going to be slower then without it. But if you are going to put a lot of geometry with highly complicated pixel shaders into the scene its going to change and then you will see benefits from using early z-pass.

So don't worry be happy :)

Share this post


Link to post
Share on other sites
Some advices:

1. Performance testing the GPU by CPU timing is always a bad idea. In fact you tested the time you need to transfer your data/commands to the GPU, but you don't tested the actual rendering time. So transfering your scene two times is indeed slower than just one time ;_) Take a look at your timing, you got 0.8ms for all your rendering calls which leads to an theoretical fps of ~1250, but I'm sure your actual fps will be lower than that.

2. Just rendering terrain will not really have a heavy impact on the overdraw rate. As soon as you add plants, trees, buildings, characters your overdraw rate will increase, independent from your shader costs. Well, in a forward render engine a pre-z pass will finally be a good idea, as long as you don't have extrem high poly number and batch calls combined with very cheap pixel shaders.

3. Optimizing separated parts of your engine is somewhat inefficient. It's always a time sink leading to more misstakes than improvements :) Try to add more things to your engine before optimizing. It just doesn't matter if your terrain engine runs with 500 or 2000 fps, but it does matter if your final engine runs with 40 instead of 20 fps :)

Well, keep your pre-z pass in and add more things ^^


--
Ashaman

Share this post


Link to post
Share on other sites

This topic is 3112 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this