Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SVG as WebGL texture #286

Closed
samreid opened this issue Sep 28, 2014 · 8 comments
Closed

Support SVG as WebGL texture #286

samreid opened this issue Sep 28, 2014 · 8 comments
Assignees

Comments

@samreid
Copy link
Member

samreid commented Sep 28, 2014

Perhaps we can have high resolution scalable vector graphics that render quickly if we can make WebGL textures out of SVG images. We could render them at the desired resolution, or mipmap them.

One idea @jonathanolson suggested: It may be possible to do this by putting the svg content as a base 64 in a div so it can be used as a texture, but we would have to check whether that is supported by IE. I think there is some discussion of that issue in webkit here, but I am not entirely sure about the context: https://gitorious.org/qtwebkit/qt5x2/commit/e87bae47b4beebc07afb21de8e6d8bee5c1e4ba6

Another possibility: using a 3rd party canvas renderer like canvg to render the svg document to a raster, as discussed here:
mrdoob/three.js#1317

One possible situation to look at with this feature: color vision has nice vector graphics for the character's head, but rendering it as svg decreases performance, so it is currently rasterized and a little blurry. (Actually we could look into manually rendering the svg with canvg without webgl too).

@samreid samreid self-assigned this Sep 28, 2014
@samreid
Copy link
Member Author

samreid commented Dec 10, 2014

Using HTMLImageElement (like new Image()) with svg + mip mapping is looking great on OSX/Chrome, Win/Chrome and iPad Retina. Haven't got it working on IE yet.

@samreid
Copy link
Member Author

samreid commented Jan 12, 2015

Not clear how we should implement spritesheeting with SVG unless using something like https://github.com/gabelerner/canvg

Hmmm.. On the other hand, why not use SVG as the spritesheet? Perhaps SVGs can be added as children, and rasters could be added as SVG images?

@jonathanolson
Copy link
Contributor

Use of canvg (which didn't seem to properly support patterns previously) might be a good option.

Another option would be to convert the SVG into a Scenery form (code to construct a sub-tree) automatically, so that we can rasterize it at arbitrary resolutions. It also works around pattern failures in IE since we would be using Canvas.

@samreid
Copy link
Member Author

samreid commented Jan 12, 2015

convert the SVG into a Scenery form (code to construct a sub-tree) automatically

Can you elaborate on this? Not sure specifically what you mean.

@jonathanolson
Copy link
Contributor

Converts SVG like

<rect x="40" y="50" ...

into Scenery code like

var rect4 = new scenery.Rectangle( 40, 50, ...

@samreid
Copy link
Member Author

samreid commented Jan 13, 2015

Thanks for explaining--seems like a huge project to handle arbitrary SVG code, though! The SVG spec is quite large AFAIK. Would we benefit from implementing a popular subset?

@jonathanolson
Copy link
Contributor

Thanks for explaining--seems like a huge project to handle arbitrary SVG code, though! The SVG spec is quite large AFAIK. Would we benefit from implementing a popular subset?

We would presumably implement the popular subset we need. Scenery can't support many of the features yet anyways (filters, etc.).

@samreid
Copy link
Member Author

samreid commented Mar 4, 2015

@jonathanolson ran into security problems that prevent us from using SVG for our simulations and instead worked on a mipmap plugin. Therefore, we do not need to support WebGL/SVG at the moment. Closing.

@samreid samreid closed this as completed Mar 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants