I've got a shader where I set the normal map using EffectParameterCollection:
however when it renders the image, it always uses the current contents of _effectsParams, not the contents when Draw(...) was called. It doesn't seem like SpriteBatch saves the contents of the EffectParameterCollection as the context of the Draw call.
The result of this is that everything is drawn correctly if I use SpriteSortMode.Immediate, unfortunately I am drawing a lot of sprites and Immediate is pretty slow. I'd like to use one of the faster sort modes like SpriteSortMode.BackToFront or Deffered, unfortunately every image in those cases is rendered using the NormalTexture map of the last image.
I've attached a screenshot to give an idea of what's going on... I've got the base goblin, and then I want to swap out of the weapons and armor as needed. What's going on in this image is the SpriteSortMode is set to Deferred, and the weapons & armor are being rendered incorrectly with the normal map from the goblin instead of the correct one.
Am I doing something wrong? Anyone have any ideas?