SpriteBatch Patch 13362

Dec 10, 2012 at 9:21 AM

http://directxtk.codeplex.com/SourceControl/list/patches

Create a discussion here since I cannot reply from the patch page.

The problem with PrimitiveBatch is:

- It is slightly harder to use, you need to manually setup shaders, textures and transforms.

- It does not work well with SpriteBatch, particularly when sprites are sorted based on z order.

The problem with me is that I had a 2d sprite class that has to have skewX and skewY property in additional to position/scaleX/scaleY/rotation. I really wanted to use SpriteBatch, but this limitation killed me.

Coordinator
Dec 10, 2012 at 6:32 PM

Would a custom shader for your SpriteBatch render be enough to provide the additional transformation support?

Dec 11, 2012 at 2:16 PM

Nop, this transform matrix is per instance (quad), and there's no way to pass per instance data to custom shaders for spritebatch.

Coordinator
Dec 11, 2012 at 5:56 PM

Another option would be to encode your custom transform data into the color parameter, and use that in the vertex shader to modify output positions.

Dec 12, 2012 at 2:27 AM

That seems hacky, and lacks the ability to adjust the alpha/color of each quad. I'll still use this modified SpriteBatch for my purpose. Thanks for the response!