Do you know of some lib or algorithm to transform an SVG path into a set of vertices / indices / faces to work with WebGL?
Do you know of some lib or algorithm to transform an SVG path into a set of vertices / indices / faces to work with WebGL?
Do you know of some lib or algorithm to transform an SVG path into a set of vertices / indices / faces to work with WebGL?
Check out the NV_path_rendering extension or more precisely the
paper about it published at Siggraph Asia 2012. The paper's
references list several papers describing the various techniques.
Note, the extension is for native OpenGL and is currently only
available in NVIDIA drivers (version > 300 recommended for very
high performance).
Regards
-Mark
NOTE: This electronic mail message may contain confidential and privileged information from HI Corporation. If you are not the intended recipient, any disclosure, photocopying, distribution or use of the contents of the received information is prohibited. If you have received this e-mail in error, please notify the sender immediately and permanently delete this message and all related copies.
That is actually a reasonable thing to propose adding as a WebGL extension because:
- it is relatively hard to do yourself in application code (implementing SVG is hard)
- browsers already have a SVG implementation anyways.
You could send an email to public_webgl about that if you care.
Converting SVG paths to triangles is probably not the best
approach. For one thing maintaining smooth curves requires
re-tesselation when the scale changes. Again I refer you to the
paper about the NV_path_rendering extension. I firmly believe its
stencil then cover approach is the right way to get accurate and
numerically stable results regardless of path complexity.
I'm with Gregg, for my own reasons.
Why in the world would we expect browsers to implement SVG on top of WebGL when they don't even implement a real 3D format natively yet?
Having the browsers implement SVG on top of WebGL is indeed the
wrong way around. If something like NV_path_rendering were to
become widespread in OpenGL implementations then the browsers
could implement their entire graphics stack on OpenGL with
beautiful and fast results. Then WebGL would merely need to expose
the underlying path functions.
Furthermore the true integration of 2D vector graphics and 3D
graphics enabled by this technology would open up many interesting
possibilities for web applications and browsers. Web "pages" would
probably become something of a misnomer.
...
While I myself would love to see some kind of basic 3D "scene graph" or other high level data format implemented natively (my VRML prejudice showing here), for the moment I'm OK with having to deal with it at the app level, and I would object strenuously to any data formats getting preferential treatment, especially non-3D ones.
Attached are 2 images of our corporate web page rendered entirely
on the GPU with NV_path_rendering. The first shows the entire
page, the second is a zoom-in on part of it. Note, I reduced the
images to 50% of their original size, to keep the size of this
message down, which may have introduced some artefacts. The
originals are completely artefact free.