I'm new to working with shaders, and have somehow ended up diving straight into the deep end. I could really use some guidance.
I've been trying to reverse-engineer this: https://vicrucann.github.io/tutorials/bezier-shader/
I have made some progress, for example, re-writing the toBezier
function to be less utterly incoherent and illegible:
vec2 bezier_position(float pixel_increment, uint index, vec2 start_anchor, vec2 start_handle, vec2 end_handle, vec2 end_anchor)
{
float progress = pixel_increment * float(index);
vec2 point = (1.0 - progress) * (1.0 - progress) * (1.0 - progress) * start_anchor;
point += 3.0 * (1.0 - progress) * (1.0 - progress) * progress * start_handle;
point += 3.0 * (1.0 - progress) * progress * progress * end_handle;
point += progress * progress * progress * end_anchor;
return point;
}
But that's as far as I've gotten, and trying to puzzle out the rest of it is making me realize that I just don't know how shaders in Godot work at all, and the Shaders section of the docs just doesn't explain.
For example, how do you declare an array? Can you even? Is that allowed? If not, what do instead? And I don't understand how outputting to the render target works at all. How do I tell my shader to actually draw things?
Is this even the right approach?