Reduction Pixel Shader cost

Started by
4 comments, last by James Trotter 18 years, 7 months ago
hi... I have a question? There are two methods for reduction pixel shader cost as follows: 1.Z-Pass: Before rendering all objects,I write z-value to z-buffer for all objects. 2.Z-Sorting: Rendering images front to back allows the z-test to discard pixels before running through the pixel shader. What is the best selection. Bill.
Advertisement
Each of these methods has it's own disadvantages:

1) Rendering depth in advance is a good solution for GeForceFX+ cards, because early Z-cull is introduced only there. Also, you need to be very careful with this early Z-cull, because enabling alpha test in Z-pass will break down hierarchical Z-buffer, and you won't get any benefit. The last thing, Z-pass requires passing almost all scene geometry twice.

2) This-method requires per-object sorting, which is done on CPU and can be not very fast. Also, the same song about Z-cull and alpha-test, which breaks it down.

Your decision depends on scene geometry and average overdraw. More hard pixel shaders overdraw - use first method, more complex scene geometry - use second method (in order ro not to send geomotry twice).
Do yourself a test, and decide, whicj method is better for you.


[Edited by - superpig on September 11, 2005 11:29:08 AM]
You could of course use them both at the same time. Roughly sort your objects from front to back then do a z-pass, and afterwards do the other passes.
why would sorting the objects not be fast? the objects aren't going to change in order that many times per frame, if you keep the previous result you can probably get away with like 3 iterations of a bubble sort per frame. [and it being wrong for a single frame isn't that much of a problem, the zbuffer is still doing the sorting proeperly]

Both :) Its best to do a rough front to back sort and zfill pass for many applications. Now, depending on your class of target hardware, and pixel shaders, that might be different. If the majority of your pixel shaders are relatively short, the zfill pass may not be a win. If your doing per-pixel lighting its likely your pixel shaders take a decent amount of time. Also note that a z pre pass may save some texture bandwidth as well. Its not free though, as you have to transform the verts at least twice (less if you use occlusion query results from the z pass). Also make sure you use seperate zfill shaders to minimize shader swaps during that pass. If your fill/shader bound it will probably be a benefit.
Quote:Original post by sit
why would sorting the objects not be fast? the objects aren't going to change in order that many times per frame, if you keep the previous result you can probably get away with like 3 iterations of a bubble sort per frame. [and it being wrong for a single frame isn't that much of a problem, the zbuffer is still doing the sorting proeperly]


I just recalled a thread I read here for not so long ago, where sorting algorithms were discussed: Here. Very interesting.

This topic is closed to new replies.

Advertisement