I am using a SpriteBatch to render large amounts of sprites very fast. Now I want to modify the sprites with shaders to tint them in a color.
Problem 1: Altering an uniform by getting the shader and setting it between the begin/end of the batch changes the whole scene not only a single sprite. E.g.:
"EngineView.getShader().setUniformf("u_blue", (float) Math.random());"
Problem 2: It is relatively slow.
Also I found this which seems to cover the same (no proper solution): (Setting uniform value of a vertex shader for different sprites in a SpriteBatch):
You almost certainly don't want to actually do this. Changing a uniform for every quad/sprite is going to severely impact the throughput of your renderer. Much of the GPU will be sitting idle while you're drawing one measly sprite at a time. The whole point of a "sprite batch" is to draw as many sprites at the same time with as few draw calls or state changes as possible. If you need random data in your shader, use a noise texture or a noise function. stackoverflow.com/questions/4200224/… – Sean Middleditch May 23 at 21:22
My question is, if I don't want to actually do this, what is it I want to do?