It took me ages to find a workable (= fast enough) solution to draw cubic splines in OSL. The quadratic version is simple enough because the shortest distance to a quadratic curve is a cubic equation which can be solved analytically, but the shortest distance to a cubic spline is a quintic equation for which there are only numerical methods.
Fortunately I finally found one, and although it toook quite some work to translate the original C-version to OSL (because OSL doesn’'t know recursion) I am quite pleased with the resullt.
Tweaked the code a bit & made it 2D instead of full 3D because i think the major use case is w. uv coords. Code still contains 3D lines, just undef CALC2D macro in source. The result is a 10% speed increase (and a lot messier code
Judging from the number of replies on this thread (zero), cubic splines in OSL is not that interesting to most people so I’ll stop tweaking it, but 10% may be worth it so I have updated the code on GitHub anyway
basically anything is possible in OSL and it certainly can read xml and thus SVG (via its dictionary functions) but from a practical point of view it would be unfeasible I think because it would be way to slow (the xml file would be cached but for each shader sample all primitives in the SVG would need to be examined).
That’s great, I have seen some users in GLSL generate solid geometry out of thin air (e.g. a sphere has a vector 3 attribute for position and a float attribute for size). In OpenGL this is a great way to optimize graphics (e.g. you won’t have to create vertex buffer objects).
I guess that this might be handy for doing something similar as well, generating various lines (hair?) based on raw data, who knows?