Pixel Shade EVERYTHING?

Started by
25 comments, last by Basiror 19 years, 7 months ago
Now that I've got my shaders working at last thanks for all your help everyone :) I was wondering, since using the FF pipeline up until now, is "pixel shading" to be used sparingly or should everything go through a pixel shader, since every operation in the FF was per vertex, is there a massive overhead from working at the pixel level? In other words, should I leave the pixel shading to only the important models or pixel shade the entire world? Thanks
Advertisement
The overhead of a pixel shader depends on what you're doing. If you're simply doing standard rendering with no frills, then there's no difference from using the fixed function pipeline.

If your shader is costly, though, that changes everything.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
So if I wanted to do a single directional light and a specular effect in the pixel shader, is that considered costly. I'm very new to shaders so I'm not sure what is considered costly. Are you talking about multi-pass shaders or simple stuff like this. I'm probably going to stick to 1.1 shaders single-pass for now anyways.
If you need a complex shader on something, then use it, at worse you'll just end up having to run at a smaller screen size and/or provide less complicated fall back code if required (their card cant handle it for example)
Ok but what is a costly/complex shader considered to be?
basically the more instructions, the longer the shader, the more costly is going to be.

Thats a basic rule of thumb, some things are more expensive on one card than another.
Quote:Original post by cpcollis
Ok but what is a costly/complex shader considered to be?


it's entirely subjective. if it slows down your game / is the bottleneck, it's costly.

-me
:) Thanks for your replies, I'll mess around and see what happens, your right tho, I guess if I can get away with pixel shading everything, then why not ;)

Quote:Original post by cpcollis
Now that I've got my shaders working at last thanks for all your help everyone :) I was wondering, since using the FF pipeline up until now, is "pixel shading" to be used sparingly or should everything go through a pixel shader, since every operation in the FF was per vertex, is there a massive overhead from working at the pixel level? In other words, should I leave the pixel shading to only the important models or pixel shade the entire world?

Thanks


The primary reason to not use pixel shaders for everything is for hardware that doesn't have them. On almost all new hardware, FF is emulated by the driver creating a pixel shader under the covers which does whatever state you set the FF to.

If you plan to target only hardware with programmable shading, then it is perfectly reasonable to only use shadsers.
EvilDecl81
One thing you might want to consider doing (that can speed your engine up TREMENDOUSLY depending on how you've implemented it already) is creating a z-test occlusion pass. Essentially, it works like this: First, render the whole scene with EVERYTHING off (no pixel shaders, no color writing, nothing) except for z-writing. Next, set the Z test to 'Z Equals' so only objects with the same Z as in the buffer will get drawn. That way, if there are 500 objects straight back with reall complex pixel shaders, the last of them won't get drawn, and only those parts of the front ones that are visible will be rendered and 'pixel shaded'.

This can allow you to use relatively complex shaders while still maintaining a decent framerate by eliminating overdraw and only calling pixel shaders for visible pixels.

You have to remeber not to draw anything with any kind of translucency during this phase though - you'll still need to process those in the normal way after all opaque material has been processed.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk

This topic is closed to new replies.

Advertisement