Hi!
Let’s discuss rendering curves (e.g. Bezier) in Defold. Any ideas?
So far I tried rendering via pixel shader: pass curve control points from vertex shader, use texture coordinate X as input to calculate point on curve and check with texture coordinate Y (with some offset) - if the pixel is on curve or not. Result is not so good :\
One of my todo project is nice vector shape rasterization with buffers via native extension. Something like Skia Graphics Library. This would support curves drawn fast with good accuracy, smoothing, and effects. You could investigate drawing curves to buffer with size of window and updating them with native extension code.
Buffers do work with HTML5 last time I tested. You don’t want to modify the buffers with Lua scripts but with native extensions. I don’t know if there would still be performance issues with HTML5 build even with NE modifying the buffer.
It should be fairly performant as long as you reuse the buffer and don’t create a new one every frame. I’m manipulating buffers in Imp but that example/asset is recreating the buffer when the image processing is applied.
It’s the same approach I tried ( if I understood you correct)
The sprite (or gui node, e.g. we can send data via color vector) should be square this way to make the line thickness constant.
Also, I have some doubts about performance of long curves.
@britzl
Is it possible to modify mesh’s vertex buffer by native extension or any other way? E.g. by generating collada mesh in runtime and applying it to model?
This is definitely something we want to add, we have had some experiments with it but nothing deliverable yet. The next step is to do a design with our experiments in mind, but I can’t say when it will be available.