Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualHodgman

Posted 04 December 2012 - 06:48 PM

should I be implementing a given feature (eg shadow mapping) multiple times for every shader that needs it, or should I be trying to create a "it-does-everything" shader?

Regardless of whether you want to make an "everything shader" or not, you shouldn't have to re-implement a feature over and over again by copying and pasting code. Put that feature into a function, and put that function into a header file, then #include the header file wherever it's needed and call the function.

And as a follow up, could I be writing my shaders to be more modular? I'm currently not using the ability to have multiple techniques or passes as I don't follow how they should be used.

"Techniques" are a property of the Microsoft FX system, not something that necessarily has to exist. IMO, an "FX Technique" is a single shader, and an "FX File" is a collection of shaders.
Whether you want to include multiple techniques in an FX file (multiple shaders in a collection) is just an organizational choice. It makes no real difference.

The ability for FX Techniques to have multiple passes was more useful on older hardware, when people actually wrote multi-pass shaders all the time.

#1Hodgman

Posted 04 December 2012 - 06:46 PM

should I be implementing a given feature (eg shadow mapping) multiple times for every shader that needs it, or should I be trying to create a "it-does-everything" shader?

Regardless of whether you want to make an "everything shader" or not, you shouldn't have to re-implement a feature over and over again by copying and pasting code. Put that feature into a function, and put that function into a header file, then #include the header file wherever it's needed and call the function.

And as a follow up, could I be writing my shaders to be more modular? I'm currently not using the ability to have multiple techniques or passes as I don't follow how they should be used.

"Techniques" are a property of the Microsoft FX system, not something that necessarily has to exist. IMO, an "FX Technique" is a single shader, and an "FX File" is a collection of shaders.
FX Techniques can have multiple passes, but this was more useful on older hardware, when people actually wrote multi-pass shaders all the time.

PARTNERS