Pixel Shade EVERYTHING?

Started by
25 comments, last by Basiror 19 years, 7 months ago
intrestingly, ATI recomend against using the Equal and NotEqual depth tests (certainly with regards to OpenGL and probably D3D as well, same hardware and all that), so setting the depth test value to equal might not give you the best performance.

Just something to keep in mind :)
(source is page 20 in the OpenGL Opermising guide in my sig)
Advertisement
Quote:Original post by _the_phantom_
intrestingly, ATI recomend against using the Equal and NotEqual depth tests (certainly with regards to OpenGL and probably D3D as well, same hardware and all that), so setting the depth test value to equal might not give you the best performance.

Just something to keep in mind :)
(source is page 20 in the OpenGL Opermising guide in my sig)
Well, I don't know if doing it in hardware is a good idea, but the renderer you need is EXTREMELY simple so it could also be done in hardware to take some of the load off the GPU (YannL implement software occlusion culling via a simmilar method, but insted of doing per-pixel like would be done in hardware, you'd draw each pixel to the software z-buffer but only read back 'is this object visible at all')
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
you could sort your meshes by depth using the center of your mesh

and then render the list from front to back so you reduce the overdraw when rendering your Z-Pass

you probably could use this directly with your final render pass maybe implement a system that judges the complexity of your renderer and let it decide on its own which way is faster let the engine create a <mapname>.cfg which you create after you run the map for the first time
http://www.8ung.at/basiror/theironcross.html
Good advice! I'll test and see what sort of performance improvements I can get.
If you want to do textures in shaders, do you have to use a pixel shader, in otherwords, is there any way to do it using the vertex shader and just not use a pixel shader at all?
A couple of points :

1) Always use Z_LESS_EQUAL it works for the first and later passes, and you never have to worry about hw that doesn't like == or !=

2) Sorting meshes by depth is almost never a win in my experience. If you already group by shader, you can try to sort those with the same shader by depth if you must.

3) My engine performs dynamic shadowing, diffuse & specular bump mapping, and glow, with about 4 passes of 10 instruction ps.1.1 shaders at 800x600 fps at ~80 fps on a geforce 5700 ultra, using ps.1.1 shaders. 1.1 shaders are fast enough to put on everything IF you stay away from dependent reads ( tex3x2tex, tex3x3vspec, texbem, etc. ).

A single frame of dependant reads ( texbem ) got only 85 fps on a geforce 4 ti 4400 at 1024x768. That was doing nothing else. So, if you have lots of fancy water and are targeting dx8 cards, be careful.

Also really good specular is hard to do fast.

If you are targeting x800 & 6800 cards, ps.2.0 shaders of 20+ instructions are fast enough to cover the entire screen several times.
@Simmer: i didn t mean sorting the meshes by shader and then by depth but sorting them in a separate list by depth one could create a linked list for all meshes

lets say you farplane-nearplane in 4096 units

you could create 8 pointers as entrypoint into the depthlist every 512 units so you don t have to traverse the entire list everytime you want to add a mesh

this should work pretty well complex scenes since overdraw is a lot higher
http://www.8ung.at/basiror/theironcross.html
Quote:Original post by Basiror
this should work pretty well complex scenes since overdraw is a lot higher

The overhead of switching shaders is almost certainly going to be greater than any gain from early z-rejection.
Quote:Original post by cpcollis
If you want to do textures in shaders, do you have to use a pixel shader, in otherwords, is there any way to do it using the vertex shader and just not use a pixel shader at all?


I am using .fx files which allow you to use shaders and set renderstates as well. MS doesn't recommend it, but you can use a vertex shader for T&L, then use the fixed function texturing stages if you want. It says that there will be z fighting, but I haven't seen any artifacts as of yet.

Jason Z
thanks jason. I think I've realised something bad in my engine design. Everyone is probably going to cringe at this, but currently I pass the Device (DirectX) object to things that need to be drawn i.e. MyModel.Draw(device); and it uses the device to draw its primitives, set materials, textures etc. I guess I'm going to have to change everything so it doesn't draw using the device object, since its now the shaders that need parameters set. As an aside, when you do device.SetTexture(myTexture) it still works with pixel shaders, but all the examples I've seen set the texture on the effect e.g. myEffect.SetValue("myTexture", myTexture). Is this the same thing? Or does setting the texture through the device slow things down (I havent noticed any change).

Thanks again, this thread is helping greatly with my design and understanding of shaders :)

This topic is closed to new replies.

Advertisement