opentoonz / opentoonz_docs

OpenToonz User Manual
http://opentoonz.readthedocs.io
28 stars 26 forks source link

SVG: Add proper support for gradient imports #199

Open BadarSaghir opened 3 years ago

BadarSaghir commented 3 years ago

I am looking for Svg import and export support so that i can use vector animations. I always face issue with svg with gradients and sometime without gradients

Just looking for vector layer properly support the svg created in inkscape with or without gradient for better workflow. Only opensource software that i found import svg properly are natron and inkscape.

RodneyBaker commented 3 years ago

Thanks for the request. Unfortunately, the only support Opentoonz has for SVG is to convert it into its native PLI vector format. Inkscape is the defacto standard for SVG and likely supports SVG better than even commercial software.

If you check back in a few years I'm reasonably confident Opentoonz will have several levels of support for SVG.

Now, having said that... It is possible to use the native PLI format to work with vector lines and fills and to maintain gradients and such but a very thorough knowledge of workflow with Opentoonz native vector format (PLI) will be required. How knowledgeable of that vector format are you at this point?

For instance, gradient fills can be maintained in PLI files exported out to SVG from Opentoonz and then reimported but those fills rely on Opentoonz palette matching so while out of Opentoonz those will be shown as solid color... bring them back into OT however and the gradient fills return (assuming nothing has broken the link or the palette order where the gradient is located hasn't changed.

To further consider some of your issues with gradient fills I will suggest looking into how Opentoonz uses palette color indexing and perhaps plan to focus on using one set palette where the color swatches never change. An issue here can be that if the indexed color points to color swatch opentoonz/opentoonz#10 where there is a vector gradient and then a different palette is used... or color opentoonz/opentoonz#10 is changed, for instance becoming opentoonz/opentoonz#11... the fill for that area/shape will change.

Having said all that... It would be good to enlist someone with very good knowledge of vector image programming and especially of the SVG format. Then we could address, firstly, some minor points of contention with conversion and thereafter fuller support of SVG. My thinking here is that this will be a three tier process with the shorter term not even designed to fix your specific issues. In the long term Opentoonz will likely need to support SVG as a dedicated level type... no small order there!

RodneyBaker commented 8 months ago

This is one of many reports that will need to be reviewed after merging opentoonz/opentoonz#5334. Some issues relate to SVG but others to PLI. It is important to understand that at this time the only way Opentoonz supports SVG is through conversion to PLI. Importantly, the Pull Request referenced here will not address gradient fills.

Gradient fills are a special case with SVG conversion especially in light of Opentoonz use of palette styles. There are a few approaches that could address gradient fills but it will take some deep diving to discover the absolute best path forward.

My personal take is that to fully support SVG (and specifically SVG 2.0 and beyond) a new SVG level type will need to be added to Opentoonz. Short of that we will also still want to still maintain and improve the converter that translates SVG to PLI and back again as even if we have full support for SVG via direct access users will still want to convert back and forth between SVG, PLI and other popular vector formats.

This note is just to suggest that with the recent fixes to SVG by @manongjohn we are still moving forward.

RodneyBaker commented 2 months ago

Moving this to Opentoonz Docs as an important step in implementation of this request will be to document the current constraints of gradient fills with respect to indexed color style in Opentoonz palettes and how they will need to match with that of gradients in SVG specification.

In short, this proper support of gradients is very doable but has some interesting complexity. Making it work simply for the user so they don't encounter any of that complexity will be challenging.