Jump to content
  • Advertisement
Sign in to follow this  
cpcollis

Pixel Shade EVERYTHING?

This topic is 5131 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

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
:) 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 ;)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!