You cannot generate new vertices inside the vertex shader (you can do this in a geometric shader that ES does not have). The number of output vertices always coincides with the number of input vertices, you can only change your positions (and, of course, the ohter attributes).
Thus, you will need to draw a linear strip made of enough vertices to guarantee a smooth enough curve. What you can do is always the same linear strip having the value of the curve parameter T as 1D vertex positions. In the shader, you then use this input position (parameter value) to calculate the actual 2D / 3D position on the curve using the DeKastelau algorithm (or any other) and points P0-P4 that you put in the shader as constants (uniform variables in GLSL terms )
But I'm not sure if that would really buy you anything by simply calculating these points on the processor and incorporating them into dynamic VBO. What you save is copying the curve points from the CPU to the GPU and computing to the CPU, but on the other hand, your vertex shader is much more complicated. It needs to be assessed, which is the best approach. If you need to calculate the points of the curve in each frame (since the control points change each frame), and the curve is pretty detailed, this might not be so bad. But otherwise I donโt think it really pays. And also your shader will not easily adapt to easily changing the number of control points / degree of the curve at runtime.
But again, you cannot set 5 control points and create N curve points on the GPU. A vertex shader always works at one vertex and outputs one vertex, just like a fragment shader, always works on one fragment (for example, a pixel, although it is not yet one) and leads to a single (or missing) fragment.
source share