HumbleUI / Skija

Java bindings for Skia
Apache License 2.0
498 stars 34 forks source link

How to update shader uniforms? #64

Open catgirljenni opened 7 months ago

catgirljenni commented 7 months ago

I have made a runtime effect with RuntimeEffect.makeForShader(shaderSrc); I have created the shader with effect.makeShader(Data.makeFromBytes(data), null, null, false) (data being a byte buffer of uniforms) I created the paint with paint = new Paint(); paint.setShader(shader);

The problem is, none of these classes have a method to update the uniforms in the shader. How do I do this? I can't just re create the shader as it takes ~3ms to create and uniforms need to be updated each frame.

tonsky commented 7 months ago

Hm. It takes only 0.02..0.06 ms for me https://github.com/HumbleUI/Skija/blob/a63330f37f24d57b457e625d861b121689c8d182/examples/scenes/src/RuntimeEffectScene.java#L59

You can try asking on https://groups.google.com/g/skia-discuss/, if there’s a better way I’m happy to provide API for it