I just started using pixel shaders with xna, but I can’t wrap my head around several things, and it seems there is no clear answer anywhere…
I use spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend); and I would like to apply shaders to a particular sprite I’m drawing and then cancel it back to a default shader or no shader.
So, can you help me with following?
-
If I have several techniques in an effect file – how do I call a particular one? Because at the moment what I do is:
shaders.CurrentTechnique.Passes[0].Apply();and it works for one technique but I would like to have many. -
If technique has several passes how do I apply all of them?
-
If I already applied a shader how do I cancel it? I can end the current sprite batch of course and start another one. But I don’t really know if that’s how it should be done for most efficiency.
Any other tips for working with pixel shaders?
You can define different techniques in your effects file like this:
From your C# code use your effects file as follows:
If you want to apply multiple passes, simply iterate over all of them like this: