to make a semitransperent glowing mesh.I want to make different material types for my meshes and each material corresponding to a combination of effects.For instance a Metal material(metal has reflection - 1 effect) or Glass(glass has a little reflection,but is also transperent and also has difraction - 3 effects).Or do I have to make one huge material shader and use different techniques for the different effect combinations?
Probably, the most used approach is to write a huge shader (usually called uber-shader) and create different permutations using #if's #ifdef's, etc
For example:
float4 PS(PS_IN pIN) : SV_TARGET0
{
#ifdef REFLECTIVE
//reflection code here
#endif
#ifdef TRANSPARENT
//transparency code here
#endif
//and more #if's
}
Then you can generate the correct permutation needed for the material when you compile the shader by defining only the needed constants.
So to answer you question, you can't use multiple shaders (effects) at the same time, so you have to combine everything in a single shader to achieve the effect you want...
Probably, the most used approach is to write a huge shader (usually called uber-shader) and create different permutations using #if's #ifdef's, etc
For example:
float4 PS(PS_IN pIN) : SV_TARGET0
{
#ifdef REFLECTIVE
//reflection code here
#endif
#ifdef TRANSPARENT
//transparency code here
#endif
//and more #if's
}
Then you can generate the correct permutation needed for the material when you compile the shader by defining only the needed constants.
So to answer you question, you can't use multiple shaders (effects) at the same time, so you have to combine everything in a single shader to achieve the effect you want...
Probably, the most used approach is to write a huge shader (usually called uber-shader) and create different permutations using #if's #ifdef's, etc
For example:
float4 PS(PS_IN pIN) : SV_TARGET0
{
#ifdef REFLECTIVE
//reflection code here
#endif
#ifdef TRANSPARENT
//transparency code here
#endif
//and more #if's
}
Then you can generate the correct permutation needed for the material when you compile the shader by defining only the needed constants.
So to answer you question, you can't use multiple shaders (effects) at the same time, so you have to combine everything in a single shader to achieve the effect you want...
Don't if statements in the shader cause a huge fps drop?Maybe I should just make a seperate .fx file for each material,so I never have to use ifs in them.
Don't if statements in the shader cause a huge fps drop?Maybe I should just make a seperate .fx file for each material,so I never have to use ifs in them.
I'm talking about precompiler #if's. This kind of conditionals disappear after the shader is compiled. You pass the compiler the definitions you want and it will generate a shader without any #if.