Jump to content
  • Advertisement
Sign in to follow this  
Roof Top Pew Wee

How to change "color operations" in FX files.

This topic is 4258 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 just started learning a bit about shaders and I'm trying to reproduce a lot of the fixed function stuff in .fx files. I understand how to grab colors from the vertex color or texture, and I understand that I can perform operations per-pixel in the pixel shader function. My question is how are color operations commonly switched? Should I just have many techniques which call different pixel shader functions in my .fx file according to the color opreations I desire? This seems like it could get messy if I start adding other things that I want to do depending on different "states". That is, if I have 3 different kinds of color operations, 3 different ways I want to apply colors, that's 9 techniques right there to handle all combinations. Add a 3rd "state" and the numbers get astronomical and impossible to manage. Is this just something that I have to deal with regarding shaders, or are there different ways to "combine" functions according to states. Thanks again, and I apologize for the poor terminology and lack perhaps basic question - this is pretty new stuff to me. --Vic--

Share this post


Link to post
Share on other sites
Advertisement
This is a fairly common problem with shaders - combinatorial explosion.

There are various tactics that can be used such as writing code with lots of compile-time constants and then getting the compiler to generate 100's (or 1000's) of combinations from the same set of code.

You can always use constant parameters though, this way you can write a more generic set of shaders and have the application specify the finer details when it comes down to rendering.

hth
Jack

Share this post


Link to post
Share on other sites
Thanks for the info. A few follow-up questions.

I've heard that in SM3, you can have if statements. Is this true, and if so, is it expensive considering this is very low level code.

Quote:

You can always use constant parameters though, this way you can write a more generic set of shaders and have the application specify the finer details when it comes down to rendering.


I'm not quite sure I understand what you mean by this. Could you give me an example? Thanks.

--Vic--

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!