Controlling effect passes in SpriteBatch

Hi guys.

I have an effect with two passes that I’m using to draw sprites. I’d like to use either the first or second or both effects in different sprite batches but right now no matter what I try the sprites always render with both passes.

Is what I’m trying possible? If so what’s the correct syntax?

Further : Can I control which passes are used within a single sprite batch?

I’m not a graphics programmer so take this with a grain of salt. I’m sure someone would correct me if this is incorrect.

That said, I believe what you would want to do is create several techniques in your shader file and switch between those based on how you want to render. Something like:

technique FirstPass
{
	pass P0
	{
		VertexShader = compile VS_SHADERMODEL VertexShaderFunction();
		PixelShader = compile PS_SHADERMODEL PixelShaderFunction();
	}
};

technique SecondPass
{
	pass P0
	{
		VertexShader = compile VS_SHADERMODEL VertexShaderFunction2();
		PixelShader = compile PS_SHADERMODEL PixelShaderFunction2();
	}
};

technique BothPass
{
	pass P0
	{
		VertexShader = compile VS_SHADERMODEL VertexShaderFunction();
		PixelShader = compile PS_SHADERMODEL PixelShaderFunction();
	}
	pass P1
	{
		VertexShader = compile VS_SHADERMODEL VertexShaderFunction2();
		PixelShader = compile PS_SHADERMODEL PixelShaderFunction2();
	}
};

EDIT: If you’re using SpriteBatch you are probably just using a Pixel Shader, but the example code should still give you an idea of what I’m saying.

From Sourcecode, all passes are rendered, when you supply an effect - there is no way around it (at least in code)

But that is what passes are designed for - I think …

Why don’t you use different techniques instead?