Pass vertices into shader from the script

Hey folks!

The goal is to generate a 2D polygon programmatically and apply a texture to it. I’ll also need to save vertices’ coordinates so that I could draw the same shape in the next game session.

As I get, there is no drawing API in Defold, so that I decided to dive into GLSL and solve the problem using shaders but can’t find any reference of how I could pass vertices into shader from the script. Any ideas?

Thanks!

Not possible at the moment. The only thing you can do is rearrange existing 16 vertices of a model. Shaders support max 16 uniforms.

You can draw to texture using drawpixels extension, but it would be hard to apply a texture. Another super hardcore way is to write native extension which would hack into Defold’s rendering process, but that’s way too hard and not recommended.