We’ve supported setting a custom ShaderProgram on a SpriteBatch for ages, via a call to SpriteBatch#shaderProgram. You could also share the same ShaderProgram across multiple SpriteBatch instances by passing it to the constructor of a SpriteBatch.
The issue with this was that the two kinds of custom shaders (one set via setShader, one set via the constructor), received different uniforms, as reported in this issue.
Today i fixed this, and also changed another thing:
- Both the ShaderProgram passed to the constructor of a SpriteBatch and a ShaderProgram set via SpriteBatch#setShader() will now only receive a single uniform matrix called “u_projTrans”, containing the combined view and transform matrix
- Custom shaders set via SpriteBatch#setShader previously got 3 uniform matrices, u_proj, u_trans and u_projTrans. I removed setting of u_proj and u_trans. The SpriteBatch will only set the combined view and transform matrix now. If you need additional uniforms, you can set them after SpriteBatch#begin()