BachiLi / diffvg

Differentiable Vector Graphics Rasterization
https://people.csail.mit.edu/tzumao/diffvg/
Apache License 2.0
902 stars 152 forks source link

There is a problem in the rendering process for gradient colors. #68

Open hh0525 opened 10 months ago

hh0525 commented 10 months ago

I initialized 2048 paths, with half of them filled with solid colors, and the other half filled with gradient colors (including linear and radial gradient). I optimized the SVG using L2 loss. When I open the final SVG with a browser like Edge, it appears to be full of color patches as below. iter_499 However, the final PNG rendering result is great. iter_499 I use render_svg.py in diffvg/apps folder to convert SVG to PNG and I get the same result: SVG is poor but PNG is great. What is the problem? I hope someone can help me.

c1enyang commented 8 months ago

Hi, I have the same problem. Did you solve it now?

hh0525 commented 7 months ago

image I found that the problem came from the color sampling process of forward rendering. The parameter pt passed in this function is the coordinate of the point in the image space (canvas_width*canvas_height), but in fact it should be the relative position of the point in the path, similar to begin and end in linearGradient.

c1enyang commented 7 months ago

image I found that the problem came from the color sampling process of forward rendering. The parameter pt passed in this function is the coordinate of the point in the image space (canvas_width*canvas_height), but in fact it should be the relative position of the point in the path, similar to begin and end in linearGradient.

Great! Can you tell me how to solve the color sampling problem? I am not familiar with this.