# In XNA 4, how can I access SpriteBatch's transformMatrix in my shader?

I would like to use a custom effect with a regular XNA SpriteBatch. I have a 2D camera which computes a transform matrix, so I need my shader to take this into account.

I have put a world matrix property into my shader:

float4x4 World;


However, it does not get set by SpriteBatch:

spriteBatch.Begin(spriteSortMode, blendState, samplerState,
depthStencilState, rasterizerState, effect, camera.WorldToScreen);


Everything is rendered properly if I set it manually in the draw loop:

effect.Parameters["World"].SetValue(camera.WorldToScreen);


How can I set up my shader parameters to make SpriteBatch set them up correctly?

In the SpriteEffect source, the world matrix is actually float4x4 MatrixTransform
• I tried changing the shader to float4x4 MatrixTransform;  but no luck! – dfgdhdgh Oct 25 '14 at 17:08