Jump to content

  • Log In with Google      Sign In   
  • Create Account


Can you use multiple .fx file effects at the same spot?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Veil   Members   -  Reputation: 143

Like
0Likes
Like

Posted 15 May 2012 - 04:14 PM

For instance,using

glow->Begin(&numPasses,0);
glow->BeginPass(0);
    opacity->Begin(&numPasses,0);
    opacity->BeginPass(0);
	    myMesh->Render();
    opacity->EndPass();
    opacity->End();

glow->EndPass();
glow->End();

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?

Sponsor:

#2 TiagoCosta   Crossbones+   -  Reputation: 2041

Like
0Likes
Like

Posted 15 May 2012 - 04:58 PM

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...

Edited by TiagoCosta, 15 May 2012 - 05:03 PM.


#3 Veil   Members   -  Reputation: 143

Like
0Likes
Like

Posted 16 May 2012 - 03:20 AM

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.

#4 TiagoCosta   Crossbones+   -  Reputation: 2041

Like
0Likes
Like

Posted 16 May 2012 - 04:07 AM

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.

You can pass the definitions in the pDefines argument of the D3DXCreateEffectFromFile function.

In my example above if you just define TRANSPARENT the compiled shader will only have the transparency related instructions... Check this link.

Edited by TiagoCosta, 16 May 2012 - 04:11 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS